Separate VAT and non-VAT invoice numbers, without renumbering anything
Many distributors run two invoice series — one for VAT sales, one for the rest. Getting a system to do that safely is less about the numbering and more about what happens on the day you switch it on.
Ask three distributors how they number invoices and you will get three answers. Some run a single sequence for everything. Some keep VAT and non-VAT sales on separate series, often with different prefixes and different padding, because that is how their accountants have always wanted it. Some are about to change because their circumstances have. All three are reasonable, and a system that assumes any one of them is wrong for the other two.
So in Nuga the numbering is configuration, not code. A company can run one series or two. Each series carries its own format, which sets the prefix and the zero padding together — so one can be five digits and the other four, which is what real series tend to look like once they have been running for years. The reference number printed on the invoice is configurable separately, because the format required on a VAT invoice is not necessarily the one a business wants on everything else.
The genuinely difficult part is not the numbering. It is switching it on at a company that is already trading. Splitting one sequence into two creates two new sequences, and unless they are told where to start, they start at one — which produces an invoice numbered 1 sitting alongside nine years of documents. It is the kind of mistake that cannot be tidied up afterwards, because by then the numbers are on paper in customers' hands.
We treat enabling the split as an operation rather than a setting. The system will not turn it on until it has been given a starting number for every branch, and it takes those numbers as part of the same action that flips the switch. It also refuses two formats that would produce the same text, because two series writing into one invoice-number field only stay distinct while their formats differ. Existing counters are never lowered, so running the change twice does nothing the second time.
That is more caution than a numbering feature usually gets. It is there because invoice numbers are one of the few things in a business system that genuinely cannot be corrected later, and the failure is silent until it is expensive.