Add a screen to set prices per branch #3

Merged
denis_ireri merged 1 commits from feat/branch-prices into main 2026-10-12 07:46:57 +00:00
Contributor

Branch price overrides were already applied at the till, in cash sales and in M-Pesa, but nothing could set them. This adds the screen and API.

What changes

  • Products -> Branch prices (/admin/prices): the owner picks a branch and sets its price for any product next to the default. Setting it back to the default removes the override; "Use default" resets it. A counter shows how many products are priced differently at that branch. Branch managers see their own branch's prices read-only.
  • /api/branch-prices: GET (owner: any branch; manager: own branch), PUT and DELETE (owner only). The branch and product must belong to the business, prices must be above zero, and who changed a price is recorded (updatedBy).
  • Plan rule: branch pricing is a Growth / Enterprise feature, as the Growth plan already advertised, and is also available during the free trial. A paid Starter business keeps any branch prices set during its trial and can reset them, but cannot set new ones. To offer it on every plan, set branchPricing: true for Starter in src/lib/tiers.ts.
  • The Products page (catalogue view) always shows default prices; the till shows what its branch charges. A phone picks up a change the next time it loads products; a sale recorded offline before that is kept at the server's price and flagged as a price mismatch.

Testing

  • npm test: 56 tests pass, 6 new: price applies only at its branch and through to the recorded sale; reset to default; manager read-only and pinned to their branch; plan rules (trial, Growth, paid Starter); zero price refused; another tenant's branch or product refused.
  • Production build passes.
  • Browser: set 20L to KES 180 at Kasarani as the owner; the cashier's till at Kasarani showed KES 180. The page fits a 375-pixel phone screen without sideways scrolling.

No migration or deploy step needed.

🤖 Generated with Claude Code

Branch price overrides were already applied at the till, in cash sales and in M-Pesa, but nothing could set them. This adds the screen and API. ## What changes - **Products -> Branch prices** (`/admin/prices`): the owner picks a branch and sets its price for any product next to the default. Setting it back to the default removes the override; "Use default" resets it. A counter shows how many products are priced differently at that branch. Branch managers see their own branch's prices read-only. - **`/api/branch-prices`**: GET (owner: any branch; manager: own branch), PUT and DELETE (owner only). The branch and product must belong to the business, prices must be above zero, and who changed a price is recorded (`updatedBy`). - **Plan rule**: branch pricing is a Growth / Enterprise feature, as the Growth plan already advertised, and is also available during the free trial. A paid Starter business keeps any branch prices set during its trial and can reset them, but cannot set new ones. To offer it on every plan, set `branchPricing: true` for Starter in `src/lib/tiers.ts`. - The Products page (catalogue view) always shows default prices; the till shows what its branch charges. A phone picks up a change the next time it loads products; a sale recorded offline before that is kept at the server's price and flagged as a price mismatch. ## Testing - `npm test`: 56 tests pass, 6 new: price applies only at its branch and through to the recorded sale; reset to default; manager read-only and pinned to their branch; plan rules (trial, Growth, paid Starter); zero price refused; another tenant's branch or product refused. - Production build passes. - Browser: set 20L to KES 180 at Kasarani as the owner; the cashier's till at Kasarani showed KES 180. The page fits a 375-pixel phone screen without sideways scrolling. No migration or deploy step needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
denis_ireri added 1 commit 2026-10-12 07:46:21 +00:00
Branch price overrides were already applied at the till, in cash sales
and in M-Pesa, but nothing could set them.

- Products -> Branch prices (/admin/prices): pick a branch and set its
  price for any product; setting it back to the default removes the
  override, and "Use default" resets it. Branch managers see their own
  branch's prices read-only.
- /api/branch-prices: GET (owner: any branch; manager: own), PUT and
  DELETE (owner only). Branch and product must belong to the business;
  prices must be above zero; who changed a price is recorded.
- Branch pricing is a plan feature, as the Growth plan already
  advertised: Growth and Enterprise, plus any business on its free
  trial. A paid Starter business keeps any prices set during its trial
  and can reset them, but cannot set new ones.
- The catalogue view on the Products page always shows default prices;
  the till's view shows what the branch charges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
denis_ireri merged commit 1fe2421cc4 into main 2026-10-12 07:46:57 +00:00
denis_ireri deleted branch feat/branch-prices 2026-10-12 09:00:16 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Ezekiel_Nyangweso/ERP#3