whisper-money/resources/js/components/accounts
Víctor Falcón ca2e5c09b3
fix(balances): allow saving a zero balance (#664)
## Why

A balance of exactly **0** could not be saved. Zero is a perfectly valid
balance for any account (an emptied wallet, a paid-off loan, a closed
position), so the app was rejecting legitimate input.

## Root cause

The shared `AmountInput` renders a numeric value of `0` as an **empty
string** (so the field shows the `0.00` placeholder instead of a literal
"0.00"). Several balance forms combined that with the native HTML
`required` attribute — which then rejected the *only* value that renders
empty: `0`. `required` on this input never guarded against a missing
value (the state is always numeric; empty == 0), it only ever blocked
zero.

The backend already accepted `0` (`required|integer`, and Laravel's
`required` treats integer `0` as present), so this was purely a frontend
constraint.

## Changes

- Drop `required` from the balance `AmountInput` in the **Update
balance** dialog and the **Balance history** edit modal.
- Remove the explicit `balanceInCents === 0` guard (and `required`) in
the onboarding **Set balance** step.
- Extend the same fix to the CSV-import **reference balance** field
(identical root cause; the compute path already gates on
`referenceBalance !== null`, so an explicit `0` is a valid anchor).
- Remove the now-orphaned `"Please enter a balance"` translation from
`es.json` / `fr.json`.
- Add feature tests asserting a zero balance can be stored and set as
the current balance.

Transaction and budget amount inputs keep `required` — `0` is not a
meaningful value there, so they are intentionally untouched.

## QA

- **Onboarding balance step**: saving with an empty/zero field now
advances instead of showing "Please enter a balance". 
- **Update balance dialog**: set €1,000.00, then overwrote it with €0.00
→ dialog closed and the record persisted. Verified in the DB
(`account_balances.balance = 0`). 
- Backend contract locked by new tests in
`AccountBalanceControllerTest`.

## Demo

<!-- PLACEHOLDER: drag the video here -->

_Video to attach: `~/Downloads/allow-zero-balances-demo.mp4`_
2026-07-10 15:02:38 +02:00
..
import-balances feat(importer): support YYYYMMDD date format (#470) 2026-06-01 16:44:46 +02:00
account-balance-chart.tsx feat(accounts): show projection on real estate chart (#338) 2026-04-27 08:08:12 +01:00
account-form.tsx feat(real-estate): auto-calculate revaluation % and generate historical balances (#253) 2026-04-15 12:18:33 +00:00
account-list-card.tsx feat(accounts): reorder accounts with drag-and-drop (#575) 2026-06-21 11:17:45 +02:00
account-name.tsx fix(dashboard): treat loans as debt in net worth (#238) 2026-03-20 09:55:53 +00:00
balances-modal.tsx fix(balances): allow saving a zero balance (#664) 2026-07-10 15:02:38 +02:00
bank-combobox.tsx feat(settings): centralize currency options and split profile/account support (#256) 2026-04-02 19:23:10 +02:00
create-account-dialog.tsx feat(open-banking): disable already-connected banks in the connect picker (#556) 2026-06-18 15:08:09 +02:00
custom-bank-form.tsx feat: Spanish localization (#74) 2026-02-08 11:58:08 +01:00
delete-account-dialog.tsx fix(ux): improve status badge, hide balance update for connected accounts, localize delete confirm (#159) 2026-02-27 22:37:16 +00:00
edit-account-dialog.test.tsx Move account delete into edit modal (#410) 2026-05-20 16:46:13 +01:00
edit-account-dialog.tsx refactor(js): extract shared getCsrfToken util (#475) 2026-06-03 17:26:09 +02:00
edit-loan-detail-dialog.tsx feat(accounts): merge real estate accounts with linked mortgages in UI (#248) 2026-03-26 20:54:12 +01:00
import-balances-drawer.tsx fix(import): honor selected date format for CSV imports (#494) 2026-06-05 15:10:48 +02:00
update-balance-dialog.tsx fix(balances): allow saving a zero balance (#664) 2026-07-10 15:02:38 +02:00