Description
For financial compliance, organizations need a tamper-evident PDF document that records every state change, payment event, and user action on an invoice from creation to closure. This issue generates a formal audit trail PDF for any invoice on demand, including a chronological event table, transaction hashes with links, actor identities, timestamps, and an optional digital signature field for the creator. The PDF must be generated server-side to prevent client-side manipulation.
Technical Context
Create app/api/invoices/[id]/audit-pdf/route.ts as a server-side PDF generation endpoint using @react-pdf/renderer or pdfkit. The endpoint collects all AuditLog entries for the invoice (status changes, payment confirmations, co-creator actions, comment additions), sorts them chronologically, and renders them as a table. Each entry includes: timestamp, actor, action, previousValue, newValue, txHash (if applicable). Add a page header with the invoice ID, creator name, creation date, and platform logo. Append a SHA-256 hash of the event table data as a verification footer. Expose the download button on app/invoice/[id]/page.tsx in an "Audit" dropdown. The PDF must be generated with a consistent Content-Disposition: attachment header to trigger browser download.
Acceptance Criteria
Description
For financial compliance, organizations need a tamper-evident PDF document that records every state change, payment event, and user action on an invoice from creation to closure. This issue generates a formal audit trail PDF for any invoice on demand, including a chronological event table, transaction hashes with links, actor identities, timestamps, and an optional digital signature field for the creator. The PDF must be generated server-side to prevent client-side manipulation.
Technical Context
Create
app/api/invoices/[id]/audit-pdf/route.tsas a server-side PDF generation endpoint using@react-pdf/rendererorpdfkit. The endpoint collects allAuditLogentries for the invoice (status changes, payment confirmations, co-creator actions, comment additions), sorts them chronologically, and renders them as a table. Each entry includes:timestamp,actor,action,previousValue,newValue,txHash(if applicable). Add a page header with the invoice ID, creator name, creation date, and platform logo. Append a SHA-256 hash of the event table data as a verification footer. Expose the download button onapp/invoice/[id]/page.tsxin an "Audit" dropdown. The PDF must be generated with a consistentContent-Disposition: attachmentheader to trigger browser download.Acceptance Criteria