Skip to content
MJ
← All work

Client engagement

Inventory & GST Billing System

Batch-tracked stock, purchasing, GST invoicing and receivables for a frozen seafood and meat supplier.

Discipline
Full-stack application
Built with
Next.js · TypeScript · PostgreSQL · Drizzle
Access
Private client application
Inventory & GST Billing System project screenshot
The stock screen running on demo data, with names changed. Client records and source code remain private.

01 / Context

The problem

A bulk seafood and meat supplier tracked stock, orders and prices in spreadsheets. Spreadsheets could not show which supplier a lot came from, which stock was close to expiry, or the true profit per kg once transport, loading and packing costs were added.

02 / The engagement

Scope & contribution

Designed and built the system end to end for International Ocean Foods: the data model, the stock and billing logic, owner and staff access, and the screens.

  • Batch and expiry tracking with first-expiry-first-out stock issue across two storage locations
  • Purchases with transport and packing costs folded into the landed cost per kg
  • Delivery challans, GST invoices, credit notes and monthly consolidated billing
  • Receivables, part payments and reports, including a GST working pack

03 / Under the surface

Implementation

Next.js and TypeScript on PostgreSQL through Drizzle. Stock is an append-only ledger, so quantity on hand is always derived from it. Documents are cancelled or reversed by credit note and never deleted. Money uses decimal arithmetic throughout.

Key engineering decisions

  • Stock is an append-only ledger with no stored balance. Quantity on hand is always summed from movements, so it cannot drift from what happened. Cancelling a document writes the exact negation of its rows.
  • Every sale line is stamped with the landed cost of the lot it came from, so profit per kg is a query, not a calculation engine. Transport, loading and packing costs are folded into each lot with an exact allocation that re-sums to the paisa.
  • Stock is issued first-expiry-first-out. One requested quantity can span several lots, and each lot becomes its own document line, so cost stays honest when the same item was bought at different prices.
  • Challans, invoices and credit notes share one table driven by two flags: moves stock, and creates dues. A monthly consolidated invoice bills existing delivery lines, moves no stock and carries no cost, so margin is never counted twice.
  • Concurrent saves are serialised with per-item advisory locks taken in a fixed order, and GST document numbers are allocated inside the document's own transaction, so numbers are unique and gap-free for each financial year.
  • Money is decimal end to end, in Postgres numeric columns and a decimal library in code. Financial documents are never deleted; they are cancelled, or reversed by a credit note, to match GST record-keeping rules.

The hard parts

  • Processing: 100 kg of whole fish that yields 60 kg cleaned has to show up as a higher cost per kg on the output lot, so total cost in always equals total cost out.
  • Supporting per-delivery billing and monthly billing from the same documents without counting cost or tax twice.

How it was checked

An integration script runs the full cycle against a real Postgres database inside a transaction that is rolled back: purchase, first-expiry-first-out sale, transfer, part payment and consolidated billing, with about 50 checks. Unit tests cover the money, date and CSV helpers.

04 / Delivery

What was delivered

A private client system. There is no public demo; client records, prices and source code are not shared here. Usage volume and time savings have not been published pending client confirmation.

Your next project

Something similar
on your mind?

Let’s talk about it
Next projectVending & Delivery LLC