The invoicing module covers the full billing lifecycle. Invoices are created asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ency07/B2B/llms.txt
Use this file to discover all available pages before exploring further.
EMITIDA, updated as partial or full payments are recorded, and can be voided (ANULADA). Collection rate and overdue balances feed directly into the admin dashboard KPIs and the operations health billing score.
Invoice statuses
| Status | Description |
|---|---|
BORRADOR | Draft — created but not yet sent to the client |
EMITIDA | Issued and sent to the client |
PARCIALMENTE_PAGADA | Partial payment received; balance remains |
PAGADA | Fully paid |
ANULADA | Voided — excluded from all financial calculations |
getInvoices(tenantCode?) → invoice list
Returns all non-deleted invoices for the tenant ordered by created_at descending, joining the client’s legal_name:
createInvoice(tenantCode, invoiceData)
Requires the invoices.manage action permission. The invoice code is auto-generated as FAC-YYYY-NNNN (zero-padded to 4 digits) from a COUNT query on the tenant’s existing invoices. The due_date defaults to 30 days from the issue date.
legal_name lookup against clients scoped to the tenant. If no match is found, it falls back to the tenant’s first active client. The invoice is created with:
status: "EMITIDA"source_type: "CLIENT",source_id: clientIdsubtotal,total_amountset toamount;discount_amountandtax_amountboth0paid_amount: 0
Invoice line items
Each invoice created viacreateInvoice automatically gets one invoice_items row. Items can also be managed directly on the invoice_items table with the following fields:
| Field | Description |
|---|---|
line_number | Sequential line number (starts at 1) |
description | Line item description (the concept argument) |
quantity | Quantity (defaults to 1 for single-concept invoices) |
unit_price | Unit price in COP |
discount_amount | Line-level discount in COP |
tax_amount | Tax in COP |
line_total | (quantity × unit_price) − discount_amount + tax_amount |
KPI integration
totalInvoiced and totalPayments are computed via the calculate_kpi PostgreSQL RPC:
kpi_history table per tenant/period and fetched back via a join on kpi_definitions. These values populate DashboardCommandCenterData.kpis.totalInvoiced and .totalPayments, and drive the Facturación Emitida and Recaudo Cartera KPI cards in the admin/director dashboard view.
The billing health score is computed in JavaScript as:
totalPaid and totalBillingAmount exclude ANULADA invoices.