Skip to content

A local-first personal finance app

Fix currencyToInteger returning null when amount is zero (#915)

Jed Fox131bb86711f4
diff --git a/packages/desktop-client/src/components/accounts/Account.js b/packages/desktop-client/src/components/accounts/Account.js
index 874bb5f824..390fa77648 100644
--- a/packages/desktop-client/src/components/accounts/Account.js
+++ b/packages/desktop-client/src/components/accounts/Account.js
@@ -195,10 +195,15 @@ function ReconcileTooltip({ account, onReconcile, onClose }) {
let balance = useSheetValue(queries.accountBalance(account));
function onSubmit(e) {
+ e.preventDefault();
let input = e.target.elements[0];
let amount = currencyToInteger(input.value);
- onReconcile(amount == null ? balance : amount);
- onClose();
+ if (amount != null) {
+ onReconcile(amount == null ? balance : amount);
+ onClose();
+ } else {
+ input.select();
+ }
}
return (
diff --git a/packages/loot-core/src/shared/util.ts b/packages/loot-core/src/shared/util.ts
index 9506ee207c..b62bf249d7 100644
--- a/packages/loot-core/src/shared/util.ts
+++ b/packages/loot-core/src/shared/util.ts
@@ -354,7 +354,7 @@ export function currencyToAmount(str) {
export function currencyToInteger(str) {
let amount = currencyToAmount(str);
- return amount ? amountToInteger(amount) : null;
+ return amount == null ? null : amountToInteger(amount);
}
export function stringToInteger(str) {
diff --git a/upcoming-release-notes/915.md b/upcoming-release-notes/915.md
new file mode 100644
index 0000000000..e8b2e2abc7
--- /dev/null
+++ b/upcoming-release-notes/915.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [j-f1]
+---
+
+Fix reconciling a budget with a zero value