Skip to main content
The Invoice Payment Workflow manages the billing lifecycle from invoice creation through payment collection and bank reconciliation.

Overview

Flow: Job Completed -> Invoice Created -> Sent -> Payment -> Reconciliation
Key Files:
  • apps/workbooks-api/src/trpc/routers/invoices.ts
  • packages/workbooks-db/src/schema/invoices.ts

Invoice Status States


Workflow Diagram


Invoice Creation

1

Source Triggers

Invoices can be created from multiple sources:

Job Completed

  • Auto-create invoice
  • Copy job details
  • Link to job

Quote Direct

  • Deposit invoice
  • Upfront payment

Manual

  • Custom invoice
  • Standalone billing
2

Invoice Created

Invoice is created in draft status with:
  • Invoice number
  • Customer details
  • Line items
  • Subtotal, tax, total
  • Due date
3

Review & Send

Choose send method:
  • Email sent immediately
  • SMS option available
  • PDF attachment included
  • Status changes to unpaid

Payment Terms

Standard Terms

Discount Terms


Reminder Schedule

Automated Reminders

Reminder Configuration


Bank Reconciliation

Transaction Matching

Partial Payments


Invoice Generation

From Completed Job


Status Transitions

Allowed Transitions

Terminal States: Once an invoice reaches paid or canceled status, no further transitions are allowed.

API Endpoints

Invoice Management


Email Templates

Invoice Email

Payment Reminder


Testing

Invoice Payment Test Path

1

Complete Job

Complete a job with line items
2

Create Invoice

Create invoice from job
3

Verify Details

Verify invoice details copied correctly
4

Send Invoice

Send invoice via email
5

Verify Status

Verify status is “unpaid”
6

Wait for Due Date

Wait for due date (or simulate)
7

Check Overdue

Verify overdue status and reminder sent
8

Record Payment

Record payment manually
9

Verify Paid

Verify invoice marked “paid”
10

Check Job Status

Verify job updated to “invoiced”

Integration Tests


Customer Lifecycle

Full workflow

Timesheet Billing

Time-based billing

Status Reference

All status enums