Skip to content

Wallet: exportable CSV statements (activity + per-child) - #220

Merged
NewWorldVenture merged 2 commits into
mainfrom
claude/wallet-statement-export
Jul 4, 2026
Merged

NewWorldVenture merged 2 commits into
mainfrom
claude/wallet-statement-export

Conversation

@NewWorldVenture

Copy link
Copy Markdown
Owner

Summary

Working todo.md #2 — Wallet, full family financial OS. An audit first confirmed the wallet is already deeply wired end-to-end:

  • Allowance cron (app/api/cron/wallet-allowance) credits the immutable ledger via creditChildWallet and advances next_run_on.
  • The AI money coach (/api/ai/wallet) computes balances from the ledger.
  • Reconciliation is surfaced at /admin/wallet/reconciliation.
  • The only honest "coming soon" left is Stripe-Issuing spending cards — legitimate future infra, kept honest until keys land.

The real missing capability for a "financial OS" is an exportable statement. Added it:

Changes

  • lib/wallet/activity.ts — new pure toStatementCsv(txns):
    • RFC-4180 field escaping (commas, quotes, newlines).
    • Running-balance column computed oldest→newest over completed rows only, so the newest row reflects the current total; pending/held rows don't move the balance.
    • Columns: Date, Time, Type, Description, Child, Direction, Amount, Status, Balance.
    • Plus statementFilename(now) → bubaly-wallet-statement-YYYY-MM-DD.csv.
  • components/wallet/activity-view.tsx — a Statement download button that exports exactly what's in view (respects the active child / type / direction filters; disabled when empty). Client-side Blob download — no server round-trip, no external deps.
  • components/wallet/child-detail-view.tsx — a per-child Statement button in the Activity header, exporting that child's history with their name.

Tests

tests/wallet-activity.test.ts +6 (now 10): header/row shape, oldest→newest running balance, pending excluded from balance, RFC-4180 escaping, filename stamp.

Verification

  • tsc --noEmit clean
  • eslint clean on changed files
  • vitest — 1536 tests pass (+5)
  • next build — exit 0

Remaining wallet gaps noted in the handoff for follow-up: Stripe Issuing (blocked on keys), a parent "run allowance now"/catch-up trigger (cron-only today), and a statement date-range picker.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VJs1Px4GTVtA1jmzDZ4ShU


Generated by Claude Code

@vercel

vercel Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
familyos Ready Ready Preview, Comment Jul 4, 2026 4:36pm

Request Review

claude added 2 commits July 4, 2026 16:30
Working todo.md #2 (Wallet — full family financial OS). The wallet is already
deeply wired (allowance cron credits the immutable ledger, AI coach reads real
balances, reconcile is surfaced in admin); the only honest "coming soon" left
is Stripe-Issuing cards. The real missing capability for a financial OS is an
exportable statement — added it.

- lib/wallet/activity.ts: pure toStatementCsv (RFC-4180 escaping; running
  balance computed oldest->newest over completed rows so the newest row shows
  the current total) + statementFilename. +6 tests (wallet-activity now 10).
- activity-view.tsx: "Statement" download button respecting the active
  child/type/direction filters (disabled when empty); client-side Blob, no
  server round-trip.
- child-detail-view.tsx: per-child "Statement" button in the Activity header.

Verified: tsc clean, eslint clean, 1536 tests pass (+5), next build exit 0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VJs1Px4GTVtA1jmzDZ4ShU
seed_wallet_ledger_one_family.sql + db:seed:wallet-ledger script. Seeds 500
public.wallet_transactions (the 0088 child allowance ledger the /wallet/activity
page and the new CSV statement export read) for the target family: ensures the
family wallet + a child_wallet with Spend/Save/Give/Invest buckets for each
non-manager member, then 500 transactions across 8 types, both directions, 4
statuses, and ~180 days. RLS-repair preamble, metadata->>'seed'='wallet_ledger'
idempotent tagging (delete-before-insert), verification SELECT.

Validated on throwaway PG16: 500 rows, idempotent on re-run (still 500), every
row has a resolved bucket, parent correctly excluded from child wallets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VJs1Px4GTVtA1jmzDZ4ShU
@NewWorldVenture
NewWorldVenture force-pushed the claude/wallet-statement-export branch from b7f53b5 to 71b4d6e Compare July 4, 2026 16:34
@NewWorldVenture
NewWorldVenture marked this pull request as ready for review July 4, 2026 16:55
@NewWorldVenture
NewWorldVenture merged commit 1cd160b into main Jul 4, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 71b4d6ed Deployed Jul 4, 2026 by vercel[bot]
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.

2 participants