Skip to main content

Invoices

Invoices represent charges sent to customers. Each invoice contains line items detailing the products and amounts charged.

Invoice Statuses​

draft β†’ open β†’ paid
↓ ↓
void uncollectible
StatusDescription
draftDraft. Can be edited, items can be added/removed
openFinalized. Chargeable, can receive payments and have credits applied
paidFully paid
voidVoided. Applied credits are restored, installments canceled
uncollectibleMarked as uncollectible (write-off)

Invoice Fields​

Identification​

FieldDescription
NumberUnique sequential number (format: INV-YYYY-NNNNNN)
Billing accountCustomer who will receive the invoice
SubscriptionAssociated subscription (optional)
CompanyIssuing company (for multi-company setups)

Amounts (in BRL)​

FieldDescription
SubtotalSum of line items before discounts and taxes
DiscountTotal discount applied
TaxesTotal taxes calculated
Total withheldWithheld taxes (PIS/COFINS/IRPJ)
Net amountNet amount after withholdings
TotalFinal amount (subtotal - discount + taxes)
Amount dueTotal amount payable
Amount paidAmount already received
Amount remainingOutstanding balance

Configuration​

FieldDescription
Collection methodcharge_automatically, manual_charge, or manual_invoice
Billing reasonsubscription_cycle, subscription_create, subscription_update, or manual
NF-e policydisabled, on_finalization, on_full_payment, or per_installment
Due dateCalculated from the customer's payment term days

Line Items​

Each invoice contains line items that detail the charges:

FieldDescription
Typesubscription or invoiceitem
DescriptionDescriptive text
QuantityQuantity charged
Unit amountPrice per unit
Total amountQuantity Γ— unit amount
ProrationWhether the item is a prorated charge
PeriodStart and end of the billed period

Operations​

Create Invoice​

When creating an invoice, provide:

  • Billing account (required)
  • Line items with description, quantity, and amount
  • Due date (or uses the customer's payment term days)
  • Installments (optional, minimum 2, sum must equal the total)
  • NF-e policy (optional)

The invoice number is automatically generated using PostgreSQL advisory locks to prevent duplication.

Edit Invoice​

draft and open invoices accept edits to every field. Once settled β€” paid, void or uncollectible β€” an invoice keeps its terms locked:

StatusEditable fields
draft, openAll
paidPublic ID, subscription, description, line items, metadata, external ID, NF-e issuance policy and NF-e description line
void, uncollectiblePublic ID, subscription, description, line items, metadata and external ID

Company, collection method, late-fee policy, due date, billing period and footer are locked. Line items can be corrected (through the API or with inline editing on the items tab, after a warning), but not while the invoice has an issued or in-flight NF-e β€” cancel it first. The rule applies to the dashboard, the API and MCP alike: changing a locked field returns 422 with code INVOICE_FIELD_LOCKED, listing the refused fields. Sending a locked field with the value already stored is not a change.

Finalize (draft β†’ open)​

When finalizing an invoice:

  1. Validates that at least 1 line item exists
  2. Validates that the sum of installments = total (if installment-based)
  3. Calculates taxes automatically
  4. Applies credits automatically (FIFO: earliest expiration first, then oldest)
  5. If collection method is charge_automatically: attempts to charge immediately

Mark as Paid​

  • Supports partial payments
  • When the full amount is received, the status changes to paid
  • Creates a transaction record

Void​

When voiding an invoice:

  • Applied credits are automatically restored
  • Pending installments are canceled
  • The void reason is stored

Undo Payment​

Reverts an invoice from paid to open:

  • Resets the paid amount to zero
  • Creates an adjustment transaction (negative amount)
  • Stores the reason in metadata

Mark as Uncollectible​

Marks the invoice as a write-off. Irreversible. No automatic payment attempts will be made.

Automatic Number Generation​

Invoice numbers are generated sequentially per year using PostgreSQL advisory locks. Format: INV-{year}-{6-digit sequence}.

Example: INV-2026-000147

Screenshots​

Invoice list​

The /dashboard/invoices screen lists all invoices with filters by status, billing account, issuing company, period and payment method. Each row shows number, customer, amount, due date, status and quick actions (download PDF, copy boleto/PIX, mark as paid).

Dashboard invoice list with filters and actions

Invoice detail​

The /dashboard/invoices/[id] page shows the complete invoice: items (with quantity and unit price), totals, discounts, credits applied, taxes withheld, payment history, linked NF-e and event timeline.

Invoice detail with items, totals and history