Skip to content

Invoice

An invoice records an amount billed to an organisation, its due date, its payment status and the PDF supplied to the client.

Invoices give clients a billing history inside the portal and give staff a place to track what has been paid. Each row carries a generated reference number, a monetary amount and currency, and an optional Attachment holding the invoice document.

Invoices are created by staff in the admin panel and read back on the support page.

  • app/Services/SupportDataService.php — loads an organisation’s invoices with their attachment for the support page.
  • app/Filament/Resources/InvoiceResource.php — staff create and edit invoices.
  • app/Filament/Resources/OrganizationResource/RelationManagers/InvoicesRelationManager.php — invoices listed on the organisation record.
  • app/Services/Voice/Tools/ListOrganizationFiles.php — surfaces invoice attachments to the voice agent.
Relation Type Related model
organization belongsTo Organization
attachment belongsTo Attachment

The inverses are Organization::invoices() and Attachment::invoices(), both hasMany.

Table: invoices.

Column Type Notes
id uuid Primary key
number string Unique, auto-generated INV-{year}-{nnn}
title string
amount decimal(10,2) Cast to decimal:2
currency char(3) Defaults to USD
due date Cast to date
status enum draft, pending, paid, overdue, cancelled
attachment_id uuid Nullable FK to attachments, null on delete
organization_id uuid FK to organizations, cascade delete
created_at, updated_at timestamp

The model adds paid, pending, overdue and forOrganization query scopes, an isOverdue() check, and the status_color and formatted_amount accessors.