Repository navigation
feat: payments as an Excel file, beside the CSV (#298) - #319
Merged
Merged
Conversation
A comma CSV opens in one column in Excel on a comma-decimal locale
(Indonesian Excel splits on ';'), and no single CSV separator fits every
locale: with ';' the amounts would also need comma decimals, which breaks
English-locale Excel. An .xlsx has typed cells, so it opens right
everywhere.
GET /v1/minds/{id}/payments.xlsx returns the same rows as the CSV (now
built once in paymentRows; the CSV output is unchanged). src/xlsx.ts is a
small writer with no new dependency: a stored zip with zlib.crc32, dates as
UTC date serials, amounts as numbers, the explorer link as a hyperlink, text
as inline strings (never formulas), bold frozen header with a filter.
Tests (local, ct-dev-env): typecheck OK; bun run test 157 pass, 0 fail,
1 skipped (the existing skip); the new Excel test unzips the response,
checks every CRC and the typed cells, and that it is owner only; the CSV
test passes unchanged. bun run load:shop: xlsx 220 requests p95 277 ms,
csv p95 281 ms, 0 errors; bun run load: 0 errors. A generated workbook
also read correctly with ExcelJS 4.4.0 and SheetJS 0.18.5 (date, number,
hyperlink, bold frozen header, filter; "=1+1" stays text).
Wallet's Recent activity gets an "Excel" button next to "Download CSV",
fetching GET /v1/minds/{id}/payments.xlsx the same way (with the session
cookie, saved as a blob named from Content-Disposition). Excel on an
Indonesian locale opens it in columns, which it doesn't do with the CSV.
Tests (local, ct-dev-env, fresh bun install): lint OK, typecheck OK,
vitest 280/280.
Adds GET /v1/minds/{mindId}/payments.xlsx to docs/openapi.json next to
payments.csv, so it shows in the Endpoints tab on docs.hellonear.xyz
(Axel's ask on #298), and to the API table and the Payments CSV page.
Only the new path is added to the spec; the rest of the file is byte for
byte the same.
Checks (local): mint@4.2.1184 openapi-check docs/openapi.json "OpenAPI
definition is valid"; mint validate exit 0; mint broken-links
--check-anchors "no broken links found". BE typecheck OK, bun run test
157 pass, 0 fail, 1 skipped (existing).
Contributor
|
@Lin1er Merged into main (9323c25) with Axel's approval; it follows the usual deploy after merge. @AncungAulia once it is on the demo, please open the Excel file from Wallet ▸ Recent activity on your Indonesian-locale Excel and report on #298 whether the columns split. |
Contributor
Author
|
Live on the hosted demo:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@Lexirieru for review. Fixes the Excel note on #298 (Axel's go-ahead: #298 (comment)).
Why
A comma CSV opens in one column in Excel on a locale whose list separator is
;, like Indonesian (Ancung's test on #298). No single CSV separator fits every locale: with;the amounts would also need comma decimals, which breaks English-locale Excel, andsep=,adds a junk first row in Google Sheets and LibreOffice. An.xlsxhas typed cells, so it opens in columns everywhere. The CSV stays exactly as it is.What changed
GET /v1/minds/{mindId}/payments.xlsx(owner only, like the CSV).paymentRows, and the CSV output is unchanged.src/xlsx.tsis a small writer with no new dependency: a stored zip usingzlib.crc32.Content-Disposition.docs/openapi.json, next topayments.csv, so it shows in the Endpoints tab;apps/docs/api.mdxand a note on the Payments CSV page;docs/api-contract.md,apps/be/CLAUDE.mdandapps/fe/CLAUDE.md.Tests (local, ct-dev-env)
bun run test: 157 pass, 0 fail, 1 skipped (an existing skip).=1+1 <tag> & "q", and that the file is owner only (404 for another owner, 401 without a session).bun run load:shop: xlsx 220 requests, p95 277 ms; csv p95 281 ms; 0 errors.bun run load: 0 errors.bun install): lint OK, typecheck OK, vitest 280/280.mint@4.2.1184 validateOK,openapi-check docs/openapi.jsonvalid,broken-links --check-anchorsnone.=1+1stays text.Not checked