Skip to content

Commit 275aa0c

Browse files
committed
feat: check for expenseType in autoCat
1 parent ec2c235 commit 275aa0c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/commands/_base.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,23 @@ export abstract class ImportBaseCommand<T extends typeof Command> extends Comman
6161
this.args = args as Args<T>;
6262
this.conf = getConfiguration();
6363

64-
if (
65-
!this.conf.wantNeedTracking &&
66-
isObjectWithKeys(this.conf.expenseTypeMapping)
67-
) {
68-
throw new Error("Found expenseTypeMapping when wantNeedTracking is off.");
64+
// TODO: This should be in ../utils/config.js but errors aren't thrown properly
65+
if (!this.conf.wantNeedTracking) {
66+
if (isObjectWithKeys(this.conf.expenseTypeMapping)) {
67+
throw new Error("Found expenseTypeMapping when wantNeedTracking is off.");
68+
}
69+
70+
const hasExpenseType = (this.conf.autoCategorization || [])
71+
.map((el, index) => {
72+
return el.categorization.expenseType ? index : null;
73+
})
74+
.filter((el) => typeof el === "number");
75+
76+
if (hasExpenseType.length) {
77+
throw new Error(
78+
"Found expenseTypein autoCategorization when wantNeedTracking is off."
79+
);
80+
}
6981
}
7082
}
7183

0 commit comments

Comments
 (0)