Skip to content

CSV export shows raw cents instead of a formatted amount (#186) - #187

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

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

Conversation

@Param-Harrison

Copy link
Copy Markdown
Contributor

Summary

exportCsv (shared by the CSV route and splitbill export) now prints the amount column as a 2-decimal string via formatCents instead of raw integer cents, so 1000 reads 10.00.

Closes #186

Plan

Plan comment (rev 1):

  • AC-1: amounts render via formatCents (4500 -> 45.00), verified by bun test tests/csv.test.ts ("exportCsv formats the amount column as a decimal")
  • AC-2: two digits kept (1005 -> 10.05, 1050 -> 10.50), verified by "exportCsv keeps two decimal places"
  • AC-3: header, row count and other columns unchanged, verified by "exportCsv keeps header and row count" plus the existing tests/routes.test.ts and tests/cli.test.ts export tests
  • AC-4: full gate passes, verified by make check

Left out (non-goals): no change to src/money/**, the CSV header/column order/csvEscape, the DB schema or SQL, src/routes/**, src/cli.ts, or any protected path.

Files changed: src/csv.ts (use formatCents, drop the stale "SEEDED DEFECT" comment) and the new tests/csv.test.ts.

Gate evidence

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

(The audit gate is optional and was skipped, not failed.)

Verify verdict

Verdict: pass, all of AC-1 to AC-4. See the verdict comment on the issue #186 thread. Test that bites: with src/csv.ts reverted, all 3 new tests fail on the amount value (e.g. "1005" received where "10.05" was expected); with the fix they pass (17 pass, 0 fail across the csv, routes and cli tests).

Reviewer notes, not addressed here:

  • could: no test cases for 0, 5 cents, negative or large amounts.
  • Separate issue, already on main: csvEscape does not neutralise a leading =, +, - or @, so the export is open to spreadsheet formula injection. NG-2 forbids changing it here, so it needs its own issue.

Risk and rollback

Low: a change confined to one non-protected module with no schema or API-shape change. Rollback: revert this PR; nothing stored changes, since only how the amount is rendered in the export differs.

Factory run

Stage Agent Duration Tool calls Cost Outcome
triage claude 24s 6 $0.09 ok
plan claude 45s 6 $0.24 ok
build claude 1m 14s 16 $0.35 ok
verify claude 47s 10 $0.32 pass
pr claude 14s 3 $0.09 ok

Proof: the new test fails without the change.

5 stage runs, 3m 23s, $1.08.

Went well

  • triage, plan, build, verify, pr passed on the first attempt
  • verify approved on the first round

Needed help

  • nothing

@Param-Harrison
Param-Harrison marked this pull request as ready for review October 13, 2026 13:33
@Param-Harrison

Copy link
Copy Markdown
Contributor Author

/factory revise add a test for an amount under one dollar, like 5 cents

@Param-Harrison
Param-Harrison marked this pull request as draft October 13, 2026 13:47
@Param-Harrison
Param-Harrison marked this pull request as ready for review October 13, 2026 13:50
@Param-Harrison
Param-Harrison deleted the factory/issue-186 branch October 13, 2026 20:09
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