Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dailyVolume keyed payments by the server's local date while its buckets were UTC days, so payments near midnight moved or vanished depending on TZ. It also accumulated floats in major units. Use utcDayKey and sumMinorUnits, and add regression tests run under America/Los_Angeles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Ticket
Closes NWP-102 (partially — see "Notes for the reviewer")
What changed
The overview's daily volume now puts every payment on its UTC day and totals amounts exactly in integer minor units. Before,
dailyVolumekeyed each payment by the server's local date (toLocaleDateString("en-CA")) while its buckets were UTC days, so payments near midnight moved to the wrong day, or dropped out of the window, depending on the machine's timezone. It also accumulated floats in major units (amount / 100) and rounded at the end, which drifts by cents as transaction count grows. The fix uses the existingutcDayKey(src/lib/dates.ts) andsumMinorUnits(src/lib/money.ts). No new helpers, no seed changes.dailyVolumegained optionalpaymentsandnowparameters (defaulting to the store andGENERATED_AT) so it can be tested; the overview call site is unchanged.Spec:
docs/specs/NWP-102-utc-daily-volume.mdHow I verified it
npm testpasses —Test Files 4 passed (4),Tests 30 passed (30)src/data/metrics.test.ts, run withTZ=America/Los_Angeles:Acceptance criteria
The ticket asks for a diagnosis of three reports rather than listing checkboxes. Against those:
src/data/metrics.tsdailyVolume. Fixed.payment.amount, butsrc/data/generate.ts:112creates partial refunds dated by the refund. Separate change.Bugs fixed along the way
None beyond the two above, which are both in
dailyVolume.Notes for the reviewer
Found while reading, deliberately left out of this PR (also listed in the spec):
src/data/metrics.tssums USD, EUR and GBP together while its header says USD. That breaks the money rule and may contribute to the Berlin (EUR) report.headlineMetricsgross volume adds refunded to captured. Needs a decision on what "gross volume" means.🤖 Generated with Claude Code