Improve transactionality, align invoice model with frontend

This commit is contained in:
Jon Staab
2026-05-29 13:37:11 -07:00
parent ae3e1c316e
commit 0018a5d4f3
12 changed files with 305 additions and 309 deletions
+14 -4
View File
@@ -106,12 +106,22 @@ export type Tenant = {
export type Invoice = {
id: string
customer: string
status: string
amount_due: number
currency: string
tenant_pubkey: string
amount: number
period_start: number
period_end: number
created_at: number
paid_at: number | null
voided_at: number | null
}
// The backend models an invoice's lifecycle as timestamps rather than a status
// field, so derive the display status from them: paid once paid_at is set, void
// once voided_at is set, otherwise still open.
export function invoiceStatus(invoice: Pick<Invoice, "paid_at" | "voided_at">): "open" | "paid" | "void" {
if (invoice.paid_at != null) return "paid"
if (invoice.voided_at != null) return "void"
return "open"
}
export type Activity = {