Invoice numbering

Invoice numbers are accounting records. This page explains exactly how they are issued and why they can never be duplicated.

When is a number issued?

Only when an invoice is first needed, and only for orders with an allowed status:

Customers never trigger a number: they can only download invoices that already exist. Previews never issue a number.

How duplicates are prevented

  1. Every issued number is a row in the invoice register (its own database table).
  2. Issuing runs in a database transaction that first locks the number sequence, so simultaneous requests (for example an email and an admin click at the same moment) wait for each other.
  3. Inside the lock the plugin checks again whether the order already has an invoice, then saves the invoice and increases the counter in the same transaction.
  4. Unique database keys guarantee that a number exists only once and that an order gets only one invoice.

We tested this with 12 processes issuing invoices for the same orders at the same time: every order got exactly one number, with no duplicates and no gaps.

Numbers never change

The number and the invoice date are fixed when the invoice is issued. Changing the prefix, suffix or date format later only affects new invoices. If creating a PDF fails, the order keeps its number and the next attempt uses the same one.

Gaps

Numbers are never re-used. A gap appears only when you move the next number forward or when an order with an invoice was deleted — the Invoice Register still lists that number with "order deleted".

Changing the next number

The Next invoice number can only be set higher than every number already issued. Use it to continue the sequence of a previous system.

Refunds and cancellations

An issued invoice keeps its number, date and original total. Refunds are listed below the total together with the net amount. Credit notes for refunds are available in the Pro add-on.