Pilot readiness: server-side roles, stock ledger and transfers, offline-safe sync #1
Reference in New Issue
Block a user
Delete Branch "fix/pilot-readiness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes the gaps found when the MVP was reviewed against
PRD.mdandREVIEW.md. Full write-up, decisions and open items:docs/PILOT_READINESS.md.What changes
Tenant isolation and roles (PRD 5.1)
PLATFORM_ADMIN_EMAILSaddresses.Stock ledger and transfers (PRD 5.2)
StockMovementledger: stock = sum of movements, each keyed by its cause so replays never double-count. Sales and confirmed M-Pesa payments deduct stock; purchases add it./api/stock,/api/stock/transfers,/api/stock/adjustments,/api/stock/movements, and a Stock admin page (per-branch levels with low/out flags, counts, transfers, morning dispatch / evening count). Dashboard shows stock per branch.Offline POS and sync (PRD 5.3, 5.5)
POST /api/transactions/cashreturns saved / duplicate / rejected per sale. The old client never learned a replayed sale had synced, so once 100+ rows piled up every sync failed with 400.Other
FEATURE_MPESA(off by default; out of scope for the pilot). Turning it on in production requires the callback IP allowlist.Testing
npm test: 37 API tests against an in-memory MongoDB (role enforcement, cross-tenant attempts on sales/stock/transfers, suspension, sync protocol including a 120-sale backlog replayed twice, business day).Before deploying
FEATURE_MPESA=false(or leave unset) andPLATFORM_ADMIN_EMAILSin the environment; see.env.example.Still open (decisions needed)
Removing branches, a screen to set branch prices, concurrent transfers racing past available stock, global email/phone uniqueness, invites and email verification, and empty-bottle/deposit tracking. Details in
docs/PILOT_READINESS.md.🤖 Generated with Claude Code