---
title: Finance sales invoices and credit memos
description: Invoice your customers from an entity. Drafts change freely; an issued invoice gets a gapless number, posts its journal and never changes. Correct it with a credit memo or void it, print it as a PDF, email it through Comms, and import a client's open invoices.
section: finance
order: 80
audience: [user, operator, agent]
sources: [services/nodejs-cloud/lib/finance/billing/invoices.ts, services/nodejs-cloud/lib/finance/billing/invoice-pure.ts, services/nodejs-cloud/lib/finance/billing/settings-pure.ts, services/nodejs-cloud/lib/finance/billing/delivery.ts, services/nodejs-cloud/lib/finance/billing/mcp.ts, services/nodejs-cloud/app/(finance)/finance/invoices, services/nodejs-cloud/app/(console)/(print)/finance/invoices/print, services/nodejs-cloud/migrations/0445_fin_sales_invoices.sql]
features: [cloud.page-finance, cloud.console-finance]
---

Sales invoices belong to the **Billing** module (`finance.billing`). An invoice goes from one of your
[entities](/docs/finance/reference-data.md#entities) to a customer: a [party](/docs/finance/parties.md) of kind customer, or both, that is the
entity's own or shared. Open them in **Finance > Invoices** (`/finance/invoices`). The list shows the newest first. You
can filter it by status (overdue included), customer, entity and issue dates, and the filters stay in the page's
address. Pick an invoice to open it beside the list. A customer's page in **Finance > Parties** lists that customer's
latest invoices too.

Billing is separate from the AI usage you resell to your own customers ([customer invoices](/docs/cloud/console-customers.md))
and from what you pay Petawork.

## Drafts {#drafts}

**New invoice** opens the editor (`/finance/invoices/edit`). Choose the entity and the customer, then add lines. Each
line has a description, a quantity (up to four decimal places), a unit price, an optional discount, a
[tax code](/docs/finance/reference-data.md#tax-codes), a revenue account and, optionally, [dimensions](/docs/finance/reference-data.md#dimensions) and a
service period. The currency and the payment terms start from the customer's. The due date is the issue date plus the
terms, unless you set one.

The editor works out each line and the totals as you type. Every amount is a whole number of the currency's minor
units, and each step rounds half up, line by line:

| Step | Amount |
|---|---|
| Gross | quantity × unit price |
| Discount | gross × discount % |
| Net | gross − discount |
| Tax | net × the tax code's rate |

The invoice's subtotal is the sum of the nets, its tax the sum of the taxes, and its total their sum. The total is never
rounded on its own, so every line can be checked by hand. A tax code of kind withholding is refused on a line: the
customer deducts withholding, you do not charge it.

A draft has no number. You can change anything on it, or void it to throw it away. The editor does not show a line's
service period, but it keeps it: a draft a [billing run](/docs/finance/subscriptions.md#billing-runs) or a [folio run](/docs/finance/folio-billing.md)
made still names each line's service dates after you change it.

## Issuing {#issue}

**Issue** does everything in one step, or nothing:

1. It checks the customer exists for the entity and is not blocked, that every line names an active income account and
   an active tax code that charges tax to an account, that the total is above zero, and that the entity names its
   receivable account ([settings](#settings)).
2. It prices the lines again at the tax codes' current rates.
3. It gives the invoice the entity's next number (`INV-000001` and up, or your prefix). Numbers come from the
   [gapless sequence](/docs/finance/audit-trail.md#numbers), taken inside the same step: if the issue fails, no number is used.
4. It freezes the invoice.
5. It proposes the invoice's [journal](/docs/finance/journals.md): the receivable account debited with the total, each line's income
   account credited with its net and each tax code's account credited with its tax. If the issue date falls in a locked
   period, the invoice keeps its date and the journal posts in the next open period, with a note on it.
6. It records the issue on the [event chain](/docs/finance/audit-trail.md).

The document language is the invoice's own when you set one, otherwise the language of the customer's first billing
contact that has one, otherwise English.

## Never edited {#frozen}

An issued invoice is never changed: not by the editor, not by any tool, and not in the database, which refuses to
change what an issued invoice says or to delete it. Only what happens to it afterwards moves: payments, credits, its
delivery status and the void. Deleting the organisation still deletes its invoices.

There are two ways to correct one:

- **Credit memo.** A credit memo goes against one issued invoice, with a reason. Credit the whole invoice in one go
  (when nothing was credited before), or give the lines it covers, each with its revenue account. A credit memo is
  never more than is left to credit: the invoice's total less its earlier credit memos. It takes its own gapless number
  (`CN-000001` and up, or your prefix), posts the mirror image of the invoice's journal, and is never changed either.
  The invoice's balance goes down by its total. Crediting the whole invoice uses the tax rates it was issued at, so the
  credit memo equals the invoice even when a tax code's rate changed or the code was retired since; a credit memo with
  its own lines uses the tax codes' current rates and only active codes. A credit memo is dated on or after the invoice's
  issue date (default today). See [credit memos on a paid invoice](#credit-memos) for what happens when it gives back
  more than the invoice has open.
- **Void.** You can void an issued invoice only while nothing has been paid or credited on it. The invoice keeps its
  number, which is never used again, and its journal is reversed with a reversing journal dated today (or voided, when it
  never became ready). Anything else is corrected with a credit memo.

### Credit memos on a paid invoice {#credit-memos}

A credit memo can give back more than the invoice still has open, for example when the invoice was paid in full or in
part. The part beyond the open balance is the customer's money. It becomes a **customer credit** in the same step as
the memo:

- An invoice of 100 paid in full, credited in full: a credit of 100.
- An invoice of 100 with 40 paid, credited in full: the memo clears the 60 open, and a credit of 40 is created.
- A memo within the open balance creates no credit.

The credit is linked to its memo (one credit per memo, so a retry never makes a second), shows on the customer's
[statement](/docs/finance/collections.md#statement) and in the credits list, and is applied to another invoice like a receipt's
surplus ([applying](/docs/finance/collections.md#apply)). It posts its own journal: debit the receivable, credit the entity's customer
credit account (`settings.collections.credit_account_id`, a liability), with the customer on both lines. The surplus
is counted once: it leaves receivables and sits in the credit account until it is applied.

A memo that would create a credit is refused until the entity has a customer credit account set; the refusal names the
setting. `finance_creditmemo_create` returns the credit as `customer_credit` (null when there is none).

**Memos made before this change have no credit.** Their surplus stays where their journal put it: a credit balance on
the customer in the receivables account. To find them, look for credit memos against invoices whose status is `paid`
or `partly_paid` and whose credited plus paid amount is more than the total, or for customers with a negative balance in
the receivables account. Move each one with a manual journal (debit receivables, credit the customer credit account,
with the customer on each line) if you want it to show as a credit.

## Overdue {#overdue}

Overdue is worked out every time an invoice is read, never stored. An invoice is overdue when it is issued or partly
paid, still has a balance, and today, in the entity's time zone, is after its due date. The list's **Overdue** filter and
each invoice's days overdue come from the same rule.

## PDF {#pdf}

**Print or PDF** opens the invoice laid out for A4 paper at `/finance/invoices/print?id=…`, in the customer's document
language. Use the browser's print dialog and choose **Save as PDF** to make the PDF. Petawork has no PDF library. The
page uses the entity's invoice settings: its logo, its legal name and tax ID, how to pay you, and its legal text. Once
something was paid or credited, the page and the email also show that amount and the balance due, which is the total
less what was paid and credited. A [write-off](/docs/finance/collections.md#write-offs) is your own entry: it does not lower the
balance due the customer sees, since a later payment reverses it.

## Sending {#send}

**Send** emails an issued invoice to each of the customer's billing contacts, in that contact's language, through your
organisation's own Comms email (a mailbox you connected in **Settings > Comms**, see
[Email from your mailbox](/docs/comms/email.md)). Comms email carries text only, so the email holds the invoice's number,
dates, lines, totals and how to pay. Send the PDF yourself when the customer needs one.

Each email is a delivery on the invoice: queued, sent or failed, with the reason when it failed. They are listed under
**Deliveries**.

If your organisation has no Comms email, nothing is sent and nothing is recorded. The answer says so and gives you the
print link. Finance never sends email any other way. A customer with no billing contact is refused with a note to add one.

## Importing open invoices {#import}

When a client moves to Finance, bring their open invoices with them: **Import open invoices (CSV)** at the bottom of the
list, or `finance_invoice_import`. Columns:

| Column | Required | What |
|---|---|---|
| `number` | yes | The invoice's original number, kept as it is |
| `customer` | yes | The customer's external reference, tax ID or exact name. It must match exactly one customer of the entity |
| `issue_date`, `due_date` | yes | `YYYY-MM-DD` |
| `currency` | yes | ISO 4217, like `SGD` |
| `total` | yes | The total in major units, like `1250.50` |
| `tax` | no | The tax within the total (default 0) |
| `open_amount` | no | What is still owed (default the total). Less than the total makes it partly paid |
| `po_reference`, `description` | no | Kept on the invoice |

The import is all or nothing. Every row is checked first, and one bad row imports none: each problem is listed with its
line. **Check** runs the checks without importing.

Imported invoices are created issued (or partly paid) and flagged **Imported**. They keep their original numbers in a
series of their own, so they never take a number from the gapless sequence. They **post no journal**: they are already in
the accounting system they came from. A number already imported for the entity is refused. A credit memo against an
imported invoice names its lines and accounts, and does post its own journal.

## Invoice settings {#settings}

Each entity's invoices use its settings' `billing` object. Set it in **Finance > Invoices > Invoice settings**
(`/finance/invoices/settings`), or with `finance_entity_update` (send the entity's whole `settings`). Changing it needs
what changing an entity needs: a controller, and `finance:admin` for an app.

| Field | What |
|---|---|
| `receivable_account_id` | The asset account issued invoices debit. Nothing is issued until it is set |
| `invoice_prefix`, `credit_prefix` | The numbers' prefixes (default `INV-` and `CN-`), up to 16 letters, digits, dashes, dots, slashes or underscores |
| `payment_details` | How to pay you: your entity's own bank details or instructions, as text, printed on every invoice and in every email. These are not a customer's bank accounts |
| `legal_text` | The legal footer |
| `logo` | A PNG, JPEG, GIF or WebP `data:` URL of at most 48,000 characters (about 35 KB). Its bytes must match its type. SVG is refused |

The tax ID printed is the entity's own (**Finance > Settings > Entities**).

## Who may do what {#roles}

| Action | Who |
|---|---|
| List and open invoices and credit memos | `billing.read`: an AR clerk, a controller, an auditor |
| Create, change, issue, void, credit, send, import | `billing.issue`: an AR clerk or a controller |
| Invoice settings | a controller with `finance:admin` |

A member scoped to some entities sees and invoices only from those. Another entity's invoice answers as if it did not
exist. With Billing off for the organisation, every page, tool and REST call answers `403 product_not_enabled`. Every
change is on the [event chain](/docs/finance/audit-trail.md): open an invoice's **History** to see it.

## Tools and API {#tools}

| Tool | REST | What it does |
|---|---|---|
| `finance_invoice_list` | `GET /api/v1/finance/invoices` | Filtered by `status` (`overdue` included), `entity_id`, `party_id`, `from`, `to` |
| `finance_invoice_get` | `GET /api/v1/finance/invoices/{id}` | One invoice with its lines, credit memos, deliveries and `print_url` |
| `finance_invoice_create` | `POST /api/v1/finance/invoices` | A draft: `entity_id`, `party_id`, optional dates, terms, currency, `po_reference`, `memo`, `language`, `lines` |
| `finance_invoice_update` | `PATCH /api/v1/finance/invoices/{id}` | Change a draft; `lines` replace its lines |
| `finance_invoice_issue` | `POST /api/v1/finance/invoices/{id}/issue` | Issue it, optional `issue_date` |
| `finance_invoice_void` | `POST /api/v1/finance/invoices/{id}/void` | Void with `reason` |
| `finance_invoice_send` | `POST /api/v1/finance/invoices/{id}/send` | Email it through Comms email |
| `finance_invoice_import` | `POST /api/v1/finance/invoices/import` | Import open invoices: `entity_id`, `csv`, `dry_run` |
| `finance_creditmemo_list` | `GET /api/v1/finance/credit-memos` | Filtered by `invoice_id`, `entity_id`, `party_id` |
| `finance_creditmemo_get` | `GET /api/v1/finance/credit-memos/{id}` | One credit memo with its lines |
| `finance_creditmemo_create` | `POST /api/v1/finance/credit-memos` | `invoice_id`, `reason`, optional `date` and `lines` |

Amounts are minor units, written as numbers or decimal text (`18000` is 180.00). A line's `unit_price_minor` is minor
units too; `quantity` is decimal text. Reading needs OAuth scope `finance:read`, every change `finance:write`.
