# Verification — 2026-10-16

Implemented the four Reports tabs, shared DTOs, five authenticated read-only endpoints, filters, pagination, source navigation, Excel export and browser-print PDF. No database model/migration or operational seeder changes are part of this change.

## Checks performed

- Shared package build, API and app typechecks: passed.
- API build and `pnpm test:docs`: passed, including compiled Reports OpenAPI discovery.
- `node --env-file=.env prisma/verify-reports.cjs --browser`: passed. 15 contract/SQL tests and 4 Chrome browser tests. The runner creates a guarded disposable database, replays existing migrations, and removes only that test database afterward.
- Reports SQL covers end-of-period state, late cancellation/completion, history fallback, invalid duration, PM denominator, empty data, posted-only movements, mixed units, local midnight, next-period reversal, exact 10,000-row export boundary, limit rejection, read-only behavior and concurrent writer snapshot isolation.
- Reports browser covers all tabs, date changes, pagination, WO/SKU navigation, Excel download and workbook inspection, changing filters during export, disabled duplicate-export controls, print content, blocked popup, loading/error/retry/stale/empty states and desktop/mobile widths.
- PDF verification intercepts the browser print call and checks printable content. Native Save as PDF interaction is not automated; the application retains the existing browser-print workflow.
- Frontend test suite: 49 passed in 11 files, including service cancellation, query keys, empty exports and 65-row exports.
- Backend Reports/Inventory/Maintenance/response contract regression selection: 20 passed in 4 files.
- Dashboard disposable regression runner: 13 passed in 3 files.
- DamageReport review regression: 8 passed on a separate guarded disposable database.
- Inventory regression: 22 passed on a separate guarded disposable database.
- Production frontend build used for browser tests: passed; existing large-bundle warning remains.
- OpenSpec strict validation: passed.

## Scope review

Only Reports source, DTOs, tests, documentation, router registration and minimal Stock Movement SKU navigation are staged. Existing seeder changes, inventory layout/date-filter edits, and the untracked root AGENTS.md remain outside this commit. Stock Movement is staged selectively to preserve the user's layout edits.

No development database migration, destructive reseed, build:vercel, push, or OpenSpec archive was performed. Historical reports intentionally use current due dates/target metadata and disclose that limitation in the UI and exports.


## Export charts follow-up (2026-10-20)

- PDF now includes vector charts from every report tab; Excel embeds PNG charts at 2x resolution and retains the Data Grafik source worksheet. Both use the same export snapshot and captured filters as the tables. No API contract or database changes.
- Frontend typecheck passed. Frontend suite: 68 tests passed across 15 files, including safe chart labels, complete multi-section rendering, zero/empty data, chart embedding and all 65 detail rows.
- API typecheck passed, including the browser test harness.
- `node --env-file=.env prisma/verify-reports.cjs --browser`: 15 Reports service/MySQL tests and 4 browser acceptance tests passed on a guarded disposable database, cleaned up by the runner. The first attempts exposed stale test selectors for renamed report tabs/buttons; the harness now uses the current labels.
- Browser verification inspected an actual downloaded XLSX for PNG image media and all five worksheets, generated an actual PDF through Chrome printToPDF, checked SVG charts in all four sections and blocked-popup handling. Exported PNG and print-window screenshot were visually inspected. Native Excel desktop and the interactive Save as PDF dialog were not automated.
- Local ignored artifacts: `apps/api/node_modules/.cache/reports-export-chart.png`, `reports-export-print.png`, `reports-export.pdf`.
- Frontend production build passed with the existing large-chunk warning. No production/development database migration, reseed or deployment was performed.


## React capture export replacement (2026-10-20)

This replaces the previous SVG/browser-print implementation. Dependencies: react-to-pdf 3.2.2 and html2canvas 1.4.1; ExcelJS remains unchanged. PDF is now raster/screenshot based and downloads directly. The manual SVG renderer and popup/print functions were removed after checking all references.

- `report-capture.tsx` owns isolated React rendering, readiness checks, supported CSS colors, html2canvas options and temporary document cleanup.
- `report-chart-export.tsx` captures the existing ReportCharts/Recharts component as Base64 PNG sections with a shared maximum scale.
- `report-export.ts` owns ExcelJS raw cells, source datasets and image placement.
- `report-pdf-export.tsx` builds the initial PDF with react-to-pdf, appends bounded html2canvas captures to the returned document, and saves it. Table batches are measured and headers repeated; no single unbounded canvas is created for all export rows.
- Frontend/API typechecks passed. Frontend suite: 68 tests in 15 files passed. An initial focused run timed out during a cold ExcelJS import while the browser build ran concurrently; the isolated rerun and full frontend suite passed.
- Disposable Reports runner with `--browser`: 15 service/MySQL tests and 4 browser tests passed. Browser checks real XLSX PNG media, direct PDF filename/header/pages/images, frozen filters, duplicate-export controls, cleanup and button recovery after injected capture failure. Database cleanup completed.
- Inspected the Recharts image extracted from XLSX and the first three PDF page images (summary, chart, table); all contain the expected content. Sample PDF had 12 pages. Native desktop Excel was not automated.
- Build passed with the existing chunk-size warning. No backend contract/schema change, migration to the working database, reseed or deployment.
