Skip to content

Add invoice dueDate: DB, API, UI, PDF; default +30d; overdue flag#57

Merged
grmbyrn merged 1 commit into
mainfrom
wl-49
Apr 1, 2026
Merged

Add invoice dueDate: DB, API, UI, PDF; default +30d; overdue flag#57
grmbyrn merged 1 commit into
mainfrom
wl-49

Conversation

@grmbyrn
Copy link
Copy Markdown
Owner

@grmbyrn grmbyrn commented Apr 1, 2026

Summary by CodeRabbit

  • New Features
    • Added due date support for invoices with a default 30-day period
    • Invoice status now displays "Overdue" when past due and unpaid
    • Due date field added to invoice creation form
    • Due date rendering included in generated invoice PDFs

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worklog Ready Ready Preview, Comment Apr 1, 2026 7:35pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 27f07e3b-1ac8-4a70-8e24-4a0bf4c8a6d6

📥 Commits

Reviewing files that changed from the base of the PR and between 6ed96e2 and ca9e6e0.

📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • __tests__/InvoicesPage.test.tsx
  • app/api/invoices/[id]/route.ts
  • app/api/invoices/route.ts
  • app/invoices/page.tsx
  • prisma/migrations/20260401192103_add_invoice_due_date/migration.sql
  • prisma/schema.prisma

📝 Walkthrough

Walkthrough

This PR introduces an invoice due-date feature to the system. A new dueDate column is added to the Invoice database schema via migration. API endpoints now compute and return an isOverdue flag. The frontend adds a due-date input field (defaulting to 30 days ahead), renders the due date in PDFs, and displays overdue status in the invoice table.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/ci.yml
Removed extra whitespace in branches arrays and trailing blank line; no logic changes.
Database Schema
prisma/schema.prisma, prisma/migrations/20260401192103_add_invoice_due_date/migration.sql
Added optional dueDate DateTime? field to Invoice model and created corresponding SQL migration.
API Handlers
app/api/invoices/route.ts, app/api/invoices/[id]/route.ts
Enhanced GET handlers to compute and return isOverdue flag; POST handler now accepts and defaults dueDate to 30 days from creation; PATCH handler formatting adjusted.
Frontend
app/invoices/page.tsx
Added DEFAULT_DUE_DATE constant; extended Invoice interface with dueDate and isOverdue fields; added due-date input to creation form; updated PDF generation to render due date; modified status logic to prioritize overdue over paid state.
Tests
__tests__/InvoicesPage.test.tsx
Refactored mock fetch handlers and conditional logic formatting; adjusted date input selector formatting without changing test behavior.

Sequence Diagram

sequenceDiagram
    participant Client as Client (Browser)
    participant Server as API Server
    participant DB as Database

    Client->>Server: POST /api/invoices (with optional dueDate)
    Note over Server: Compute dueDate default (now + 30 days) if not provided
    Server->>DB: Create invoice with dueDate
    DB-->>Server: Invoice created
    Server-->>Client: Return created invoice

    Client->>Server: GET /api/invoices
    Note over Server: Fetch all invoices from DB
    Server->>DB: Query invoices
    DB-->>Server: Invoices retrieved
    Note over Server: Compute isOverdue for each<br/>(dueDate exists && !paid && dueDate < now)
    Server-->>Client: Return invoices with isOverdue

    Client->>Client: Render invoice table<br/>Show "Overdue" if isOverdue,<br/>else "Paid"/"Unpaid"
    Client->>Client: Render PDF with Due date
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Add due date field to invoices #49: This PR directly implements the requested dueDate field addition with schema migration, 30-day default behavior, PDF rendering, and overdue computation.

Possibly related PRs

  • store hourly rate per client #56: Both PRs modify the same invoice API handlers and frontend page to extend invoice objects with additional optional fields.
  • Feature/invoice paid status #18: Both PRs involve invoice payment/status handling, with retrieved PR introducing PATCH/isPaid logic while this PR adds overdue status prioritization.

Poem

🐰 A hop through the dates, a due one appears,

Thirty days hence by default, crystal clear!

Overdue flags now wave with pride,

In PDFs and tables, no dates can hide! 📅

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wl-49

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@grmbyrn grmbyrn merged commit f4243eb into main Apr 1, 2026
3 of 4 checks passed
@grmbyrn grmbyrn deleted the wl-49 branch April 1, 2026 19:39
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