feat(sponsor-reports): surface partial line cancellations in the By Item and Lines Manifest views - #1056
Conversation
…eport views The three-way line state (canceled / partially canceled / parent order status) was written three times: LineStatusPill, accumulateRow's contributor token, and the ByItemView drill-down render. Collapse to lineStatus() plus a token-driven LineStatusPill, both exported from LinesManifestView, which ByItemView already imports from. Also drop six tests that pass with the code deleted (a tone-map lookup, two identity assertions, unreachable is_canceled branches) and five that duplicated a surviving assertion, and trim the new comments to the eight that stop a plausible wrong edit. Co-Authored-By: Claude <noreply@anthropic.com>
…ifest rows The Qty cell reads "3 / 5" while the money cell priced all 5, so the row contradicted itself. Render both figures, matching the Qty cell: netting alone would drop the charged amount, and this is the only per-line money surface finance has (the Orders serializer carries no cancellation field). Co-Authored-By: Claude <noreply@anthropic.com>
…color Spec requires the partial state be visually distinct; only its label was guarded. Asserts the rendered chip class rather than the tone lookup, so it fails on real breakage instead of restating the map. Co-Authored-By: Claude <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Comment |
There was a problem hiding this comment.
Pull request overview
This pull request updates Sponsor Reports “Purchase Details” views to correctly represent partially canceled line items by netting canceled units/amounts in aggregates and surfacing a distinct per-line status indicator (rather than relying on the parent order status).
Changes:
- Added shared helpers in
LinesManifestView.jsto compute live (net) quantity/amount and a three-way line status, plus aLineStatusPillrenderer. - Updated By Item to net partially canceled units and cents into item aggregates and to display split quantities and line-level status in drill-down contributors.
- Updated Lines Manifest to display split quantity and “live / charged” money for partially canceled lines, and to render the line-level status pill.
- Added the “Partially Canceled” i18n string, updated status tone mapping, and expanded unit tests to cover the new behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/i18n/en.json | Adds label for the new partially canceled line status. |
| src/components/sponsors/reports/StatusPill.js | Adds a warning tone mapping for partially_canceled. |
| src/components/sponsors/reports/LinesManifestView.js | Introduces shared “live” helpers, line-level status resolution, and updated row rendering for partial cancellations. |
| src/components/sponsors/reports/ByItemView.js | Uses shared helpers to net aggregates and show partial-cancel splits/status in contributor drill-down rows. |
| src/components/sponsors/reports/tests/StatusPill.test.js | Verifies color mapping for partially_canceled. |
| src/components/sponsors/reports/tests/LinesManifestView.test.js | Adds coverage for live helpers and partially canceled rendering behaviors. |
| src/components/sponsors/reports/tests/ByItemView.test.js | Adds coverage for aggregate netting and contributor split/status rendering for partial cancellations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ref: https://app.clickup.com/t/9014802374/86bbpjzmm
Both Purchase Details report views read the binary
is_canceledonly, so a partially cancelled line rendered as fully live and its cancelled units counted as purchased. The API has returnedcanceled_quantity,canceled_amountandis_partially_canceledsince sponsor-reports-api #41; nothing here consumed them.What changed
Two pure helpers plus a shared status token, exported from
LinesManifestView.js(the one-wayByItemView->LinesManifestViewdependency already existed):liveQuantity(row)andliveAmountCents(row)net the cancelled portion, clamped at 0, null-in/null-out for money.lineStatus(row)resolves the line's own three-way state, andLineStatusPillrenders it. A soft-cancelled or partially cancelled line leaves its parent orderPaid, sopurchase.statusalone printed "Paid" on a row with real cancelled units.By Item nets both units and money into the item aggregates. The money subtraction is exact rather than prorated:
canceled_amountis the source's own frozen sum for the cancelled units, and the source charges partial events at floor unit price, so proration drifts by cents. Drill-down contributors carry the same live money they contribute, so the rows sum to their own header.Lines Manifest shows the cancelled portion on the row:
3 / 5units and$1980.00 / $3300.00. Live over charged for money, because that column is the only per-line money surface finance has and netting alone would drop the charged figure.Deliberate, not oversights
0 / $0.00would erase what the cancellation was for. Item aggregates are unaffected either way, since a fully cancelled line never enters theif (!row.is_canceled)block.bucketLinesBySponsoris untouched.liveLineCountcounts lines, not units, and a partially cancelled line is still one live line to fulfil.Known divergence, tracked in 86bbmwk83
The Total Items tile is computed server side (
purchase_details_summary,Sum('quantity')filtered oncanceled_at IS NULL) and cannot be corrected from this repo. On dev summit 73 it reads 212 against a netted By Item Σ Qty of 201, a gap of 11. 86bbmwk83 closes it. If that ships in the same release there is no window; if not, the two disagree only on data containing a partially cancelled line.Verified on dev
Deployment slot 13, backfill run, 8 partially cancelled lines. Every rendered figure was checked against the database:
By Item drill-downs sum to their headers (
SJC-L-D: 2+5+2 = 9 units, $500+$1250+$400 = $2150). All five sit underPaidorders, which is the trap this fixes.yarn test: 183 suites, 1634 tests. eslint clean on the changed files.Note for review
Partially CanceledandPendingboth map to thewarningtone, so they share a colour in the Status column. The labels differ and are readable, but they are not separable at a glance, most visibly in a By Item drill-down where the two sit adjacent.secondaryis the only unused tone inTONE_BY_STATUSif you would rather they were distinct. Happy either way.