Skip to main content

Module db

Module db 

Source

Structs§

Client
Invoice
InvoiceItem
Issuer
Product

Functions§

client_by_slug
client_create
client_delete
client_list
client_update
Full-replace UPDATE. Matches by slug.
invoice_create
invoice_delete
Delete an invoice by number. Refuses non-draft invoices unless force. Deleting a non-draft invoice breaks the numbering sequence — which is a regulatory problem in many jurisdictions. Forcing should be deliberate.
invoice_get
invoice_item_add
Append an item to a draft invoice. Fails if the invoice isn’t draft.
invoice_item_edit
Replace the item at position with item’s fields. Draft-only.
invoice_item_remove
Remove the item at position from a draft invoice; re-compacts trailing positions so there are no holes.
invoice_list
invoice_set_status
Update status and, on first transition into issued / paid, stamp the corresponding timestamp column. Idempotent — re-marking doesn’t overwrite the original timestamp.
invoice_update_draft
Draft-only metadata edit. Rejects edits to issued / paid / void invoices — the correct path for those is a credit note.
issuer_by_slug
issuer_create
issuer_delete
issuer_list
issuer_update
Full-replace UPDATE. Matches by slug (PK-like). Slug itself cannot change.
next_invoice_number
Generate the next document number for an issuer/year/kind combination. kind is typically “invoice” or “credit_note” — credit notes get an independent sequence and are formatted with a “CN-” prefix.
open
open_at
product_by_slug
product_create
product_delete
product_list
product_update
Full-replace UPDATE. Matches by slug.