Build invoice generation and management system
✓Works with OpenClaudeYou are a backend developer building a production-ready invoice system. The user wants to create a complete invoice generation and management system with storage, PDF export, and payment tracking.
What to check first
- Verify you have a database set up (PostgreSQL recommended) with migration tools like Prisma or Sequelize
- Check that you have
pdfkitorpuppeteeravailable:npm list pdfkit puppeteer - Confirm Node.js version is 16+ with
node --version
Steps
- Install required dependencies:
npm install express prisma @prisma/client pdfkit uuid dotenv stripefor Stripe integration - Define your Prisma schema with
Invoice,InvoiceItem, andCustomermodels including timestamps and status fields - Create a database migration with
npx prisma migrate dev --name init_invoice_schema - Build the invoice controller with methods:
createInvoice(),getInvoiceById(),listInvoices(),updateInvoiceStatus() - Implement PDF generation using pdfkit with
invoice.generatePDF()that iterates through invoice items and calculates totals - Add invoice item calculations in the model: subtotal, tax amount (use
tax_rate * subtotal), and total due - Create routes for POST
/invoices, GET/invoices/:id, GET/invoices, PATCH/invoices/:id/status - Implement soft delete for invoices by adding
deleted_attimestamp and filtering archived invoices in queries
Code
import express from 'express';
import { PrismaClient } from '@prisma/client';
import PDFDocument from 'pdfkit';
import { v4 as uuidv4 } from 'uuid';
import fs from 'fs';
const app = express();
const prisma = new PrismaClient();
app.use(express.json());
// Create invoice with items
app.post('/invoices', async (req, res) => {
try {
const { customerId, items, taxRate = 0.10, dueDate } = req.body;
const subtotal = items.reduce((sum, item) => sum + (item.quantity * item.unitPrice), 0);
const taxAmount = subtotal * taxRate;
const totalAmount = subtotal + taxAmount;
const invoice = await prisma.invoice.create({
data: {
invoiceNumber: `INV-${Date.now()}-${uuidv4().slice(0, 8)}`,
customerId,
subtotal,
taxAmount,
totalAmount,
taxRate,
status: 'DRAFT',
dueDate: new Date(dueDate),
items: {
create: items.map(item => ({
description: item.description,
quantity: item.quantity,
unitPrice: item.unitPrice,
lineTotal
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Payments Skills
Other Claude Code skills in the same category — free to download.
Stripe Integration
Integrate Stripe payments with checkout and payment intents
Stripe Subscriptions
Set up recurring subscription billing with Stripe
Stripe Webhooks
Handle Stripe webhook events with signature verification
PayPal Integration
Integrate PayPal payments and checkout
Payment Form
Build secure PCI-compliant payment forms
Pricing Page
Build dynamic pricing page with plan comparison
Payment Testing
Set up payment testing with test cards and sandbox environments
Want a Payments skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.