Skip to content

feat(finance): per-flat statement of account (#96)#100

Merged
ankitsejwal merged 2 commits into
mainfrom
feat/m3.5-statement
Jul 16, 2026
Merged

feat(finance): per-flat statement of account (#96)#100
ankitsejwal merged 2 commits into
mainfrom
feat/m3.5-statement

Conversation

@ankitsejwal

Copy link
Copy Markdown
Member

M3.5 · Task #96 — Per-flat statement (backend)

Transaction-level running balance per flat (today there's only an aggregate dues row). Needed before the Balance Sheet (member dues = an asset) and expected by residents + auditors.

Domain (shared, unit-tested)

buildStatement(rows, opening) — merges charges (bills + interest → debits) and payments (credits) into a dated running balance. Debit-positive (what the flat owes); closing = opening + Σdebit − Σcredit, which reconciles to outstanding dues.

API

GET /apartments/:id/statement?from=&to= — ordered entries {date, type, description, debit, credit, balance, ref} + opening/closing/totals. Role-scoped (residents only their own flats, ADMIN any), excludes CANCELLED bills, tags auto-generated interest bills as INTEREST (shared INTEREST_BILL_TITLE_PREFIX, now reused by bills.ts).

Acceptance

  • ✅ Dated statement with running balance that reconciles to outstanding dues.
  • ✅ Opening + closing correct for an arbitrary date range (opening carries in everything before from).
  • ✅ Interest/adjustments represented as distinct entry types.

Tests / notes

buildStatement (running balance, opening carry-in, out-of-order sort, empty-safe) + statement route tests (401/403 scoping, admin running balance). Suite 340 green. Web (billing statement view) + mobile (bills.tsx) read-only statement land in the M3.5 admin-UI pass.

A dated, running-balance ledger per apartment — the "My Statement" every
benchmark app has and auditors expect.

- buildStatement (shared): merges charges (bills + interest = debits) and
  payments (credits) into a chronological running balance. Debit-positive
  (what the flat owes); closing = opening + Σdebit − Σcredit, reconciling to
  outstanding dues. Opening carries in everything before the window.
- API GET /apartments/:id/statement?from=&to= — role-scoped (residents only
  their flats, ADMIN any), excludes CANCELLED bills, tags auto interest bills
  as INTEREST via the shared title prefix.
- Shared INTEREST_BILL_TITLE_PREFIX constant (bills.ts now reuses it).
- Tests: buildStatement (running balance, opening, sort, empty) + statement
  route (401/403 scoping, admin running balance). Suite 340 green.

Web (billing statement view) + mobile (bills.tsx) UI land in the consolidated
M3.5 admin-UI pass.
@ankitsejwal
ankitsejwal merged commit d82e4b3 into main Jul 16, 2026
1 check passed
@ankitsejwal
ankitsejwal deleted the feat/m3.5-statement branch July 16, 2026 11:23
ankitsejwal added a commit that referenced this pull request Jul 16, 2026
Backend for the admin finance dashboard (tiles + charts land in the M3.5
admin-UI pass).

- shared: agingBucketFor + bucketAging (0-30 / 31-60 / 61-90 / 90+ days past
  due; not-yet-due counts current, cleared balances skipped) + AGING_BUCKETS.
- API GET /reports/aging?asOf= — buckets outstanding per-bill dues, total and
  per flat (sorted by exposure), for the defaulter report.
- /reports/finance now also returns cashBankBalance (ledger 10xx accounts) for
  the dashboard tile; FinanceReport type + the finance-shape test updated.
- Tests: aging bucket boundaries + summation + not-yet-due/cleared handling;
  /aging route (auth + a two-flat bucketing case). Suite 366 green; web
  typechecks.
ankitsejwal added a commit that referenced this pull request Jul 16, 2026
Surfaces the M3.5 accounting backend in the admin app (extends existing pages —
no new routes).

- admin/index.tsx: finance tiles — outstanding dues, collection rate, cash+bank.
- admin/reports.tsx: statutory statements (Balance Sheet, I&E with mutual/
  taxable split, Receipts & Payments, Trial Balance with balanced badges) each
  with PDF/Excel/CSV export buttons + a Tally XML export; and an aging section
  (0-30/31-60/61-90/90+ buckets + per-flat breakdown).
- api.ts: getTrialBalance/getIncomeExpenditure/getBalanceSheet/
  getReceiptsPayments/getAging + reportExportObjectUrl (auth-fetch downloads).
- i18n: ~33 new keys (en + hi, parity test green).
- Validated: web check-types, vite build, lint (0 errors), web tests 27 green.
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