Modules

Invoices

Receivables with aging, overdue reminders, partial payments, a quick view and a live invoice editor.

composables/useInvoices.ts
View in the demo

The stored state is draft, sent or paid. invoiceStatus() derives pending, partial and overdue from the due date and the payments. Only drafts can be edited; /billing/invoices/new creates one.

Files

File
Role
pages/billing/invoices/index.vueThe list with the receivables card.
pages/billing/invoices/[id].vueThe editor with a live preview.
composables/useInvoices.tssave, setState, remind, recordPayment, markPaid, duplicate, remove and the known clients.
types/models/invoices.tsInvoices, lines and payments.
config/invoices.config.tsViews, aging buckets, terms, tax and discount rates and payment methods.
utils/invoices.tsPure rules, unit tested.
components/pages/billing/InvoiceDocument, InvoiceQuickView, InvoiceReceivablesCard, InvoicePaymentDialog.

Data

useInvoices() loads its data through a InvoicesProvider (types/models/invoices.ts); the demo uses createInvoicesMockProvider(). Write a provider that calls your API and make it the default: the pages do not change. See Connect your API.

Permissions

The list and the editor need invoices.view.

Configuration

INVOICE_VIEWS

The views of the list.

config/invoices.config.ts
const INVOICE_VIEWS: InvoiceView[]

INVOICE_AGING_BUCKETS

The aging buckets of the receivables bar.

config/invoices.config.ts
const INVOICE_AGING_BUCKETS: InvoiceAgingBucket[]

INVOICE_PAYMENT_TERMS

Payment terms in days.

config/invoices.config.ts
const INVOICE_PAYMENT_TERMS: number[]

INVOICE_TAX_RATES

The tax rates of the editor.

config/invoices.config.ts
const INVOICE_TAX_RATES: number[]

INVOICE_DISCOUNT_RATES

The discount rates of the editor.

config/invoices.config.ts
const INVOICE_DISCOUNT_RATES: number[]

INVOICE_PAYMENT_METHODS

Payment methods for recording a payment.

config/invoices.config.ts
const INVOICE_PAYMENT_METHODS: InvoicePaymentMethod[]

Rules

Pure functions in utils/, unit tested in tests/unit/. Statuses and segments are derived from the stored data, never stored themselves.

invoiceTotals()

Totals; the discount applies before VAT.

utils/invoices.ts
invoiceTotals(invoice: Pick<Invoice, 'lines' | 'taxRate' | 'discountRate'>): InvoiceTotals
Returnssubtotaldiscounttaxtotal

invoiceStatus()

The derived status.

utils/invoices.ts
invoiceStatus(invoice: Invoice, now: Date): InvoiceStatus

invoiceBalance()

The amount due.

utils/invoices.ts
invoiceBalance(invoice: Invoice): number

invoiceAging()

Outstanding by bucket.

utils/invoices.ts
invoiceAging(invoices: Invoice[], now: Date): { buckets: Record<InvoiceAgingBucket, number>; count: number; total: number; }
Returnsbucketscounttotal

averageCollectionDays()

Average days to collect.

utils/invoices.ts
averageCollectionDays(invoices: Invoice[]): number | undefined

How it works

  • A receivables card replaces KPI cards: outstanding total, collected this month, an aging bar and a v-list legend whose items filter the table.
  • An overdue BaseAlert offers “show” and “send reminders”.
  • A row click opens InvoiceQuickView: amount due, InvoiceDocument, the BaseTimeline history, reminder, payment (a BaseFormPanel + BaseForm dialog), Download PDF (the print() of BaseDocument, which opens the print dialog with only the invoice), duplicate and delete.
  • The editor is a BaseDocumentEditor: a plain v-form with Base* inputs next to a live InvoiceDocument preview (which only maps the invoice onto BaseDocument), in four numbered sections (BaseSectionTitle): client, dates and terms (the due date is a sentence computed from the payment terms), items with unlimited lines and a totals block where discount and VAT are picked next to their amounts, and the note. The validation message disappears as soon as the form is valid.
© 2026 melsami UI.
Developer documentation for melsami UI.