whisper-money/resources/js/types
Víctor Falcón 66ff427481
feat(import): calculate balances from transactions (#403)
## Why

Some banks return transactions without a balance column. The CSV/Excel
importer happily creates the transactions but leaves the account without
any balance history, making the account look incomplete.

## What

Opt-in flow that derives per-day balances from the transactions
themselves, using a single reference point (the balance on the date of
the latest transaction).

### Mapping step
- New checkbox **"Calculate balances from transactions"** next to the
  Balance column select.
- Available only when no balance column is mapped (disabled + visually
  faded otherwise).
- When checked, a balance input appears labeled with the latest
  transaction date using a relative format:
  - `Today`
  - `Yesterday`
  - `Monday, 3 of Jun`
- If an `AccountBalance` already exists for that date, it is pre-filled
  automatically (no need to ask) with a small hint.
- The reference balance is **mandatory** when the checkbox is checked;
  the Next button is disabled until it is provided.

### Preview step
- A new `Balance` column shows the balance about to be created for each
  date, regardless of whether it came from the file or was calculated.

### Persistence
- Balances are computed by walking backwards across distinct transaction
  dates and subtracting each day's net movement.
- They flow through the existing import path that POSTs to
  `AccountBalanceController@store`, so no new endpoint was needed.

## Feature flag

Hidden behind a new Pennant feature, **off by default**:

```bash
php artisan feature:enable CalculateBalancesOnImport user@example.com
# or
php artisan feature:enable CalculateBalancesOnImport all
```

The flag is exposed to the frontend via Inertia shared props
(`features.calculateBalancesOnImport`).

## Tests

- New vitest cases for `getLatestTransactionDate` and
  `calculateBalancesFromTransactions` (sparse dates, reference date
  without txns, empty list).
- `LocalizationTest` passes (new ES strings added).
- Full vitest suite green (106 tests).
2026-05-20 10:29:14 +01:00
..
account.ts feat(settings): centralize currency options and split profile/account support (#256) 2026-04-02 19:23:10 +02:00
automation-rule.ts feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
balance-import.ts feat: investment benefits — show gains/losses on investment accounts (#140) 2026-02-23 13:59:10 +01:00
banking.ts feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
budget.ts Add yearly budget period (#384) 2026-05-12 13:35:25 +02:00
category.test.ts Fix Spanish translations in category and delete flows (#397) 2026-05-14 11:36:53 +01:00
category.ts Fix Spanish translations in category and delete flows (#397) 2026-05-14 11:36:53 +01:00
import.ts feat(import): calculate balances from transactions (#403) 2026-05-20 10:29:14 +01:00
index.d.ts feat(import): calculate balances from transactions (#403) 2026-05-20 10:29:14 +01:00
label.ts feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
language.ts feat: Spanish localization (#74) 2026-02-08 11:58:08 +01:00
pricing.ts feat(pricing): dynamic Stripe pricing with locale-aware formatting (#204) 2026-03-05 11:41:59 +00:00
transaction.ts Move transaction filtering from client-side to server-side (#126) 2026-02-16 12:49:04 +01:00
uuid.ts Fix CI: Update bun.lock and fix linting errors 2025-12-01 15:16:06 +01:00
vite-env.d.ts Init browser Sentry from env DSN (#370) 2026-05-09 12:07:11 +02:00