Skip to content

A local-first personal finance app

fix: crash on filtering by amount (#5608)

Michael Süssemilch48ae371ecc1f
diff --git a/packages/loot-core/src/shared/rules.ts b/packages/loot-core/src/shared/rules.ts
index 4317b91a7b..cac2e07743 100644
--- a/packages/loot-core/src/shared/rules.ts
+++ b/packages/loot-core/src/shared/rules.ts
@@ -340,7 +340,18 @@ export function unparse({ error, inputKey, ...item }) {
case 'number': {
let unparsed = item.value;
if (item.field === 'amount' && item.op !== 'isbetween') {
- unparsed = amountToInteger(unparsed);
+ // Handle both string (formatted) and number inputs
+ if (typeof unparsed === 'string') {
+ // Convert formatted string back to number first
+ unparsed = currencyToAmount(unparsed);
+ if (unparsed !== null && !isNaN(unparsed)) {
+ unparsed = amountToInteger(unparsed);
+ } else {
+ unparsed = null;
+ }
+ } else {
+ unparsed = amountToInteger(unparsed);
+ }
}
return { ...item, value: unparsed };
diff --git a/upcoming-release-notes/5608.md b/upcoming-release-notes/5608.md
new file mode 100644
index 0000000000..fba273d162
--- /dev/null
+++ b/upcoming-release-notes/5608.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [misu-dev]
+---
+
+Fixes a crash when filtering by amount