feat(billing): generate invoices from billable time entries (PMS-33) #76

Merged
vas2000-work merged 2 commits from feat/pms-33-billing into main 2026-06-05 04:13:22 +02:00
Owner

Implements PMS-33 core. create_invoice_from_time_entries: in one tx, selects billable time_entries, allocates a gapless invoice number (reusing invoice_sequences), builds one time_entry line per entry, and flips entries to billed+linked. POST /api/v1/invoices/from-time-entries (RequireFinance). tests/billing.rs 2/2 (generation + payment->paid). rust_decimal throughout; clippy -D warnings clean. Recurring-contract-item billing (PMS-64) + audit hooks (PMS-117) follow after those merge.

Implements PMS-33 core. create_invoice_from_time_entries: in one tx, selects billable time_entries, allocates a gapless invoice number (reusing invoice_sequences), builds one time_entry line per entry, and flips entries to billed+linked. POST /api/v1/invoices/from-time-entries (RequireFinance). tests/billing.rs 2/2 (generation + payment->paid). rust_decimal throughout; clippy -D warnings clean. Recurring-contract-item billing (PMS-64) + audit hooks (PMS-117) follow after those merge.
feat(billing): generate invoices from billable time entries (PMS-33)
All checks were successful
Check / fmt + clippy + compile + tests (pull_request) Successful in 54s
Build OCI container / Build and push mokosh-api image (push) Successful in 6m8s
7396d1b513
PMS-33: add the missing monetization path. New create_invoice_from_time_entries selects a company's billable time_entries (is_billable, billing_status ready_to_bill/not_billed, not yet invoiced), and in one transaction allocates a gapless per-tenant number from invoice_sequences (reusing the existing allocator), builds one time_entry invoice line per entry (quantity = duration_minutes/60, unit_price = hourly_rate), inserts the invoice, and marks those entries billing_status='billed' with invoice_id set. Exposed as POST /api/v1/invoices/from-time-entries (RequireFinance). All money uses rust_decimal.

Integration tests in tests/billing.rs cover invoice generation (gapless number, one line per entry, entries flipped to billed and linked) and recording a payment transitioning the invoice to paid.

Recurring contract-item billing depends on PMS-64 and audit hooks on PMS-117; both land once those merge.

#PMS-33

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merge branch 'main' into feat/pms-33-billing
All checks were successful
Create release / Create release from merged PR (pull_request) Has been skipped
Check / fmt + clippy + compile + tests (pull_request) Successful in 1m16s
Build OCI container / Build and push mokosh-api image (push) Successful in 3m37s
c7884b18c8
vas2000-work deleted branch feat/pms-33-billing 2026-06-05 04:13:22 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!76
No description provided.