ERP · Finance · 2026

An ERP for a wholesale garments business, with real accounting underneath

Integer money, FIFO lot costing, a double-entry ledger and append-only history. Built so the numbers a business runs on are never approximately right.

Client code is private. This describes the engineering
Wholesale Garments ERP, ERP · Finance
Client
Confidential (Oman)
Industry
Wholesale trade
My role
Architect and lead engineer, API and web app
Year
2026

Overview

A full ERP for a wholesale garments importer: purchases in supplier currency, landed-cost inventory, sales, invoicing, a general ledger and reporting. NestJS + Prisma + PostgreSQL behind a React 19 + Vite + shadcn front end.

The problem

Most 'ERPs' built by web teams store money as floats, cost inventory by average, and edit history in place. All three produce books that don't reconcile. This business trades in Omani Rial with three decimal places, buys in Bangladeshi Taka, and needed accounts an auditor could follow.

What I built

  • Money as a value object: integer baisa (1 OMR = 1000 baisa), never floats, persisted to NUMERIC(18,3). Arithmetic that cannot silently lose a third decimal.
  • FIFO lot costing: every shipment receipt is a StockLot with its own landed cost; sales consume lots oldest-first and record exact cost of goods sold.
  • A double-entry ledger: every financial action posts a balanced LedgerTransaction against a seeded chart of accounts.
  • Immutable history: ledgers, confirmed sales, invoices and stock movements are append-only; corrections are reversing records, never edits.
  • Per-shipment FX: purchases entered in the supplier's currency with the exchange rate captured on the shipment.
  • Fail-fast environment validation, strict ESLint where `any` is an error, Vitest, an ERD and data-model document, CI and deploy pipelines.

Outcome

3 dp

OMR handled exactly, as integer baisa

FIFO

Exact COGS per sale from lot-level landed cost

Balanced

Every transaction posts double-entry

Append-only

Corrections reverse, they never overwrite

Engineering decisions

  • Integer money value object
  • FIFO lot costing with landed cost
  • Double-entry ledger, append-only
  • Per-shipment foreign exchange