---
title: "Invoicing records"
description: "Understand the records the API keeps beside the invoices it files, such as number series, drafts, reminders and recurring invoices."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.certinvo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoicing records

Certinvo keeps the records an invoicing app needs beside the invoices it files: number series, drafts, a
catalogue, payment methods, a short profile, reminders and recurring invoices. They live in the API's database,
one set per company, because they need a counter, a clock and email. The engine reads one invoice and nothing else.
The API routes are listed under [Invoicing](/reference/api/invoicing). The console's screens for them are
described under [In the console](#in-the-console).

## Who may change what

Every record belongs to one company. Row security in the database stops any other company from reading or changing
it, as for every company table.

- Any credential may read the records, write drafts and products, take numbers, send reminders and
  prepare recurring invoices.
- Only a signed-in person may change a number series pattern, a payment method or the invoicing profile. A key
  that leaked must not be able to renumber invoices or send payments to another account.

## Number series

A company has five series: `invoice`, `credit-note`, `correction`, `quote` and `proforma`. Each has a pattern
such as `RE-{YYYY}-{0000}`: text, the year, and one counter whose zeros set its width. A pattern with a year
starts again at 1 in a new year.

`POST /v1/number-series/{kind}/allocations` takes the next free number. It locks the series row while it works,
so two requests at the same moment never get the same number. It skips any number that an invoice this company
issued already carries, for example one typed by hand.

The answer also carries `issueDate`: the company's day that the number's year was counted in. Date the invoice by
it, so the number and its date never fall on two sides of midnight. The day is read in the company's time zone,
which is `Europe/Berlin` unless the company holds another.

`GET /v1/invoice-numbers?number=` says whether an issued invoice already carries a number, which invoices do,
and the next free number. The create form uses it to warn about a used number.

## Drafts

A draft is an invoice being written. It holds the canonical invoice as far as it is written and the form's own
settings, as JSON of at most 1 MiB. Nothing checks a draft's content: the validator checks the invoice when it
is filed. The list shows a title made from the buyer's name and the invoice number.

Each save counts the draft's `revision` up by one. A save with `PUT /v1/drafts/{id}` may name the revision it
changes in an `If-Match` header, such as `"3"`. When the draft was saved since, nothing is saved and the answer is
409 `draft_changed`. Without the header, the save replaces whatever is there. The create form sends the revision it last
opened or saved, and the console passes the header on to the API.

A quote and a pro forma are drafts with that `kind`. They are never sent as e-invoices.

A pro forma carries type code 325. It is a business document that claims no payment, so Certinvo makes it as a PDF
only, with `POST /v1/business-documents`. A conversion or a new version with type code 325 is refused with
`not_an_invoice`. Today 325 is the only type code made as a business document; every other type code is an invoice.

## Follow-ups and final invoices

`POST /v1/invoices/{id}/follow-ups` makes a new draft from an invoice the company issued:

- `copy`: type 380, a suggested number, the company's day as its date and the same payment period. The delivery date and every
  period are cleared.
- `correction`: type 384, with the invoice as its preceding invoice (BT-25 and BT-26).
- `credit`: a credit note, type 381, with the invoice as its preceding invoice. Its amounts stay positive.
- `next`: the same type, with every period and the delivery date moved one interval on. A last day of a month
  stays the last day of the month.

What was paid on one invoice is never paid on another. A copy, the next invoice and a credit note carry no paid amount
(BT-113), no advance payment and none of the notes a final invoice lists its down payments in, and their amount due
is the whole total again. A correction replaces the same invoice, so it keeps what was paid on it.

The draft's `settings.numberSeries` names the series its number comes from. The number in the draft is a
suggestion. It is taken only when the invoice is filed.

`GET /v1/down-payments?reference=` lists the down payment invoices (type 326, 386 or 875) whose contract or
order reference is the one given. `POST /v1/final-invoices` makes a final invoice draft of type 380, or 877 for
construction work. It deducts only down payments marked paid: a final invoice deducts the part payments
received and their tax (UStG § 14(5)). Without `downPaymentIds` it takes every paid down payment of the reference. When
none is paid, or one it names is not, the answer is 409 `down_payment_not_received` and no draft is made. Each down
payment deducted becomes a preceding invoice and a note line with its net amount, VAT and gross amount. Their gross sum is the paid amount (BT-113), which the amount due subtracts. The invoice model has
no field of its own for a deduction, so these are the fields that carry it.

Both routes accept an `Idempotency-Key` header. A repeat with the same key and body answers the draft the first one
made, as it is now, and makes no second draft. The same key with another body is 409 `idempotency_key_reused`, and
while the first is still being done it is 409 `request_in_progress`.

## Payment methods and the profile

A company has several payment methods and one default. Each answers with the payment means of the invoice model
it fills in (BG-16), so the form copies it as it is. An IBAN is refused when its check digits do not match. A
SEPA direct debit names the creditor id, and the mandate and debited account when the method is one buyer's.

The invoicing profile holds five answers: small business or not, who the company mostly invoices, net or gross
prices, construction work or not, and 7, 14 or 30 days to pay. The answer about customers names the files a new
invoice is made as: the default for that buyer type, by the same rule the check reads (`filesToMake`), so the
Factur-X PDF for business and consumer customers and XRechnung for public ones. The profile ticks no file on the
form: a tick is a choice, and the files stay the API's plan for the buyer.

## Payment status

An invoice is `paid` when its history holds `api:paid`. Otherwise it is `overdue` when the later of its due date
and its newest reminder's due date is before today, and `open` in every other case. The status is worked out
each time it is read and is never stored.

Two kinds of document ask nobody for payment:

- An invoice whose newest check the validator rejected has no payment status. The API answers `paymentStatus` as null.
- A credit note owes the buyer. It is `open` until it is marked paid, and it is never `overdue`.

A credit note is a document whose type code (BT-3) is a credit note's in the UNTDID 1001 code list, such as `381`.
Certinvo's list of document types marks each of them as claiming no payment. The API keeps each document's type code as it files it,
and answers it as `typeCode` in the invoice list and on each invoice. `GET /v1/invoices?status=overdue` lists the overdue ones, and
`POST /v1/invoice-events` marks many invoices paid in one call, and a paid file at `/v1/data-files/payments` marks them by invoice number and day.

Today is the date in Berlin, read by the API. Tests set the date themselves.

## Reminders

A reminder has a level: 0 is a payment reminder, 1 the first notice and 2 the second notice. A level comes only
after the one before it, and a paid invoice gets none. A version an edit replaced gets none either
(`invoice_replaced`): the reminder would ask for its old amount. A credit note and an invoice the validator rejected
get none, because they ask nobody for payment. The API refuses a reminder for them with 409 `not_payable`, and
lists their next level as null. Each reminder sets a new due date, 10 days
from today unless one is given, and may add a fee.

With an email address, the reminder is sent through the email provider as plain text in German or English
before it is recorded. If the provider refuses it, nothing is recorded. Each reminder also carries its content
as data (`document`), so a printed reminder can be made from it.

## How a total counts a document

Every total the console adds counts each document by one rule, in `sums.ts`:

- An invoice counts plus.
- A credit note counts minus. An invoice of 1,000.00 and its credit note of 1,000.00 add up to 0.00.
- A document whose newest check the validator rejected counts not at all.
- A document with no readable amount is left out. It is never counted as zero.
- A correction (type code 384) is the same invoice again. One that states the full amount replaces the invoice it
  names as preceding (BT-25): that invoice counts no longer. One with minus amounts counts as it is, so it nets against
  the invoice. One the validator rejected replaces nothing.

Which type codes are credit notes is one list. It holds exactly the codes the EN 16931 rules let a credit note carry
(BR-CL-01), 458, a bank's reversal of a credit, among them.

Amounts are added as exact decimals, never as floating point numbers. A total keeps every decimal place any of its
amounts has, and at least two.

The rule decides these numbers:

- The buyer page's figures: open, overdue and invoiced this year.
- The amount column of the invoice lists, its sort and the batch total under it. A credit note's amount shows with a
  minus.
- The totals per currency on Analytics. They add the invoices whose issue date (BT-2) falls in the period. The
  counts beside them are still the documents filed in the period.

## Recurring invoices

A recurring invoice repeats an issued invoice or a draft every month, quarter, half year or year.
`GET /v1/recurring-invoices?due=true` lists the ones due today or before.
`POST /v1/recurring-invoices/{id}/drafts` prepares the next invoice as a draft and moves the due date one
interval on. Nothing is filed or sent automatically.

## Bookkeeping export

The DATEV export books invoices by their invoice date, whatever their payment status. So it has no status
filter. A list filtered by status still offers each invoice's DATEV download.

## In the console

The console reads and saves every record through its own forwarders, which pass the signed-in person's session
on as the bearer (`api-forward.ts`, and `payment-status.server.ts` for the payment status). A forwarder passes on
the `Idempotency-Key` header when the screen sent one. Under the development switch `CVO_DEV_AUTH=1` there is no session, and they
send a local API key from the `cvo_dev_key` cookie instead, when one is set. The API checks each value. When it refuses one, a screen says
why in the console's language, chosen by the refusal's code, and computes no status of its own. Every invoice field a form names is named by its official label
through one function, `officialLabel()` in `bt-dictionary.ts`, as every console screen does. A table's column headings may be plain words instead: the bank accounts' table reads Name, Type, IBAN and BIC.

- **Settings, Invoices.** Two pages follow the layout, before Email sending:
- **Numbering**: one pattern per kind of document, with a preview of the next number while it is typed.
    The next free number shown after saving is the API's.
- **Defaults**: the five questions, and the file new invoices are made as.
- **Products** (`/products`, the second page under the Data manager): the catalogue as a table titled **All products**, its search (the
  API's) at the right of the title, with **Import and export** and **Add item** on top right. **Import and export** downloads the products or a sample as CSV, Excel or JSON, and imports a file after showing what it would change. A row opens the item's own page (`?open=<id>`, or `?open=new` for a new one), its fields on a Settings card
  (each a row, its name on the left), with **Save** and **Delete**. Saving returns to the list. Unit and VAT category are picked from the official code lists, and the table names them, as the create form does.
- **Settings, Company.** **Bank accounts** sits after Company details, Locations and Validation policy: a table of the payment methods with the default
  marked. A dialog adds or changes one. The old link `/settings?tab=payments` opens it there.
- **The five questions** are asked in Settings → Invoices → Defaults only. Home and the invoice lists never show
  them.
- **Buyers.** The Buyers page (`/customers`, the first page under the Data manager) is a table titled **All buyers**, its search at the right of the
  title, with **Add buyer** on top right. A row opens the customer's own page (`?open=<n>`, or `?open=new` for a new
  one). The page shows four figures: open, overdue and invoiced this year, each a sum in one currency with its number
  of invoices under it, and how many were rejected. A credit note counts minus in each sum, and a rejected invoice
  counts only in the number rejected (see [How a total counts a document](#how-a-total-counts-a-document)). Under them are the invoices we sent the customer with their payment and validation, found by
  the API's own search on the customer's name (every page of it) and filtered by All, Open, Paid and Issues, and its
  details and its files on cards beside them. **Edit**, on top or on either card, opens its fields in a drawer, where it is saved or removed; **New invoice** opens the
  create form with this customer picked (`/invoices/neu?customer=<id>`). The API keeps the list
  whole, so every save sends every customer. Each customer also holds its VAT ID, address and contact. The establishment
  country and the address country are picked from the official country list and stored as the two-letter code. A
  stored value that is no code is shown as an error on that buyer, kept on screen and left out of the save, so the
  other buyers still save. A refused list is said in the console's words; when two buyers share an id, or a delivery names a file the buyer does not need, it names that buyer and the field.
- **The outbound list.** Each invoice shows open, overdue or paid. A rejected invoice shows a dash. Ausgang's filter tabs are **All**, **Action
  required**, **Open**, **Overdue**, **Paid** and **Not accepted**, the files dropped in SFTP's `outgoing/` that
  never became an invoice. A payment tab asks the API for one status (`status=`), and the
  list then shows the API's page of those invoices. Without one, the page reads the status of the rows on screen
  from the API, up to ten pages of 200. Ticked invoices are marked paid with one report, from the bar that takes the tabs' place while rows are ticked
  (`POST /v1/invoice-events`, code `api:paid`).
- **Payment.** The invoice page of a sent invoice has a tab named **Payment**. Its first card holds the payment
  status and three actions on one line: **Payment reminder**, **Recurring** and **Final invoice**. A version an edit
  replaced has no **Payment reminder**. On a credit note, a rejected invoice or a paid invoice, **Payment reminder**
  cannot be pressed. Its second card
  holds the follow-ups **Copy**, **Corrected invoice** and **Credit note**, each description beside its button:
- **Copy**, **Corrected invoice** and **Credit note** each make a draft through the API, then open it. Each press
    sends an `Idempotency-Key`. A press again after no answer carries the same key, so it opens the first draft.
- **Payment reminder** shows the next level and lets the person pick another. The API refuses a level out of
    order, and the dialog says so. A fee, a new due date (typed, or picked from the kit's calendar), an email address and
    the language are optional. After sending, the dialog shows the letter as the API wrote it.
- **Recurring** sets the interval and the first due day.
  - A corrected invoice, or a newer version of an invoice, has a third card, **DATEV**. It names the invoice it
    corrects and where that went to DATEV, offers the class its changes show or higher, and says what the next
    export books. An invoice that corrects nothing shows no card.

- **Final invoice** appears when the invoice has a contract or order reference. It lists the down payments the
    API found for that reference, each paid one marked so, and makes the final invoice draft from the ones ticked. A
    ticked one that is not paid is refused, and the dialog says to mark it paid first or leave it out. It sends an
    `Idempotency-Key` in the same way.
- **Drafts.** `/invoices/drafts` is the Studio's Drafts screen. Invoices are listed only in Eingang and
  Ausgang, so it lists no invoice. **New invoice** on top right opens the create form. It shows two tables, one under
  the other, each with its one line beside its title. Delete, in a row, asks once in that row before it deletes:
- **Drafts** lists the drafts. A draft continues at `/invoices/neu?draft=<id>`, where the create form loads it.
- **Recurring** lists the recurring invoices, each with its status (active, due or paused) last. A due one says
    whether it is due today or since which day, by the day in Berlin. "Prepare next"
    makes the next one as a draft and opens it the same way. `?tab=recurring` scrolls to this table.
- **The old Manage address.** `/invoices/manage` sends each of its tabs where it went: Open, Overdue and Paid to
  Ausgang with that status, All to Ausgang, Drafts and Recurring to the Drafts screen. An address naming no tab
  opens Ausgang on Open, as Manage did.

## See also

- [Find and export invoices](/how-to/invoices/find-and-export-invoices): the list's filters, payment status included.
- [API error codes](/reference/api-error-codes): every refusal these routes answer.

Source: https://docs.certinvo.com/explanation/invoicing-records/index.mdx
