Skip to content

feat: SCO-151 export any report as a PDF - #403

Merged
scottcarlton merged 1 commit into
devfrom
feat/sco-151-report-pdf
Oct 30, 2026
Merged

scottcarlton merged 1 commit into
devfrom
feat/sco-151-report-pdf

Conversation

@scottcarlton

Copy link
Copy Markdown
Owner

Summary

  • Every report page gets an Export PDF button next to Export CSV. It links to GET /api/reports/[slug]/pdf with the page's current filter (year, or days for Product Performance).
  • src/lib/server/report-pdf.ts composes the document on the shared pdf-layout.ts canvas (same page setup as order, invoice and credit memo PDFs): title, org, filter, generated date, then the SCO-150 bar chart drawn as PDF rectangles (top 3 values labelled, "Other" muted), then the table with a repeating header on page breaks and a totals row where the page has one. No Puppeteer.
  • src/lib/utils/report-columns.ts describes each report's table as data, mirroring the page's tables column for column. Share snapshots (next PR) will reuse it.
  • The report loader moved verbatim from routes/reports/[slug]/+page.server.ts into src/lib/server/reports/load-report.ts, so the page and the PDF share one scoping path (brand scope, sales scope, Nx-BLSR). Bypass inventory and permissions map updated.

Why

SCO-151: export any report as a PDF with the current filter baked in. Share links are the second half of the ticket and come in a separate PR.

Verification

  • bun run lint passes
  • bun run check passes (0 errors)
  • bun run test:run passes (2134), including new tests for report-columns.ts and PDF smoke tests (single page, pagination, empty report, missing fields)
  • tests/rls/admin-bypass.test.ts passes with the moved supabaseAdmin call site
  • Rendered sample PDFs (Sales by Account with 13 rows, Season Sell-Through) and checked them visually: chart, top-3 labels, Other bar, percent scale, zebra rows, totals
  • Not clicked through in a browser: the Chrome extension blocks localhost by policy

Test plan

  • Open a report, pick a year, click Export PDF: the file downloads and matches the table on screen
  • Product Performance with 30 days: the PDF says "Last 30 days"
  • As a sales user: the PDF shows the same scoped rows as the page
  • A long report paginates with the header repeated

Part of SCO-151

🤖 Generated with Claude Code

Reports could only be exported as CSV. Export PDF builds the document on
the server from the same filtered rows as the page: title, filter and
date, the SCO-150 bar chart, then the table with its totals. The report
loader moved into lib/server/reports/load-report.ts so the page and the
PDF share one scoping path.

Part of SCO-151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
threadline Ready Ready Preview Oct 30, 2026 3:27pm UTC

@scottcarlton
scottcarlton merged commit b9ce405 into dev Oct 30, 2026
8 checks passed
@scottcarlton
scottcarlton deleted the feat/sco-151-report-pdf branch October 30, 2026 15:28

This branch was successfully deployed

1 active deployment
Preview — d099efa1 Deployed Oct 30, 2026 by vercel[bot]
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.

1 participant