diff --git a/models/baseModels/Item/Item.ts b/models/baseModels/Item/Item.ts index 351bf5b57..653230355 100644 --- a/models/baseModels/Item/Item.ts +++ b/models/baseModels/Item/Item.ts @@ -58,16 +58,28 @@ export class Item extends Doc { }; static filters: FiltersMap = { - incomeAccount: () => ({ - isGroup: false, - rootType: AccountRootTypeEnum.Income, - }), - expenseAccount: (doc) => ({ - isGroup: false, - rootType: doc.trackItem - ? AccountRootTypeEnum.Liability - : AccountRootTypeEnum.Expense, - }), + incomeAccount: (doc) => { + if (doc.fyo.singles.AccountingSettings?.itemAccountFiltering) { + return { + isGroup: false, + rootType: AccountRootTypeEnum.Income + } + } else { + return {isGroup: false} + } + }, + expenseAccount: (doc) => { + if (doc.fyo.singles.AccountingSettings?.itemAccountFiltering) { + return { + isGroup: false, + rootType: doc.trackItem + ? AccountRootTypeEnum.Liability + : AccountRootTypeEnum.Expense + } + } else { + return {isGroup: false} + } + }, }; validations: ValidationMap = { diff --git a/schemas/app/AccountingSettings.json b/schemas/app/AccountingSettings.json index 469979928..d0ce5ebef 100644 --- a/schemas/app/AccountingSettings.json +++ b/schemas/app/AccountingSettings.json @@ -100,6 +100,13 @@ "default": false, "section": "Features" }, + { + "fieldname": "itemAccountFiltering", + "label": "Filter out non expense accounts for items", + "fieldtype": "Check", + "default": true, + "section": "Features" + }, { "fieldname": "fiscalYearStart", "label": "Fiscal Year Start Date",