Skip to content

A local-first personal finance app

:bug: fix category is nothing rule crashing spending report widget (#4360)

Matiss Janis Aboltins524707ceccb1
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
index b498ce6f69..49fb03b877 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
@@ -52,6 +52,7 @@ export function createSpendingSpreadsheet({
conditions: conditions.filter(
cond => !cond.customName && cond.field === 'category',
),
+ applySpecialCases: false,
},
);
diff --git a/packages/loot-core/src/server/accounts/transaction-rules.ts b/packages/loot-core/src/server/accounts/transaction-rules.ts
index 9d4baf72d6..4e644f5952 100644
--- a/packages/loot-core/src/server/accounts/transaction-rules.ts
+++ b/packages/loot-core/src/server/accounts/transaction-rules.ts
@@ -337,7 +337,10 @@ function conditionSpecialCases(cond: Condition | null): Condition | null {
}
// This does the inverse: finds all the transactions matching a rule
-export function conditionsToAQL(conditions, { recurDateBounds = 100 } = {}) {
+export function conditionsToAQL(
+ conditions,
+ { recurDateBounds = 100, applySpecialCases = true } = {},
+) {
const errors = [];
conditions = conditions
@@ -354,7 +357,7 @@ export function conditionsToAQL(conditions, { recurDateBounds = 100 } = {}) {
return null;
}
})
- .map(conditionSpecialCases)
+ .map(cond => (applySpecialCases ? conditionSpecialCases(cond) : cond))
.filter(Boolean);
// rule -> actualql
diff --git a/packages/loot-core/src/server/main.ts b/packages/loot-core/src/server/main.ts
index 8d8044b297..fa1e4bf8e3 100644
--- a/packages/loot-core/src/server/main.ts
+++ b/packages/loot-core/src/server/main.ts
@@ -515,8 +515,11 @@ handlers['payees-get-rules'] = async function ({ id }) {
return rules.getRulesForPayee(id).map(rule => rule.serialize());
};
-handlers['make-filters-from-conditions'] = async function ({ conditions }) {
- return rules.conditionsToAQL(conditions);
+handlers['make-filters-from-conditions'] = async function ({
+ conditions,
+ applySpecialCases,
+}) {
+ return rules.conditionsToAQL(conditions, { applySpecialCases });
};
handlers['getCell'] = async function ({ sheetName, name }) {
diff --git a/packages/loot-core/src/types/server-handlers.d.ts b/packages/loot-core/src/types/server-handlers.d.ts
index 8facdf8f03..7cc0ebb3c5 100644
--- a/packages/loot-core/src/types/server-handlers.d.ts
+++ b/packages/loot-core/src/types/server-handlers.d.ts
@@ -127,6 +127,7 @@ export interface ServerHandlers {
'make-filters-from-conditions': (arg: {
conditions: unknown;
+ applySpecialCases?: boolean;
}) => Promise<{ filters: unknown[] }>;
getCell: (arg: {
diff --git a/upcoming-release-notes/4360.md b/upcoming-release-notes/4360.md
new file mode 100644
index 0000000000..5aeb293ab3
--- /dev/null
+++ b/upcoming-release-notes/4360.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [MatissJanis]
+---
+
+Fix "category is (nothing)" filter crashing the spending analysis report widget.