Skip to content
Book a call

Invoice numbering: what the law allows, and what your system should refuse

· 5-minute read · Romanian compliance · by Direct Softworks

The law asks for one thing, a number in one or more series that identifies each invoice uniquely. Everything that goes wrong happens in the software around it.

Before our own invoicing went live, we deleted every test invoice from the production database. The next number the system offered was 001 again. Nobody had reset a counter. The series is worked out from the invoices that exist, so when none existed, it started over.

That was exactly what we wanted that day. On any later day it would have been a defect, and the difference is most of what there is to say about invoice numbering: the rule in the law is one line long, and almost everything that goes wrong happens in the software.

What the law actually says

The Fiscal Code (Law 227/2015, art. 319 alin. (20) lit. a)) lists the number first among the mandatory contents of an invoice: a sequential number, based on one or more series, that identifies the invoice uniquely. It prescribes no format and no prefix.

The accounting side adds the administrative part. OMFP 2634/2015, Annex 1, point 24, asks every entity to run an internal numbering regime: a written internal decision naming who allocates and manages the numbers, a sequential number or series on every document, and an internal procedure stating, for each financial year, the number or series from which the first document is issued.

Three things follow. You may run more than one series, and the order expects allocation to follow your branches and work points. You may start again each financial year, provided your procedure says so. And the texts do not talk about gaps at all: they ask for numbers that are sequential and unique. A missing number is exactly what an inspector would ask about, so a system should make gaps impossible or documented.

Check the current wording with ANAF and with your accountant rather than with a blog, including this one.

What the system has to refuse

Reuse. The tempting implementation counts the invoices and adds one. Ten invoices, delete the fourth, and the next is number ten again. Derive the next number from the highest one already issued in the series, and put a unique constraint on the column so the database refuses a duplicate even when two people press the button in the same second. In our panel the second press fails with an error and the person tries again, which is the right kind of failure.

Deletion. Even the maximum only works if issued invoices never disappear. Art. 330 sets out how an invoice is corrected: if it has not reached the customer, it is cancelled and a new one is issued; if it has, a new invoice reverses it with negative values and cites the number and date of the original. Art. 319 alin. (2) gives a document that modifies an invoice and refers to it unambiguously the same legal standing as an invoice. In software terms, cancelled is a status, not a DELETE, and a reversal takes the next number in the series and points back at the one it corrects. The application has no path that removes an invoice row, which is the only reason deriving the number from the rows is safe. Our purge was a one-off, run by hand, on test data.

Edits after issue. Art. 319 alin. (25) requires the integrity of an invoice's content from the moment it is issued to the end of its storage period, and defines integrity as the mandatory content not having been changed. An edit button on an issued invoice breaks that silently. Our panel has no action that changes an invoice's lines at all. A wrong draft is voided and keeps its number as a cancelled record; a wrong sent invoice is reversed.

Validate before you allocate

The quieter source of gaps is a number taken for a document that is then refused.

If an invoice can be blocked for a missing client address, a CUI that fails its check digit or a missing exchange rate, every one of those checks has to run before the number is assigned. Otherwise each refusal burns a number and leaves a hole with nothing behind it. Our invoice builder checks the client, the lines, the rate and the supplier's own details first, and only then asks for a number. A number should be the last thing a document receives, not the first.

The cheapest of those checks is validating a CUI before it reaches your database, which belongs at the keyboard as well.

Series, years and branches

One series per financial year is the simplest arrangement that satisfies all of this: the year in the number, a counter that starts at one when the year does, and the internal decision saying so. If your financial year differs from the calendar year, it is clearer for the number to follow the financial one.

Multiple series are legitimate, and sometimes necessary. Two rules keep them sane.

Each series is its own sequence. Store the series and the counter as separate fields rather than parsing them out of a formatted string. Parsing turns a typo in a prefix into a new series nobody decided to open, quietly starting at one.

Opening a series is an administrative act, not a preference. If anyone with a settings screen can add a series, the written decision the order asks for describes a system that does not exist. Make it a privileged action that leaves a log entry, so the paper and the configuration can be compared.

The general shape

The legal requirement fits in one line, and every failure mode belongs to the software: a count instead of a maximum, a delete instead of a status, an edit instead of a reversal, a number taken before the checks ran. None of them shows up in a demo, because a demo never deletes or refuses anything.

Same lesson as an audit log you can actually ask questions of: the correction for a wrong entry is a compensating entry, never an edit. An invoice register is the oldest version of that idea.

More from the blog