feat(balance): priced-kind support (#140) #149

Merged
maximus merged 4 commits from issue-140-bilan-2 into main 2026-04-26 13:25:21 +00:00
Owner

Closes #140

Stacked on top of #148 (Issue #146). Base branch: issue-146-bilan-1b. Once #147 + #148 are merged, this PR will need its base retargeted to main.

Summary

  • Adds priced-kind validation to balance.service.ts (kind invariants + value-match tolerance ε ≤ 0.01)
  • AccountForm category mode now accepts kind = simple | priced selector
  • SnapshotLineRow priced variant: quantity + unit_price inputs, read-only computed value, [Manuel] attribution tag
  • Improved category deletion UX:
    • is_seed = 1 → button disabled with tooltip
    • Has linked accounts → error message lists count + names of accounts to archive first
  • i18n FR/EN under balance.category.kind.* and balance.snapshot.priced.*
  • CHANGELOG entries (FR + EN) under [Unreleased]

Test plan

  • cargo check
  • npm run build
  • npm test (priced validation: kind invariants, value match, ε tolerance)
  • Manual verification — pending human

Generated autonomously by /autopilot run of 2026-04-25

Closes #140 > Stacked on top of #148 (Issue #146). Base branch: `issue-146-bilan-1b`. Once #147 + #148 are merged, this PR will need its base retargeted to `main`. ## Summary - Adds priced-kind validation to `balance.service.ts` (kind invariants + value-match tolerance ε ≤ 0.01) - `AccountForm` category mode now accepts `kind = simple | priced` selector - `SnapshotLineRow` priced variant: quantity + unit_price inputs, read-only computed value, `[Manuel]` attribution tag - Improved category deletion UX: - `is_seed = 1` → button disabled with tooltip - Has linked accounts → error message lists count + names of accounts to archive first - i18n FR/EN under `balance.category.kind.*` and `balance.snapshot.priced.*` - CHANGELOG entries (FR + EN) under [Unreleased] ## Test plan - [x] cargo check - [x] npm run build - [x] npm test (priced validation: kind invariants, value match, ε tolerance) - [ ] Manual verification — pending human Generated autonomously by /autopilot run of 2026-04-25
maximus added 4 commits 2026-04-25 19:03:02 +00:00
- Export validateLineKindInvariants helper for both 'simple' and 'priced'
  account kinds; surfaces typed BalanceServiceError codes.
- Extend SnapshotLineInput with optional account_kind / quantity /
  unit_price (default 'simple' to preserve #146 callers).
- upsertSnapshotLines now validates kind invariants ahead of the SQL
  CHECK and persists priced lines with non-NULL qty / unit_price.
- Tolerance constant PRICED_VALUE_TOLERANCE = 0.01 absorbs FP drift.
- 14 new unit tests covering simple invariants, priced invariants,
  tolerance edge cases, and mixed batches.

Refs #140

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- AccountForm now exposes a 'category' variant with a kind selector
  (simple | priced); the legacy 'account' variant is unchanged
  modulo the new symbol-required-for-priced UI guard.
- SnapshotLineRow dispatches on account.category_kind:
  * simple variant unchanged from #146
  * priced variant: quantity + unit_price inputs + read-only
    computed value rendered live (qty × price, 2 decimals) +
    [Manuel] attribution tag
- useSnapshotEditor extends state with pricedValues map, exposes
  setLineQuantity / setLineUnitPrice handlers, prefill copies
  quantity but leaves unit_price blank (per spec-decisions row),
  save() builds mixed simple+priced batches.
- SnapshotEditor + SnapshotEditPage thread the new priced state.
- Total line at the top of SnapshotEditPage now sums simple + priced
  contributions live as the user types.

Refs #140

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- AccountsPage Categories tab now uses the new AccountForm 'category'
  variant for creation (with kind selector).
- Delete button is disabled when the category has linked accounts;
  the disabled tooltip surfaces the count.
- Clicking the delete button on a category with linked accounts now
  shows a dismissable error banner listing up to the first 3 names
  (with ellipsis when more) so the user knows exactly which accounts
  to archive first. The service-level FK RESTRICT remains the
  ultimate guard.

Refs #140

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(balance): i18n + CHANGELOG for priced kind
All checks were successful
PR Check / rust (push) Successful in 22m31s
PR Check / frontend (push) Successful in 2m21s
80c0a97841
- Adds keys under balance.category.kind, balance.category.form.kindLabel
  / kindHint*, balance.category.actions.deleteHasAccountsHint,
  balance.category.error.has_accounts, balance.account.form
  .symbolRequiredForPriced, balance.snapshot.priced.* (FR + EN).
- Extends balance.errors.* with the four new typed codes:
  snapshot_priced_quantity_required,
  snapshot_priced_unit_price_required,
  snapshot_priced_value_mismatch,
  snapshot_simple_must_be_scalar.
- CHANGELOG entries (FR + EN) under [Unreleased].

Refs #140

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
maximus added the
autopilot:pending-human
status:approved
labels 2026-04-25 19:03:10 +00:00
maximus changed target branch from issue-146-bilan-1b to main 2026-04-26 13:25:16 +00:00
maximus merged commit 6341aeb74c into main 2026-04-26 13:25:21 +00:00
maximus deleted branch issue-140-bilan-2 2026-04-26 13:25:22 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: maximus/Simpl-Resultat#149
No description provided.