Skip to content

Add Invoice status enum, API + UI support, dashboard counts#58

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

Add Invoice status enum, API + UI support, dashboard counts#58
grmbyrn merged 1 commit into
mainfrom
wl-42

Conversation

@grmbyrn
Copy link
Copy Markdown
Owner

@grmbyrn grmbyrn commented Apr 1, 2026

No description provided.

@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 8:07pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new invoice status field is introduced as a database enum (DRAFT, SENT, PAID, OVERDUE) with corresponding Prisma model updates. API endpoints are extended to compute and return unpaid/overdue invoice counts, handle status transitions with validation, and default new invoices to DRAFT. Dashboard and invoice list UI components are updated to display status as colored pills and enable users to change status via dropdown controls.

Changes

Cohort / File(s) Summary
Database Schema
prisma/migrations/20260401195727_add_invoice_status/migration.sql, prisma/schema.prisma
Added InvoiceStatus enum (DRAFT, SENT, PAID, OVERDUE) and status column to Invoice table with NOT NULL constraint and DRAFT default.
Dashboard API Metrics
app/api/dashboard/route.ts
Extended GET response to include unpaidCount (invoices with status !== 'PAID') and overdueCount (invoices with status !== 'PAID' and either status === 'OVERDUE' or dueDate earlier than now).
Invoice API Routes
app/api/invoices/route.ts, app/api/invoices/[id]/route.ts
Updated GET to check status !== 'PAID' for overdue logic; updated POST to set status: 'DRAFT' on creation; enhanced PATCH to validate and apply status updates with conditional isPaid synchronization logic.
Dashboard UI
app/dashboard/page.tsx
Extended DashboardData interface with optional unpaidCount and overdueCount fields; added two new statistic cards displaying unpaid and overdue invoice counts (with red styling for overdue).
Invoices List UI
app/invoices/page.tsx
Added optional status field to Invoice interface; replaced status label logic with status-driven colored pill rendering; introduced <select> dropdown to allow users to change invoice status with PATCH request and query invalidation.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API as API Server
    participant DB as Database

    rect rgba(100, 150, 200, 0.5)
        Note over Client,DB: Invoice Status Update Flow
        Client->>API: PATCH /api/invoices/{id} with { status: newStatus }
        API->>API: Validate: status is string and in allowed set
        API->>API: Conditionally sync isPaid based on status
        API->>DB: UPDATE invoice SET status, isPaid
        DB->>API: Confirm update
        API->>Client: Return updated invoice
        Client->>Client: Invalidate ['invoices'] query
    end

    rect rgba(150, 100, 200, 0.5)
        Note over Client,DB: Dashboard Metrics Computation Flow
        Client->>API: GET /api/dashboard
        API->>DB: COUNT invoices WHERE status != 'PAID'
        DB->>API: Return unpaidCount
        API->>DB: COUNT invoices WHERE (status != 'PAID' AND (status = 'OVERDUE' OR dueDate < now))
        DB->>API: Return overdueCount
        API->>Client: JSON response with unpaidCount, overdueCount
        Client->>Client: Render new metric cards
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Feature/invoice paid status #18: Directly related as both PRs modify the same invoice PATCH handler and invoices page UI to support status updates alongside the existing isPaid field, with overlapping validation and synchronization logic.
  • Add invoice dueDate: DB, API, UI, PDF; default +30d; overdue flag #57: Closely related as both modify invoice overdue logic and affect the same API/UI files (app/api/invoices/route.ts and app/invoices/page.tsx), with the main PR adding status-based overdue tracking and the retrieved PR introducing the dueDate and isOverdue flag.

Poem

🐰 A status for every invoice, from DRAFT to PAID with care,
Unpaid counts hop on dashboards, overdue warnings flare!
Status pills now glow and guide each transformation through,
From SENT to OVERDUE, the invoice's journey shines brand new! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main changes across the pull request: adding an InvoiceStatus enum to the database schema, implementing API support for status updates, adding UI controls to manage invoice status, and displaying unpaid/overdue counts on the dashboard.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-42

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


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 88329ef into main Apr 1, 2026
3 of 4 checks passed
@grmbyrn grmbyrn deleted the wl-42 branch April 1, 2026 20:09
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