Skip to content

feat: add invoice pdf download on purchase lists - #1022

Open
tomrndom wants to merge 4 commits into
masterfrom
feature/invoice-purchases-pdf
Open

feat: add invoice pdf download on purchase lists#1022
tomrndom wants to merge 4 commits into
masterfrom
feature/invoice-purchases-pdf

Conversation

@tomrndom

@tomrndom tomrndom commented Jul 24, 2026

Copy link
Copy Markdown

ref: https://app.clickup.com/t/9014802374/86bb31qvd
depends on OpenStackweb/openstack-uicore-foundation#282 (comment)
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added invoice PDF download actions for sponsor purchases.
    • Invoices include summit-specific details and branding.
    • Improved accessibility with translated download labels.
  • Bug Fixes
    • Enhanced sponsor order retrieval to support selecting the correct sponsor context.
    • Prevents concurrent invoice generation/download requests.
    • Displays user-facing errors when invoice generation fails.
  • Chores / Tests
    • Updated UI core dependency and adjusted Jest file mock mapping.
    • Improved test mocks and added summit context to test state.

tomrndom added 2 commits July 24, 2026 17:18
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a73282c1-8ff0-41ec-9eed-dee8386a0918

📥 Commits

Reviewing files that changed from the base of the PR and between 2af4f37 and c8f9285.

📒 Files selected for processing (2)
  • src/pages/sponsors/show-purchase-list-page/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/sponsors/show-purchase-list-page/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js

📝 Walkthrough

Walkthrough

Sponsor purchase views now support invoice PDF downloads. They retrieve sponsor orders with optional sponsor identifiers, generate PDFs using summit data, prevent duplicate requests, display translated errors, and expose accessible download actions.

Changes

Sponsor invoice downloads

Layer / File(s) Summary
Sponsor order lookup contract
src/actions/sponsor-purchases-actions.js
getSponsorOrder accepts an optional sponsorId and uses the resolved identifier in the purchase-order API endpoint.
Purchase list invoice flow
src/pages/sponsors/show-purchase-list-page/index.js, src/i18n/en.json
The purchase list fetches orders and generates invoice PDFs using summit data and a logo, with loading protection, translated errors, and an accessible download action.
Sponsor purchases tab invoice flow
src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/index.js, src/pages/sponsors/sponsor-page/tabs/sponsor-purchases-tab/__tests__/*, package.json
The sponsor purchases tab adds guarded invoice generation, summit-state wiring, translated errors, accessible download behavior, test state and mocks, and supporting Jest/dependency configuration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SponsorPurchaseView
  participant getSponsorOrder
  participant generateInvoicePDF
  SponsorPurchaseView->>getSponsorOrder: Fetch selected sponsor order
  getSponsorOrder-->>SponsorPurchaseView: Return order data
  SponsorPurchaseView->>generateInvoicePDF: Generate invoice with summit data and logo
  generateInvoicePDF-->>SponsorPurchaseView: Download invoice PDF
Loading

Possibly related PRs

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding invoice PDF download support on purchase lists.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/invoice-purchases-pdf

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
setLoadingPDF(true);
getSponsorOrder(item.id, sponsor.id)
.then(({ response: fetchedOrder }) =>
generateInvoicePDF(fetchedOrder, currentSummit, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom generateInvoicePDF is called with the raw, un-normalized order fetched here, but the rest of this app normalizes this exact order shape before rendering it — the PDF will disagree with the on-screen grid on discount line descriptions.

{ response: fetchedOrder } is the raw API response from getSponsorOrder. Everywhere else this order shape reaches the UI (SponsorOrderGrid on SponsorOrderDetails), it goes through normalizeOrder() (src/pages/sponsors/sponsor-page/utils.js:6-13) first, via the RECEIVE_SPONSOR_ORDER reducer (sponsor-page-purchase-list-reducer.js:101). openstack-uicore-foundation's OrderPdf/buildRows (which generateInvoicePDF renders) expects form.discount to already be the formatted string normalizeOrder produces (formatDiscount(form.discount_amount, form.discount_type)) — its own test fixtures pass discount: "15%" as a literal. Passing the raw order here means form.discount is undefined on every form, so any order with a discount applied downloads a PDF where the "DIS" line shows the right amount but a blank description.

Same pattern at src/pages/sponsors/show-purchase-list-page/index.js:99-106.

Suggested fix: run fetchedOrder through normalizeOrder() before calling generateInvoicePDF, the same way the reducer does for the on-screen view — generateInvoicePDF(normalizeOrder(fetchedOrder), currentSummit, {...}). (Flagged the same gap from the uicore side on OpenStackweb/openstack-uicore-foundation#282, since either OrderPdf enforcing/documenting its expected shape or normalizing here before the call closes it.)

setLoadingPDF(true);
getSponsorOrder(purchaseOrder.id, purchaseOrder.sponsor_id)
.then(({ response: fetchedOrder }) =>
generateInvoicePDF(fetchedOrder, currentSummit, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom Same raw-vs-normalized order gap as sponsor-purchases-tab/index.js:97fetchedOrder here is never passed through normalizeOrder() before generateInvoicePDF, so discount line descriptions will be blank in the downloaded PDF for this entry point too. Same fix: generateInvoicePDF(normalizeOrder(fetchedOrder), currentSummit, {...}).

@smarcet
smarcet requested a review from Copilot July 27, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@smarcet smarcet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom please review

…oice PDF

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants