<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Om Lahore</title>
    <description>The latest articles on DEV Community by Om Lahore (@omlahore47).</description>
    <link>https://dev.to/omlahore47</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F99mvlsfu5tfj9m7ku25d.png</url>
      <title>DEV Community: Om Lahore</title>
      <link>https://dev.to/omlahore47</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omlahore47"/>
    <language>en</language>
    <item>
      <title>I built a GST invoice checker that runs on a laptop, and it caught its own AI's mistake</title>
      <dc:creator>Om Lahore</dc:creator>
      <pubDate>Sun, 18 Oct 2026 11:42:43 +0000</pubDate>
      <link>https://dev.to/omlahore47/i-built-a-gst-invoice-checker-that-runs-on-a-laptop-and-it-caught-its-own-ais-mistake-2pkl</link>
      <guid>https://dev.to/omlahore47/i-built-a-gst-invoice-checker-that-runs-on-a-laptop-and-it-caught-its-own-ais-mistake-2pkl</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week2-2026-10-12"&gt;Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;gstsort reads a folder of GST invoices, PDFs or phone photos, and tells you which ones you can claim input tax credit on and which ones you can't yet.&lt;/p&gt;

&lt;p&gt;Every Indian business registered for GST claims back the tax it paid on purchases, and the claim only holds if the invoice is right: the supplier's GSTIN is valid, it's billed to your GSTIN, the tax type matches the states involved, and the numbers add up. Freelancers and small agencies collect a pile of these every month and check them by hand, or pay their CA to, and a CA office does the same for dozens of clients. Those are the people who'd pay for this: the freelancer gets a clean sheet in a few minutes instead of an evening, and the CA office gets a first pass over every client's folder before anyone opens a PDF.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc2h2fm27mb5seb10stix.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc2h2fm27mb5seb10stix.jpg" alt="sample invoice, photographed at an angle" width="800" height="1001"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;I ran it on ten sample invoices with made-up suppliers. Six of them have a problem planted in them, and it found all six:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqtqiw9lvx77wahaihfwq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqtqiw9lvx77wahaihfwq.png" alt="gstsort output on the ten sample invoices" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All ten took about two minutes on a laptop with 16 GB of RAM, 12 to 16 seconds an invoice, with nothing going over the network.&lt;/p&gt;

&lt;p&gt;One catch wasn't planted. On the Inkwell invoice the model read the GSTIN 27ABZPI9054E1Z4 as 27ABZP19054E1Z4, an I turned into a 1. A wrong GSTIN in your purchase register won't reconcile with GSTR-2B, and that's credit you don't get. A GSTIN has a check digit, and the PAN inside it has letters and digits in fixed slots, so gstsort put an I back in the slot that has to be a letter, recomputed the check digit, saw it match, and fixed it. When a fix doesn't make the check digit agree, like the Lensbox invoice where the GSTIN printed on the invoice itself is wrong, it leaves it alone and flags it for a human.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/omlahore" rel="noopener noreferrer"&gt;
        omlahore
      &lt;/a&gt; / &lt;a href="https://github.com/omlahore/gstsort" rel="noopener noreferrer"&gt;
        gstsort
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Check GST invoices for input tax credit problems with a local vision model
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;gstsort&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;Point it at a folder of GST invoices (PDFs or phone photos) and it gives you a CSV of everything on them, plus a list of the ones you shouldn't claim input tax credit on yet. A local open-weight vision model reads the invoices, so they never leave your machine.&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/omlahore/gstsort/docs/run.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fomlahore%2Fgstsort%2FHEAD%2Fdocs%2Frun.png" alt="gstsort output on the ten sample invoices"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;$ gstsort -gstin 27AKXPS4821M1Z7 samples/
...
06-typo-gstin.pdf (Lensbox Camera Rentals LB-26-0391)
  - supplier GSTIN "27AAKFL4410C1ZQ" fails the checksum, recheck it on the invoice

07-total-mismatch.pdf (INKWELL STATIONERS IW-2207)
  - taxable 1580.00 + tax 284.40 + cess 0.00 doesn't add up to total 1964.40 (off by -100.00)
  ~ read supplier GSTIN as 27ABZP19054E1Z4, fixed to 27ABZPI9054E1Z4 (checksum confirms)
...
10 invoices, 4 clean. Input tax credit ready to claim: ₹3437.82. Held back for review: ₹2406.56
Wrote invoices.csv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;What it checks&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;The model only reads. Everything after that is plain code:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GSTIN format and the mod-36 check digit. A misread look-alike (an…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/omlahore/gstsort" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;The model is Qwen2.5-VL-7B-Instruct, an open-weight vision model, quantized to 4 bits (Q4_K_M GGUF) and served by llama.cpp's llama-server on localhost. The CLI is about 400 lines of Go.&lt;/p&gt;

&lt;p&gt;For each invoice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PDFs get rendered to PNG with pdftoppm, and phone photos get scaled down so the long side is 1400 px. A 4000 px photo blows past the context window of a 7B vision model.&lt;/li&gt;
&lt;li&gt;The image goes to llama-server's OpenAI-compatible endpoint with a JSON schema in &lt;code&gt;response_format&lt;/code&gt;. llama.cpp turns that schema into a grammar, so the model can only produce valid JSON with the fields I asked for: GSTINs, invoice number, date, taxable value, CGST, SGST, IGST, cess, total and the HSN/SAC codes.&lt;/li&gt;
&lt;li&gt;Everything after that is plain Go. The model reads the invoice and never decides whether a credit is claimable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GSTIN format and the mod-36 check digit, with the look-alike repair above&lt;/li&gt;
&lt;li&gt;billed to your GSTIN, and no buyer GSTIN means it's a B2C bill with no credit&lt;/li&gt;
&lt;li&gt;same state means CGST + SGST, different states means IGST&lt;/li&gt;
&lt;li&gt;CGST equals SGST, the effective rate is a real GST slab, and taxable + tax + cess equals the total&lt;/li&gt;
&lt;li&gt;restaurant services (SAC 99633x), which are usually blocked credit under section 17(5)&lt;/li&gt;
&lt;li&gt;the same supplier and invoice number showing up twice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The output is a CSV with every field, the credit you can claim on each invoice, and the reason for anything held back. Place-of-supply edge cases like a hotel stay in another state still need a human, and the README says so.&lt;/p&gt;

&lt;p&gt;I tried letting the model pick an expense category too. It labeled almost everything "travel", including a broadband bill. So that field went, and the food check reads the SAC code instead, which is printed on the invoice and doesn't need guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;Invoices are other people's financial data. A CA office holds them for dozens of clients and has every reason not to upload them to someone else's API. With an open-weight model on llama.cpp nothing leaves the machine, it works with the internet off, and there's no per-page API bill, so running a whole year of invoices through it is fine.&lt;/p&gt;

&lt;p&gt;Running the inference server myself also means I control the decoding. The JSON schema is enforced as a grammar while the model generates, so I never parse free text and hope. When a better open vision model comes out, I point llama-server at it and nothing else changes.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>ai</category>
      <category>go</category>
    </item>
  </channel>
</rss>
