Skip to content

Why GST invoice extraction needs validation rules, not just a model

By Akshora AI Labs3 min read

  • Document AI
  • GST
  • Tally

Why invoices are hard to read reliably

Indian GST invoices come in thousands of layouts: different suppliers, languages, scanned copies, phone photos, multi-page tables and handwritten stamps. Transport documents such as lorry receipts (bilties) are even less standardised. Modern layout-aware models handle much of this, but they still misread characters, merge table rows or skip a field now and then.

For accounting, an occasional error is not acceptable. A wrong digit in a GSTIN or a shifted line item ends up in your books. The fix is not only a better model. It is a layer of checks that can show an extraction is consistent before it is used.

Layer 1: check identifiers and formats

Start with the fields that have a strict structure.

  • GSTIN: 15 characters. The first two digits are the state code, the next ten are the PAN, then an entity number, the letter Z and a final check character. A single misread character usually breaks the check character, so it is easy to catch.
  • PAN: five letters, four digits, then one letter.
  • Dates: parse to a real date and check that it falls in a plausible financial year (April to March).
  • Invoice numbers: check length and character rules per supplier where you know them.

Layer 2: check the tax logic

GST has rules that an extraction can be checked against.

  • Place of supply decides the tax split. For a supply within one state, tax is split into CGST and SGST. For a supply between states, it is IGST. The state codes in the GSTINs help confirm which one applies.
  • Tax amount should equal the taxable value multiplied by the rate, within a small rounding tolerance.
  • CGST and SGST amounts on a line should be equal.
  • The rate on a line should be a valid rate for that kind of item.

Layer 3: reconcile the totals

  • Quantity times rate, minus discount, should match each line amount.
  • Line amounts should add up to the taxable value.
  • Tax on the lines should add up to the tax totals.
  • Taxable value plus taxes, plus or minus round-off, should equal the grand total.

When every check passes, the invoice is internally consistent. That is much stronger evidence than a model's confidence score.

Route by validation, not by confidence alone

Use three outcomes for every document:

  1. All checks pass: post automatically and generate the voucher XML that Tally imports.
  2. A check fails: send it to a review queue with the failing field highlighted.
  3. The document is unreadable: reject it and ask for a better copy.

Where we use this

This is the approach behind our GST document AI work: fine-tuned extraction, a deterministic validation layer, and Tally Prime XML export, delivered as containers you own.

Related serviceDeterministic Document & GST AI

Quick answers

Is OCR alone safe for posting invoices to Tally?

Not on its own. OCR and layout models can misread characters or shift table rows. Add deterministic checks on GSTIN, tax split and totals, and send anything that fails to a person before it is exported to Tally.

How can a GSTIN be validated automatically?

A GSTIN has 15 characters with a fixed structure: state code, PAN, entity number, the letter Z and a check character. You can verify the format and recompute the check character, which catches most misread characters. It does not prove the business is active, which needs a lookup on the GST portal.

Want this built for you?

Tell us about your project. Founders and engineers reply directly.