Skip to content

feat(accounts): debt-detail, statement-closing-day, availableCredit (v0.5.0)#5

Merged
StevenACZ merged 1 commit intomainfrom
feat/debt-detail
Apr 20, 2026
Merged

feat(accounts): debt-detail, statement-closing-day, availableCredit (v0.5.0)#5
StevenACZ merged 1 commit intomainfrom
feat/debt-detail

Conversation

@StevenACZ
Copy link
Copy Markdown
Owner

Summary

  • lucas accounts debt-detail <id> — pass-through over GET /api/accounts/:id/credit-debt-breakdown with AI-friendly defaults (--mode=current_cycle --limit=100).
  • lucas accounts create --statement-closing-day <n> — parity with accounts update. Emits account.creationWarning from the backend when CREDIT is created without it.
  • lucas accounts list now returns availableCredit for CREDIT accounts with a non-null creditLimit.

Bumps to v0.5.0. Changelog updated.

Why

Kimi (AI agent) was approximating current credit-card debt with a 7/14/21/31-day search loop, which inflated reported debt with already-settled prior-cycle charges. The backend already has the precise cycle math (accounts.credit-debt-breakdown), it was only missing a CLI surface. This PR exposes it.

Test plan

  • Unit tests: 22/22 pass (bun run test)
  • bun run format, bun run typecheck, bun run lint, bun run build — all green
  • E2E smoke scenarios 2-6, 8 validated against local backend (see docs/DEBT_DETAIL_SMOKE.md):
    • S2 (40 expenses, 0 payments): charges=400, payments=0, currentDebt=400
    • S3 (40 expenses, $20 payment): charges=400, payments=20, net=380
    • S4 (carry-over): invariant currentDebt == composedDebt + outsideRangeDebt holds
    • S5 (no closing day): creationWarning present; default mode errors with Spanish message; --mode custom succeeds
    • S6 (DEBIT): rejected with "Solo disponible para cuentas de crédito"
    • S8 (availableCredit): all CREDIT accounts with creditLimit have the field; others omit it
  • Scenario 7 (archived CREDIT): breakdown endpoint does NOT filter archived — documented contract in smoke doc
  • Cross-repo: lucasapp-front bun run build and LucasApp xcodebuild both green
  • Scenario 1 (real production data) — manual, runs once this ships to npm

Backend dependency

Requires lucasapp-backend#19 (merged & deployed 2026-04-20). The creationWarning field only surfaces when the backend is on the new version; other features work against any backend.

🤖 Generated with Claude Code

…availableCredit

Three AI-facing additions for credit-card debt reporting:

- `accounts debt-detail <id>` wraps the existing backend breakdown
  endpoint with pro-AI defaults (`--mode=current_cycle --limit=100`)
  plus passthrough flags for `--anchor-date`, `--start-date`,
  `--end-date`, `--search`, `--only-pending`, pagination.
- `accounts create --statement-closing-day <n>` reaches parity with
  `accounts update`. Lets AI create CREDIT cards with the cycle data
  needed for `debt-detail` to work without falling back to the 30-day
  synthetic window. The backend returns `creationWarning` on the
  account when the flag is omitted on a CREDIT type.
- `accounts list` now derives `availableCredit = max(0, creditLimit -
  currentDebt)` client-side for CREDIT accounts with a non-null
  `creditLimit`. Omitted for other account types.

Adds `DEBT_DETAIL_SMOKE.md` with 6 automated E2E scenarios and 2
manual checks (real-data validation + archived-account behavior).

.gitignore picks up `*.dump`/`*.sql`/`dev-fixtures/` so no
production data can slip into this public repo.

Bumps to 0.5.0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@StevenACZ StevenACZ merged commit 383dd13 into main Apr 20, 2026
2 checks passed
@StevenACZ StevenACZ deleted the feat/debt-detail branch April 20, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant