feat: add invoice pdf download on purchase lists - #1022
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughSponsor 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. ChangesSponsor invoice downloads
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
| setLoadingPDF(true); | ||
| getSponsorOrder(item.id, sponsor.id) | ||
| .then(({ response: fetchedOrder }) => | ||
| generateInvoicePDF(fetchedOrder, currentSummit, { |
There was a problem hiding this comment.
@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, { |
There was a problem hiding this comment.
@tomrndom Same raw-vs-normalized order gap as sponsor-purchases-tab/index.js:97 — fetchedOrder 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, {...}).
…oice PDF Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
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