The sales platform a distribution company runs on — from a rep's phone at the shop counter to the office ledger.

Founder and full-stack engineer — data model, money flows, field interface, printing
- Django
- Python
- PostgreSQL
- django-tenants
- Bootstrap 5
- Leaflet
- ReportLab
- ESC/POS
Business platform
The problem
A distribution company lives on field sales. Reps bill shops, give free-of-charge stock, collect cash and cheques, take returns and refund on the spot — all day, on the road. When that runs on paper and spreadsheets, nobody can say what a shop owes, what a rep is carrying or what the stock is really worth until someone reconciles it by hand.
The thinking
Model the money first. Every bill, return, exchange, payment and settlement is a record with a number, a state and an owner, and stock moves through FIFO cost layers so profit is calculated rather than estimated. The rep's phone and the office dashboard are two views of one ledger — and because the next distributor would need exactly the same system, each company gets its own PostgreSQL schema.
The temptation was to build a billing app. The decision was to build the ledger and let billing be one way of writing to it. Anything that moves money or stock — a bill, a return, a payment, a write-off — has to leave the books consistent, including when it is cancelled a week later. That single rule is why commissions reverse themselves and why stock is costed in layers rather than averages.
The system
- Tenant layer — one PostgreSQL schema per distributor, resolved by subdomain, with a platform view across all of them
- Field layer — shops on a map, orders, visits and billing from a phone
- Sales layer — bills, returns and exchanges, each with its own dated number
- Money layer — cash, cheques, bank transfers and credit, verified by the office
- Stock layer — purchase orders, goods received, free-of-charge stock and FIFO cost layers
- Commission layer — rep earnings at the rate in force on the bill's date, reversed when a sale is undone
The experience
The rep is at a shop counter with a phone in one hand and a customer waiting. So field screens are short, a button that is switched off says why right above it, and the receipt prints from the phone with no laptop in the car. The office does the opposite job — checking, verifying, settling — and gets dense tables and filters instead.
The details
Billing at the counter
A rep builds the bill on a phone in the shop — products, free-of-charge items, discounts — and prints it before leaving.
Bluetooth thermal printing
Receipts go from the phone to a portable printer as ESC/POS. One print engine covers every receipt type and paper size, from 58 mm to A4.
Shops on a map
Every shop carries its coordinates, so reps see their route and the office sees coverage. A new order needs the shop's location.
Verified payments
Cash, cheques, bank transfers and credit each follow their own path, and the office verifies them against what was collected.
Refunds in the field
A rep can take goods back and refund cash on the spot. The bill, the stock and the commission follow, and the cash settles at the end of the day.
Commissions that reverse
Earnings accrue at the rate in force on the bill's date, reverse when a sale or payment is undone, and pay out on a schedule.
FIFO stock costing
Purchase orders and goods-received notes feed stock in cost layers, so the cost of a sale is the cost of the stock it actually used.
One platform, many distributors
Each distributor runs in its own schema behind its own subdomain; a platform dashboard reports across all of them.
The result
Zergo Distributors runs its sales on it — reps in the field, the office behind them. A bill printed in a shop, the cash it brought in and the commission it earned are one chain of records, and the same system can serve another distributor without either seeing the other's data.
Lessons
- In a financial system every undo needs its own record. Editing history is how the books stop balancing.
- Cancellation is the hardest feature to get right, and usually the last one designed.
- Field software is judged at the counter, in seconds, with someone waiting.
- Building for your own company removes the last excuse for not knowing how the work is actually done.