Skip to content

feat(gsAdmin): rework invoice-comparison summary + link receipt cells#117970

Merged
armcknight merged 8 commits into
masterfrom
andrewmcknight/reveng-221-admin-show-of-invoices-that-are-1-difference
Jun 18, 2026
Merged

feat(gsAdmin): rework invoice-comparison summary + link receipt cells#117970
armcknight merged 8 commits into
masterfrom
andrewmcknight/reveng-221-admin-show-of-invoices-that-are-1-difference

Conversation

@armcknight

Copy link
Copy Markdown
Member

Frontend half of REVENG-221. Reshapes the admin invoice-comparison view so the summary leads with the parity metric operators scan for first (share of compared rows past 1% delta) and lets reviewers click straight from a delta row into the underlying invoice's receipt page.

Summary panel — Grid shrinks from 7 cards to 4

Dropped:

  • Legacy total, Platform total, Total delta — redundant with the per-row data; for parity diagnosis the per-row delta is the useful number, not aggregate volume
  • Rows — already shown by the paginator

Added:

  • >1% diffover_threshold_pct with (N of M) denominator note; the headline parity metric

Kept: Legacy invoices, Platform invoices, Unmatched.

Per-row table — Legacy and Platform $ amount cells become links

When a row has exactly one invoice on a side (the typical case in a 24h window), the $ amount renders as a <Link> to /settings/{slug}/billing/receipts/{guid}/ using the new legacy_invoice_guids / platform_invoice_guids fields the backend companion adds. Multi-invoice rows fall back to plain text — a single link can't represent N receipts and the muted count badge next to the cell already signals there's more than one.

Backend dependency

Reads new fields from AdminInvoiceComparisonEndpoint:

  • summary.over_threshold_count, summary.over_threshold_pct
  • per row: legacy_invoice_guids: string[], platform_invoice_guids: string[]

And no longer reads summary.legacy_total_cents / summary.platform_total_cents.

Merge this PR after the getsentry companion (getsentry/getsentry#20740) ships, otherwise the page renders undefined denominators and no receipt links during the deploy window.

Refs REVENG-221

Reshapes the admin invoice-comparison summary to lead with the parity
metric operators actually scan for: the share of compared (both-sided)
orgs whose per-org delta exceeds 1%. The Grid loses Legacy total,
Platform total, Total delta, and Rows (each either redundant with the
per-row data or duplicated by the paginator) so the headline ">1%
diff" stat has room to breathe alongside the existing Unmatched and
invoice-count stats; 7 cards collapses to 4.

Per-row, the Legacy and Platform `$` amount cells become `Link`s to
`/settings/{slug}/billing/receipts/{guid}/` whenever the row resolves
to exactly one invoice on that side (the typical case), using the new
`legacy_invoice_guids` / `platform_invoice_guids` fields the backend
companion change adds. Multi-invoice rows fall back to plain text -- a
single link can't represent N receipts and the count badge already
signals the cardinality.

Backend companion: getsentry feat(billing) commit, same Refs.

Refs REVENG-221

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 18, 2026

Copy link
Copy Markdown

REVENG-221

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ no issues found

…ng-221-admin-show-of-invoices-that-are-1-difference

# Conflicts:
#	static/gsAdmin/views/invoiceComparison.tsx
Comment thread static/gsAdmin/views/invoiceComparison.tsx Outdated
@armcknight armcknight marked this pull request as ready for review June 18, 2026 19:51
Comment thread static/gsAdmin/views/invoiceComparison.tsx
The Row / UnmatchedRow types declare ``*_invoice_guids`` as ``string[]``
based on the post-deploy backend shape, but a stale-cached response
from before the backend companion shipped (or any future shape drift
that drops the field) leaves ``guids`` runtime-``undefined``. The old
``guids.length !== 1`` check then threw ``TypeError`` on
``undefined.length``, crashing the page.

Widen the parameter to ``string[] | undefined`` and replace the bare
``.length`` access with optional chaining so the cell renders as plain
text in those cases — same fallback the multi-invoice branch already
uses.

Caught by Sentry's PR review bot at #117970 (comment).

Refs REVENG-221

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread static/gsAdmin/views/invoiceComparison.tsx Outdated
Per the getsentry backend revert (companion PR): drop the
``renderAmountCell`` helper and the ``*_invoice_guids`` plural type
fields; the singular ``*_invoice_guid`` fields and master's
``InvoiceAmount`` component are sufficient since rows have at most
one invoice per side in practice.

Restoring the original 7-card summary Grid (Legacy invoices,
Platform invoices, Legacy total, Platform total, Total delta, Rows,
Unmatched) and adding just the new ">1% diff" card → 8 cards. The
totals + delta + rows cards aren't being dropped after all; that
reshape was out of scope for this PR.

What's left in this PR: the ">1% diff" stat card. Nothing else.

Refs REVENG-221

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread static/gsAdmin/views/invoiceComparison.tsx
…s cards

Per the original REVENG-221 ticket scope: "get rid of legacy total
and platform total numbers" + "remove rows count because it's ==
platform invoices number". The previous review-feedback commit
over-reverted these on the UI side — Noah's "don't refactor other
stuff" was about the backend guid plumbing, not the summary card
removal, which was always part of REVENG-221's display intent.

Backend still emits ``legacy_total_cents`` / ``platform_total_cents``
for compatibility with the deployed master frontend; this PR's
frontend just stops displaying them. Grid shrinks from 8 cards to 4:
Legacy invoices, Platform invoices, >1% diff, Unmatched.

Refs REVENG-221

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
``formatPercent`` returns the infinity symbol for a ``null`` input
because that's meaningful for ``delta_pct`` rows — legacy=\$0 with
non-zero platform is "undefined drift" and sorts to the top of the
list. That semantic doesn't carry to summary ratios like
``over_threshold_pct`` / ``unmatched_invoice_pct``: a runtime
``null``/``undefined`` there only means the backend didn't populate
the field (deploy-window race, response-shape drift), not "drift
went to infinity". Rendering ``∞`` in those cells is misleading.

Adds ``formatPercentOrNA`` for the summary case (N/A on missing,
otherwise same percentage formatter as before). The existing
``formatPercent`` keeps the ``∞`` behavior for ``delta_pct`` rows.

Caught by Sentry's PR review bot at #117970 (comment).

Refs REVENG-221

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ng-221-admin-show-of-invoices-that-are-1-difference
Comment thread static/gsAdmin/views/invoiceComparison.tsx Outdated
The Summary type declares counts (``legacy_count``, ``platform_count``,
``over_threshold_count``, ``row_count``, ``unmatched_invoice_count``)
as ``number``, but a deploy-window race or response-shape drift could
leave them runtime-``undefined`` and render the literal string
``undefined`` in the UI (or ``NaN`` for the Unmatched denominator,
which sums two counts).

Adds ``formatCountOrNA`` — same defensive philosophy as the
``formatPercentOrNA`` helper added in the previous commit — and
routes every count interpolation in the summary Grid through it.
Falls back to an em dash on null / undefined / NaN, matching the
missing-value affordance ``formatDollars`` already uses.

Caught by Sentry's PR review bot at #117970 (comment).

Refs REVENG-221

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@armcknight armcknight enabled auto-merge (squash) June 18, 2026 21:24
@armcknight armcknight merged commit 17b3dea into master Jun 18, 2026
88 of 90 checks passed
@armcknight armcknight deleted the andrewmcknight/reveng-221-admin-show-of-invoices-that-are-1-difference branch June 18, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants