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

This commit is contained in:
Matiss Janis Aboltins
2025-02-12 14:54:47 +00:00
committed by GitHub
parent 8351edc8bb
commit 524707cecc
5 changed files with 18 additions and 4 deletions

View File

@@ -52,6 +52,7 @@ export function createSpendingSpreadsheet({
conditions: conditions.filter(
cond => !cond.customName && cond.field === 'category',
),
applySpecialCases: false,
},
);

View File

@@ -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

View File

@@ -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 }) {

View File

@@ -127,6 +127,7 @@ export interface ServerHandlers {
'make-filters-from-conditions': (arg: {
conditions: unknown;
applySpecialCases?: boolean;
}) => Promise<{ filters: unknown[] }>;
getCell: (arg: {

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---
Fix "category is (nothing)" filter crashing the spending analysis report widget.