2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00

fix: Add Item Type Product or Service

- Automatically set Income and Expense account and hide them from View
This commit is contained in:
Faris Ansari 2019-12-23 18:50:47 +05:30
parent f2071c96df
commit 47ce6117d1

View File

@ -30,6 +30,14 @@ module.exports = {
default: 'Unit',
options: ['Unit', 'Kg', 'Gram', 'Hour', 'Day']
},
{
fieldname: 'itemType',
label: 'Type',
placeholder: 'Sales',
fieldtype: 'Select',
default: 'Product',
options: ['Product', 'Service']
},
{
fieldname: 'incomeAccount',
label: 'Income',
@ -43,6 +51,15 @@ module.exports = {
isGroup: 0,
accountType: 'Income Account'
};
},
formulaDependsOn: ['itemType'],
formula(doc) {
if (doc.itemType === 'Product') {
return 'Sales';
}
if (doc.itemType === 'Service') {
return 'Service';
}
}
},
{
@ -56,15 +73,12 @@ module.exports = {
getFilters: () => {
return {
isGroup: 0,
accountType: [
'in',
[
'Cost of Goods Sold',
'Expense Account',
'Stock Received But Not Billed'
]
]
accountType: ['in', ['Cost of Goods Sold', 'Expense Account']]
};
},
formulaDependsOn: ['itemType'],
formula() {
return 'Cost of Goods Sold';
}
},
{
@ -81,14 +95,7 @@ module.exports = {
placeholder: '0.00'
}
],
quickEditFields: [
'rate',
'unit',
'incomeAccount',
'expenseAccount',
'tax',
'description'
],
quickEditFields: ['rate', 'unit', 'itemType', 'tax', 'description'],
layout: [
// section 1
{