Most people treat invoice numbers as labels. They are not. In most tax regimes the sequence itself has to hold up: no gaps, no duplicates, per series and per period. That gets uncomfortable the moment two orders are paid in the same second and both ask for the next number.
We wrote up how we keep that counter honest under real traffic, and why the accounting rules decide what goes on the invoice while the sequence decides whether it counts at all: https://shipmindlabs.com/c/0ed96d4b
Explaining a missing invoice number to an accountant is probably not a conversation you want to have.