feat: invoice CRUD API with Puppeteer PDF generation & Cloudinary storage#123
Merged
0xdevcollins merged 1 commit intomainfrom Apr 4, 2026
Merged
Conversation
- Add full CRUD endpoints: POST, GET (list + detail), PATCH, DELETE
- Add PDF generation via Puppeteer rendering a branded HTML template
- Add PDF storage via Cloudinary (free tier, replaces R2)
- Add partial payment tracking with automatic status transitions
- Add StorageService (Cloudinary) and PdfService modules
- Add Zod-validated DTOs for create, update, filters, and record-payment
- Extend Invoice schema: invoiceNumber, amountPaid, customerPhone,
customerAddress, notes, updatedAt + DB indexes
- Add migration backfilling updatedAt for existing rows
- Update .env.example to replace R2 vars with Cloudinary vars
Status lifecycle: DRAFT → SENT → VIEWED → PARTIALLY_PAID → PAID → OVERDUE → CANCELLED
Endpoints: POST /v1/invoices, GET /v1/invoices, GET /v1/invoices/:id,
PATCH /v1/invoices/:id, DELETE /v1/invoices/:id,
GET /v1/invoices/:id/pdf, GET /v1/invoices/:id/pdf/download,
POST /v1/invoices/:id/send, POST /v1/invoices/:id/cancel,
POST /v1/invoices/:id/payments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #66## Summary
POST,GET,PATCH,DELETE) with Zod validationinvoiceNumber,amountPaid,customerPhone,customerAddress,notes,updatedAt+ DB indexesEndpoints
POST/v1/invoicesGET/v1/invoicesGET/v1/invoices/:idPATCH/v1/invoices/:idDELETE/v1/invoices/:idPOST/v1/invoices/:id/sendPOST/v1/invoices/:id/cancelPOST/v1/invoices/:id/paymentsGET/v1/invoices/:id/pdfGET/v1/invoices/:id/pdf/downloadStatus lifecycle
DRAFT → SENT → VIEWED → PARTIALLY_PAID → PAID → OVERDUE → CANCELLEDTest plan
POST /v1/invoicescreates invoice with correct computed totals (subtotal, tax, discount)GET /v1/invoicesreturns paginated list filterable by status, currency, date range, searchPATCH /v1/invoices/:idrejects non-DRAFT invoicesDELETE /v1/invoices/:idrejects non-DRAFT invoicesPOST /v1/invoices/:id/paymentstransitions status correctly (PARTIALLY_PAID → PAID)GET /v1/invoices/:id/pdfgenerates PDF, uploads to Cloudinary, returns URLGET /v1/invoices/:id/pdf/downloadstreams PDF buffer directlyCLOUDINARY_CLOUD_NAME,CLOUDINARY_API_KEY,CLOUDINARY_API_SECRETin.envnpx prisma migrate dev🤖 Generated with Claude Code