Sponsor Reports: show-wide By Item view for the warehouse pull sheet - #1025
Sponsor Reports: show-wide By Item view for the warehouse pull sheet#1025caseylocker wants to merge 2 commits into
Conversation
…sheet The By Item report only rolled up within a sponsor, so there was no way to read a show-wide total for an item. The warehouse pulls the bulk number for a show first, then assigns that inventory out, and had no view for the first half of that. Adds a layout toggle to the By Item view: - By Sponsor (as before): sponsor accordions -> per-item aggregates - All Sponsors: one row per item_code across every sponsor, drilling down to the contributing orders with the sponsor and destination each unit goes to Both layouts share one accumulator, so what counts as purchased cannot drift between them: canceled lines stay excluded from qty/money/orders while still showing struck-through, and every payment status including Pending counts toward the pull total. Both render through one group container, so the card surface, summary divider and table inset match by construction. Also here: - Sortable Item Code / Item Name / Qty / Orders columns, defaulting to Item Code ascending; order/orderDir live in the by-item slice so the choice survives the Orders toggle. Sorting runs before paging in the all-sponsors layout, and is stable, so the canonical qty-desc rollup survives as the tiebreak. - Expand All / Collapse All over both the group accordions and the per-item drill-downs. Collapse All returns to the default view rather than closing the groups as well. - Export CSV in this view now orders the per-line manifest by item code, so every line for one item lands together with its sponsor and booth — the OVERALL sheet the logistics team reconciles against. item_code was already in the endpoint's ordering_fields; no backend change. The rollup is derived client-side from rows the whole-set fetch already loads, so none of this adds an API call. Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe By Item purchase details report now supports cross-sponsor aggregation, client-side sorting, sponsor and all-sponsors layouts, bulk expansion controls, Redux sort state, and CSV exports ordered by item code. ChangesBy Item report
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ByItemView
participant PurchaseDetailsReportPage
participant Redux
participant ExportPurchaseDetailsLinesCsv
User->>ByItemView: choose layout or sort column
ByItemView->>PurchaseDetailsReportPage: invoke callback
PurchaseDetailsReportPage->>Redux: update By Item sort state
Redux-->>PurchaseDetailsReportPage: provide order and orderDir
User->>PurchaseDetailsReportPage: export By Item lines
PurchaseDetailsReportPage->>ExportPurchaseDetailsLinesCsv: pass filters and item_code
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/actions/__tests__/sponsor-reports-actions.test.js (1)
1025-1041: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAdd the negative case alongside this one. The default (no-order) export now always spreads
order: null; assert that the emitted params carry noorderkey so a serializer change can't silently start sending an empty ordering param on the Line Items export.💚 Suggested addition
it("exportPurchaseDetailsLinesCsv omits the ordering param when no alias is given", async () => { await exportPurchaseDetailsLinesCsv({ status: "Paid" })(dispatch, getState); const [, params] = getCSV.mock.calls[0]; expect(params.order).toBeUndefined(); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/actions/__tests__/sponsor-reports-actions.test.js` around lines 1025 - 1041, Add a test beside the existing exportPurchaseDetailsLinesCsv ordering test that invokes the action without an ordering alias and asserts the generated params have no order key (params.order is undefined).src/components/sponsors/reports/ByItemView.js (1)
252-259: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale
ItemTabledoc comment sits aboveItemGroup. Lines 252-255 describeItemTable/showSponsorbut are attached toItemGroup; move them down to theItemTabledeclaration at Line 288.♻️ Suggested move
-// The item table both layouts render: one row per item_code with the purchased -// aggregates, expanding to the orders that contributed. `showSponsor` adds the -// Sponsor column to the drill-down for the all-sponsors layout, where the -// sponsor is no longer carried by a parent accordion. // The group container BOTH layouts render: an accordion whose summary carriesand above
const ItemTable = ({(Line 288):+// The item table both layouts render: one row per item_code with the purchased +// aggregates, expanding to the orders that contributed. `showSponsor` adds the +// Sponsor column to the drill-down for the all-sponsors layout, where the +// sponsor is no longer carried by a parent accordion. const ItemTable = ({🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/sponsors/reports/ByItemView.js` around lines 252 - 259, Move the stale documentation comment from above ItemGroup to directly above the ItemTable declaration. Keep the existing ItemTable/showSponsor explanation unchanged and leave the ItemGroup documentation with only content describing ItemGroup.src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js (1)
200-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBy Item fixture lacks the new
order/orderDirslice fields.mapStateToPropsnow reads them, soByItemViewrenders withorder === undefinedhere — no column is ever active and the page-level sort wiring stays untested. Mirror the reducer's defaults.💚 Proposed fix
sponsorReportsPurchaseDetailsByItemState: { data: byItemData, summary: null, currentPage: 1, perPage: 10, + order: "itemCode", + orderDir: 1, filters: byItemFilters, readError: byItemReadError }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js` around lines 200 - 207, Update the sponsorReportsPurchaseDetailsByItemState fixture used by the ByItemView tests to include the reducer-default order and orderDir fields. Keep their values aligned with the reducer defaults so mapStateToProps receives valid sorting state and the page-level sort behavior is exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js`:
- Around line 83-90: The mocked action factory must include
setPurchaseDetailsByItemSort because mapDispatchToProps binds it and page-level
sorting invokes the resulting prop. Add a Jest mock for
setPurchaseDetailsByItemSort alongside setPurchaseDetailsByItemPaging, returning
the expected sort action shape used by handleByItemSort.
---
Nitpick comments:
In `@src/actions/__tests__/sponsor-reports-actions.test.js`:
- Around line 1025-1041: Add a test beside the existing
exportPurchaseDetailsLinesCsv ordering test that invokes the action without an
ordering alias and asserts the generated params have no order key (params.order
is undefined).
In `@src/components/sponsors/reports/ByItemView.js`:
- Around line 252-259: Move the stale documentation comment from above ItemGroup
to directly above the ItemTable declaration. Keep the existing
ItemTable/showSponsor explanation unchanged and leave the ItemGroup
documentation with only content describing ItemGroup.
In
`@src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js`:
- Around line 200-207: Update the sponsorReportsPurchaseDetailsByItemState
fixture used by the ByItemView tests to include the reducer-default order and
orderDir fields. Keep their values aligned with the reducer defaults so
mapStateToProps receives valid sorting state and the page-level sort behavior is
exercised.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a1b9a98-599a-4892-8b0c-f3fe72d70186
📒 Files selected for processing (9)
src/actions/__tests__/sponsor-reports-actions.test.jssrc/actions/sponsor-reports-actions.jssrc/components/sponsors/reports/ByItemView.jssrc/components/sponsors/reports/__tests__/ByItemView.test.jssrc/i18n/en.jsonsrc/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.jssrc/pages/sponsors/sponsor-reports/purchase-details-report-page/index.jssrc/reducers/sponsors/__tests__/sponsor-reports-purchase-details-by-item-reducer.test.jssrc/reducers/sponsors/sponsor-reports-purchase-details-by-item-reducer.js
…el sorting The revert of the client-side rollup CSV also took out the setPurchaseDetailsByItemSort entry it had added to the page test's action mock, so mapDispatchToProps bound the prop to undefined. Nothing caught it: there was no page-level test that sorts. Adding one first reproduced it as "TypeError: setByItemSort is not a function". Restores the mock, mirrors the reducer's order/orderDir defaults in the buildState fixture (without them no column renders active), and adds the page-level test that clicks a sort header and asserts the thunk fires. Also moves the ItemTable doc comment back above ItemTable — inserting ItemGroup had orphaned it above the wrong function.
|
Worked through the three nitpicks from the review body. Two applied, one declined. Fixture missing Stale Negative case for the ordering param ( Full suite green at 153 suites / 1428 tests. |
There was a problem hiding this comment.
Pull request overview
This PR enhances the Sponsor Reports → Purchase Details By Item view to support a warehouse “pull sheet” workflow by adding a show-wide, item-aggregated layout (across all sponsors), plus persistent client-side sorting, bulk expand/collapse controls, and CSV export ordering by item code so lines for the same item are grouped together.
Changes:
- Added a By Sponsor / All Sponsors layout toggle, including show-wide item rollups with sponsor attribution in the drill-down.
- Implemented sortable rollup columns (persisted in the by-item reducer slice) and expand/collapse all across groups and item drill-downs.
- Updated lines CSV export from the By Item view to pass
order=item_codeto group exported lines by item.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/reducers/sponsors/sponsor-reports-purchase-details-by-item-reducer.js | Adds persisted sort state (order/orderDir) for the By Item slice. |
| src/reducers/sponsors/tests/sponsor-reports-purchase-details-by-item-reducer.test.js | Adds coverage for default sort and SET_SORT behavior. |
| src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js | Wires new layout toggle, sorting, item rollup, and CSV export ordering into the page. |
| src/pages/sponsors/sponsor-reports/purchase-details-report-page/tests/index.test.js | Tests CSV export ordering and sort dispatch wiring from the page. |
| src/i18n/en.json | Adds UI strings for layout toggle, pagination label, and expand/collapse actions. |
| src/components/sponsors/reports/ByItemView.js | Implements shared accumulation for both layouts, show-wide item grouping, sorting UI, and expand/collapse all. |
| src/components/sponsors/reports/tests/ByItemView.test.js | Adds extensive tests for show-wide grouping, sorting behavior, and expand/collapse semantics. |
| src/actions/sponsor-reports-actions.js | Adds sort action + LINES_ORDER_BY_ITEM constant and updates lines CSV export to accept an order param. |
| src/actions/tests/sponsor-reports-actions.test.js | Tests passing the ordering alias through to the lines CSV export query. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ref: https://app.clickup.com/t/86bb4gpu5
Why
The By Item view (#1009) only rolls items up within a sponsor, so there was no way to read a show-wide total for an item. The warehouse pulls the bulk number for a show first, then assigns that inventory out — and had no view for the first half of that.
Requested by Jeremy Muir (Slack, 2026-07-27): "a filter that is across all sponsors by item (total number of 43" led Monitors for the show) … and then if you click on that item it could show the breakdown of that item in particular (I.E 10 monitors go to Intel booth, 3 go to Nvidia meeting room)", so that "our warehouse [can] pull the total equipment for the show and then start assigning that inventory once they have the bulk number pulled."
What
item_codeacross every sponsor. The drill-down gains a Sponsor column alongside the existing Destination, so it answers "10 to Intel booth, 3 to Nvidia meeting room" directly.order/orderDirlive in the by-item slice so the choice survives the Orders toggle.order=item_codeto the existing lines CSV endpoint, so every line for one item lands together with its sponsor and booth.Client-side rollup over rows the existing whole-set fetch already loads. No new API call and no backend change.
Notes for review
accumulateRow) and one group container (ItemGroup), so neither the purchased-qty semantics nor the card styling can drift between them. An earlier iteration hand-rolled the all-sponsors container and immediately diverged visually; that is why it is one component.PURCHASE_DETAILS_LINES_CSV_COLUMNSmatches the logistics OVERALL sheet exactly; only the ordering was wrong (it defaulted to sponsor name, scattering an item's lines).item_codewas already declared in the endpoint'sordering_fieldsand the CSV path runs throughfilter_queryset, so this is a query param, not a new contract./summits/{summit_id}/reports/…and the queryset filterspurchase__summit_id, so no cross-show mixing is possible and no filter was needed for it.Testing
Full suite green: 153 suites / 1427 tests. New coverage includes cross-layout Σ-qty reconciliation against a total computed from the fixture, sort stability and sort-before-paging, expansion-key separation between the two layouts, and the expand/collapse semantics.
Reviewed by Codex ahead of this PR: mergeable, no Critical or Major correctness findings; its two Minor test-quality findings are addressed in this branch.
sponsor_boothdoesn't exist in that build, and the finance columns are blank.Deliberately not in scope
Summary by CodeRabbit
New Features
Bug Fixes