Skip to content

CSV export shows raw cents instead of a formatted amount (#27) - #32

Closed
Param-Harrison wants to merge 3 commits into
mainfrom
factory/issue-27
Closed

Param-Harrison wants to merge 3 commits into
mainfrom
factory/issue-27

Conversation

@Param-Harrison

Copy link
Copy Markdown
Contributor

Closes #27

Summary

The CSV export's amount column printed raw integer cents (4500) instead of a decimal amount (45.00). exportCsv in src/csv.ts now formats that column with formatCents, following the handling-money rule to format only at the output edge. The fix also applies to the CLI export command and to GET /api/groups/:id/export.csv, because both call exportCsv.

Acceptance criteria

AC Evidence (command / test) Result
AC-1 bun test tests/csv.test.ts: exportCsv > formats the amount column as a decimal via formatCents gives 45.00, 12.00, 30.00 pass
AC-2 bun test tests/csv.test.ts: exportCsv > keeps the header row and one line per expense pass
AC-3 With src/csv.ts reverted to main, bun test tests/csv.test.ts fails (received ["1200","3000","4500"]) pass
AC-4 bun test tests/cli.test.ts tests/routes.test.ts: both export tests fail when the fix is reverted and pass with it (17 pass, 0 fail across csv/cli/routes) pass
AC-5 make check: tsc --noEmit clean, bun test 29 pass / 0 fail, all 9 skills valid pass

Non-goals respected

  • NG-1: nothing under src/money/** changed. formatCents is reused as-is.
  • NG-2: the CSV header, the column order and csvEscape are unchanged. Only how the amount field is written changed.
  • NG-3: the JSON API (amountCents is still integer cents) and public/index.html are untouched.
  • NG-4: src/routes/export.ts and src/cli.ts are untouched. The fix is only in src/csv.ts.
  • NG-5: no protected paths were edited and there is no schema or DB change.

The test that bites

  • Test: tests/csv.test.ts › exportCsv > formats the amount column as a decimal via formatCents
  • Fails on main: git checkout main -- src/csv.ts, then bun test tests/csv.test.ts gives 1 pass, 1 fail (received "1200","3000","4500", expected "12.00","30.00","45.00")
  • Passes here: bun test tests/csv.test.ts gives 2 pass, 0 fail

Gate line

FACTORY_GATES: status=GREEN passed=3 failed=0 skipped=1 failed_gates=audit

(audit was skipped. make audit is not part of make check.)

Protected paths touched

none

Reviewer findings addressed

none (the full evidence is in the factory verdict comment on #27)

Human checklist

  • AC table has real evidence, not placeholders
  • Non-goals respected
  • Gate line is GREEN
  • Protected paths are "none", or the change to them is expected and reviewed
  • I ran the test that bites myself

🤖 Generated with Claude Code

@Param-Harrison
Param-Harrison marked this pull request as ready for review September 23, 2026 19:02
@Param-Harrison

Copy link
Copy Markdown
Contributor Author

/factory revise Add a test where the amount has a trailing zero cent, e.g. 45.50, so we know the column is not truncated.

@Param-Harrison
Param-Harrison marked this pull request as draft September 23, 2026 19:04
@Param-Harrison
Param-Harrison marked this pull request as ready for review September 23, 2026 19:08
@Param-Harrison
Param-Harrison deleted the factory/issue-27 branch September 23, 2026 19:28
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.

CSV export shows raw cents instead of a formatted amount

1 participant