Skip to content

feat(finance): XLSX + CSV + Tally exports (#99 pt.1)#102

Merged
ankitsejwal merged 1 commit into
mainfrom
feat/m3.5-exports
Jul 16, 2026
Merged

feat(finance): XLSX + CSV + Tally exports (#99 pt.1)#102
ankitsejwal merged 1 commit into
mainfrom
feat/m3.5-exports

Conversation

@ankitsejwal

Copy link
Copy Markdown
Member

M3.5 · Task #99 (part 1) — XLSX / CSV / Tally exports

The most-demanded treasurer feature — financial reports a CA can consume. Dependency-free and Cloudflare-Workers-safe (no lockfile change).

Worker-safe XLSX writer (lib/xlsx.ts)

exceljs/SheetJS assume Node APIs, so I wrote a small from-scratch .xlsx writer: real OOXML SpreadsheetML zipped with STORED (uncompressed) entries + a hand-rolled CRC32 — no zip/deflate dependency. Validated locally with unzip -t (CRC OK, no errors) and structurally (all 6 OOXML parts).

Export layer (shared/export.ts, pure + tested)

  • report → table (rows, in rupees) for Trial Balance, I&E, Balance Sheet, R&P, and dues
  • CSV serializer (RFC-escaping)
  • Tally-import XML builder: ledger masters + vouchers, debit negative / credit positive (Tally convention)

API

  • ?format=xlsx|csv on /reports/{trial-balance,income-expenditure,balance-sheet,receipts-payments} and /bills/dues
  • GET /reports/tally-export → Tally XML (PAYMENT→Receipt, EXPENSE→Payment, else Journal), importable into TallyPrime

Acceptance

  • ✅ Every financial report downloads as .xlsx (CRC-verified valid zip / OOXML) — recommend a real-Excel smoke test on deploy; pip/openpyxl is locked down in this sandbox.
  • ✅ Tally XML for receipt + payment + journal vouchers.
  • ⏳ Print-ready statement PDFs + the invoice ₹-glyph fix → next export PR (feat(finance): penalties & interest on arrears (#95) #99 pt.2).

Tests

xlsx zip structure + inline-string/number/escaping; CSV escaping; Tally envelope/signing/masters; table shaping. Suite 359 green. No schema change.

The most-demanded treasurer feature: financial reports the society's CA can
consume. Dependency-free and Cloudflare-Workers-safe.

- lib/xlsx.ts: a from-scratch .xlsx writer — real OOXML SpreadsheetML zipped
  with STORED entries + a hand-rolled CRC32, so no Node-only zip/xlsx lib is
  needed on Workers. Validated with `unzip -t` (CRC OK) and openpyxl-shaped
  structure.
- shared/export.ts (pure): report -> table (rows in rupees) for trial balance,
  I&E, balance sheet, R&P, and dues; a CSV serializer; and a Tally-import XML
  builder (ledger masters + vouchers, debit negative / credit positive).
- API: ?format=xlsx|csv on /reports/{trial-balance,income-expenditure,
  balance-sheet,receipts-payments} and /bills/dues; GET /reports/tally-export
  streams Tally XML (PAYMENT->Receipt, EXPENSE->Payment, else Journal).
- Tests: xlsx zip structure + inline-string/number/escaping, CSV escaping,
  Tally envelope/signing/masters, table shaping. Suite 359 green.

Print-ready statement PDFs + the invoice ₹-glyph fix are the next export PR.
@ankitsejwal
ankitsejwal merged commit e867f41 into main Jul 16, 2026
1 check passed
@ankitsejwal
ankitsejwal deleted the feat/m3.5-exports branch July 16, 2026 13:40
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