Joynal Sanitary
Single-tenant internal web ERP for M/s. Joynal Sanitary, a Bangladesh sanitary wholesaler. Admin and Manager staff handle products, stock, customers, invoices, payments, returns, supplier purchases, staff pay, and reports. Stock and customer balances derive from append-only records, never edited.

Built for every role

Features
Access and users
Inventory
Customers
Sales
Suppliers and purchases (V2)
Cashbook & Staff
Reports
Notifications
Localization and ops
Estimated price
BDT 500 – BDT 1,500
Typical duration
15–45 days
About this project
Purpose. The shop serves 300+ regular business customers, plus walk-in buyers. Staff run daily counter operations here: creating invoices, collecting payments, handling returns, tracking dues, and buying from suppliers. The Admin also sees full profit and loss, ledgers, and cost data.
Status. Version 1 (core sales operations) and Version 2 (suppliers, purchases, staff, operating cashbook, advanced reports, CSV export) are both complete, with 218 passing tests. The next step is the Vercel production deploy. Live SMS is gated on the MiMSMS IP whitelist and npm run verify:sms.
Financial rules the system enforces
Stock = SUM(IN) − SUM(OUT) from
StockMovement. It is never a field onProduct.Customer, supplier, and staff balance = SUM(DEBIT) − SUM(CREDIT) from
LedgerEntry.Invoice, items, stock movements, ledger entries, and payment are created in one atomic DB transaction.
Cost uses a moving weighted average. Each invoice line snapshots
costPrice, and no sale is allowed whileaverageCostis 0.Confirmed invoices are immutable. Corrections go through sales returns or an Admin-only void, both of which keep the audit trail.
Row locks (
SELECT … FOR UPDATE) on products, invoices, and the invoice-number counter prevent negative stock, overpayment, and duplicate invoice numbers.Walk-in sales are cash-only and create no ledger entries.
Managers never see
averageCost,costPrice, profit, ledgers, dues, or supplier and staff data. This is enforced on the server, and responses are shaped per role.SMS is sent after commit, is always logged, and never rolls back a sale.
Architecture. A modular monolith: one Next.js app with layers for presentation, application (thin route handlers and hooks), domain (services own all business logic), and data (Prisma and PostgreSQL with raw SQL constraints). Every API response uses { success, data, error, code? }, with Decimal and Date values serialized safely.

















