Skip to content

Commit

Permalink
add the option to turn off item account filtering
Browse files Browse the repository at this point in the history
So that items can be assets
  • Loading branch information
jkroso committed Nov 29, 2023
1 parent 814845f commit 0386b08
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
32 changes: 22 additions & 10 deletions models/baseModels/Item/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {

Check failure on line 61 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_test

Type '(doc: Doc) => { isGroup: false; rootType: AccountRootTypeEnum; } | { isGroup: false; rootType?: undefined; }' is not assignable to type 'FilterFunction'.
if (doc.fyo.singles.AccountingSettings?.itemAccountFiltering) {
return {
isGroup: false,
rootType: AccountRootTypeEnum.Income

Check warning on line 65 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_lint

Insert `,`
}

Check warning on line 66 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_lint

Insert `;`
} else {
return {isGroup: false}

Check warning on line 68 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_lint

Replace `isGroup:·false}` with `·isGroup:·false·};`
}
},
expenseAccount: (doc) => {

Check failure on line 71 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_test

Type '(doc: Doc) => { isGroup: false; rootType: AccountRootTypeEnum; } | { isGroup: false; rootType?: undefined; }' is not assignable to type 'FilterFunction'.
if (doc.fyo.singles.AccountingSettings?.itemAccountFiltering) {
return {
isGroup: false,
rootType: doc.trackItem
? AccountRootTypeEnum.Liability
: AccountRootTypeEnum.Expense

Check warning on line 77 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_lint

Insert `,`
}

Check warning on line 78 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_lint

Insert `;`
} else {
return {isGroup: false}

Check warning on line 80 in models/baseModels/Item/Item.ts

View workflow job for this annotation

GitHub Actions / setup_and_lint

Replace `isGroup:·false}` with `·isGroup:·false·};`
}
},
};

validations: ValidationMap = {
Expand Down
7 changes: 7 additions & 0 deletions schemas/app/AccountingSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0386b08

Please sign in to comment.