case-study --pharma-erp
§IV · PLATEPharmulo
Live · in productionA pharma wholesaler wanted retailers ordering from their phones, but would not give up ProfitMaker. So a Windows agent reads the ERP, never writes to it, and drafts bills through the same screen the staff already use. The ERP stays the source of truth.
project-brief --outcome-first
§IV · BRIEFWhat had to change
Let retailers order online without replacing the wholesaler's ProfitMaker ERP, writing directly to its database, or creating a second stock truth for staff to reconcile.
What I shipped
A multi-tenant retailer PWA, wholesaler admin, and auto-updating Windows agent that mirrors 26 ERP entities and drafts guarded bills through ProfitMaker's own UI.
What the business gained
A retailer order can flow from phone to a human-reviewed ProfitMaker bill without re-keying, while stock, fulfillment, and reconciliation continue to derive from the ERP.
screens --as-shipped
§IV · PLATES
systems --under-the-hood
§IV · SCHEMATIC- Read-only ERP mirror26 entities
An auto-updating Windows agent reads 26 ProfitMaker entities through SELECT-only SQL, then syncs typed contracts into the tenant-scoped Postgres mirror.
- Guarded order→bill bridge
The agent claims one order, checks for an existing bill, and drives ProfitMaker's Sales screen under focus and dialog guards; a human reviews the draft and ProfitMaker performs the save.
- ERP-derived fulfillment
Orders become billed only when the saved bill syncs back. Quantities and mismatches derive from its lines, with a reaper surfacing stranded drafts instead of trusting an agent acknowledgement.
- Expiry-aware batch billing
Retailers see only sellable batches, the agent skips expired or unknown-expiry stock during bill entry, and the admin stock view exposes source-data gaps for repair.
- Value-aware reconciliation
Nightly digests fold money and quantity values identically across SQL Server and Postgres, skip no-op writes, and bound any tombstone cleanup so a bad scan cannot erase a mirror.
context --how-it-works
§IV · NOTESEvery wholesaler gets a branded catalog where their retailers browse live stock and order from a phone. The wholesaler keeps ProfitMaker, keeps their staff workflow, and keeps their database as the thing that is actually true.
The bridge runs across a Next.js platform, a Node sync worker, a Rust and Tauri desktop shell, SQL Server, Postgres, and Windows UI automation. The agent has no write access to ProfitMaker's database, by design. It drives the same Sales screen the staff use, and it aborts the moment it cannot prove the window in front of it is the one it expected. A human presses save.
The pilot has taken an order all the way to a saved bill. Since then I've added expiry-aware stock, reconciliation across all 26 mirrored entities, no-op write suppression, bounded tombstone cleanup so a bad scan can't wipe the mirror, background updates, and a retailer onboarding flow for the wider rollout.