Skip to content

feat: allow draft invoice downloads - #2

Merged
maxehmoon merged 1 commit into
mainfrom
feat/download-draft-invoices
Sep 8, 2026
Merged

maxehmoon merged 1 commit into
mainfrom
feat/download-draft-invoices

Conversation

@maxehmoon

Copy link
Copy Markdown
Owner

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 typecheck
  • bun run lint
  • bun run test — 258 passed, 1 skipped
  • bun run build — passed with two file-tracing warnings in unchanged next.config.ts / database code
  • Relevant light and dark UI states checked at desktop and mobile widths
  • No secrets, local databases or real customer data included

Focused verification with isolated synthetic invoices confirmed valid PDF attachments for drafts and issued invoices, the DRAFT label, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T12:42:19.495110Z 5a47972 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@maxehmoon
maxehmoon force-pushed the feat/download-draft-invoices branch from f0e1a5a to 5a47972 Compare September 8, 2026 12:36
@maxehmoon
maxehmoon merged commit 2a77ded into main Sep 8, 2026
2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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" ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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`}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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