DEV Community

taxgarden
taxgarden

Posted on

Validating GST Invoice Numbers: The 16-Character Rule That Breaks Imports

If you build billing or ERP software for Indian businesses, one small piece of GST law causes a surprising number of rejected uploads: the invoice number format.

Rule 46 of the CGST Rules says an invoice needs a consecutive serial number of not more than 16 characters, in one or multiple series, using alphabets, numerals, and only hyphen and slash as special characters. That's all. Underscores, spaces and dots are out, and 17 characters is out.

A plain check:

```python import re INVOICE_NO = re.compile(r"^[A-Za-z0-9/-]{1,16}$")

def valid_invoice_no(s: str) -> bool: return bool(INVOICE_NO.match(s))

assert valid_invoice_no("INV/2026-27/00042") assert not valid_invoice_no("INV_2026_27_000042") assert not valid_invoice_no("FY2026-27/INV/0000042") # 21 chars ```

The classic trap is a financial-year prefix plus a long counter. "FY2026-27/INV/0000042" is a perfectly natural thing to generate and it is over the limit. Decide on a short series prefix early, because changing the numbering scheme mid-year breaks the "consecutive" requirement.

A few other constraints worth encoding while you're there:

B2C invoice to an unregistered customer of Rs 50,000 or more: customer name, address, delivery address, state name and code are mandatory. Below that, they're optional.
HSN: 4 digits on B2B invoices for businesses up to Rs 5 crore turnover in the previous year, 6 digits above that.
Sales below Rs 200 to an unregistered customer who doesn't ask for an invoice can be covered by a consolidated invoice at the end of the day.
E-invoices don't need a signature, because the IRP signs them and adds the QR code. Ordinary PDF invoices do.
Validation at entry time is much cheaper than fixing a GSTR-1 after the fact. The full field list and edge cases are in this GST invoice format and mandatory fields reference, which I keep open when writing tests.

Top comments (0)