Repository navigation
feat: allow draft invoice downloads - #2
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
f0e1a5a to
5a47972
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a4797288d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <p className="mt-0.5 text-[12px] text-subtle-foreground">The downloaded PDF uses this same document.</p> | ||
| </div> | ||
| {invoice.lifecycle === "issued" ? ( | ||
| {invoice.lifecycle !== "void" ? ( |
There was a problem hiding this comment.
Avoid presenting drafts with an issued date
When a draft has no issue_date, enabling this download produces a PDF whose date row says Issued <created_at>, because buildInvoiceDocumentData substitutes the creation date for issuedAt and the shared document view always labels that field “Issued.” Thus an invoice that the details page reports as “Not issued” becomes an externally shareable document claiming an issuance date; draft PDFs should omit that row or label it as a draft/creation date.
Useful? React with 👍 / 👎.
| </form> | ||
| <DeleteDraftDialog action={deleteDraftInvoiceAction} invoiceId={invoice.id} /> | ||
| <Button asChild className="text-[13px]" variant="outline"> | ||
| <a href={`/api/invoices/${invoice.id}/pdf`}> |
There was a problem hiding this comment.
Give each draft download an identifiable filename
Every draft maps its missing invoice number to DRAFT, and the PDF endpoint derives Content-Disposition solely from that value, so all links enabled here download as DRAFT.pdf. When a user exports multiple drafts, clients may overwrite the earlier file or create indistinguishable names such as DRAFT (1).pdf, increasing the chance of sending the wrong invoice; include a stable draft-specific identifier in the filename while retaining the DRAFT label inside the document.
Useful? React with 👍 / 👎.
Summary
Draft invoices currently hide both PDF download controls and the PDF endpoint rejects them. Enable the header and preview downloads for drafts and allow the endpoint to render them using the existing document format.
Downloaded drafts remain labelled
DRAFT; downloading does not issue the invoice or allocate an invoice number.Verification
bun run typecheckbun run lintbun run test— 258 passed, 1 skippedbun run build— passed with two file-tracing warnings in unchangednext.config.ts/ database codeFocused verification with isolated synthetic invoices confirmed valid PDF attachments for drafts and issued invoices, the
DRAFTlabel, unchanged draft status and invoice numbering, and the existing 401/404 responses for unauthenticated or missing-invoice requests. Documentation and environment-variable changes are not applicable.