Skip to content

Enhancement: Add-on Multi-Quantity Support#122

Merged
khaira777 merged 13 commits into
mainfrom
feature/addon-quantities
Jul 23, 2026
Merged

Enhancement: Add-on Multi-Quantity Support#122
khaira777 merged 13 commits into
mainfrom
feature/addon-quantities

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Resolves #83. Work in progress for add-on configuration UX and multi-quantity support.

@khaira777
khaira777 force-pushed the main branch 2 times, most recently from 46f0145 to c6f9e70 Compare July 22, 2026 21:59
khaira777 added 12 commits July 23, 2026 04:30
…issue #83)

- Add migration v33 with addon_groups.allow_multiple_quantities column
- Update backend order and tax routes to validate and compute addon quantities
- Update POS AddonModal with +/- quantity controls and total group bounds check
- Update cart store identity generation and subtotal calculations
- Format add-on quantities on KDS views and printed receipts (e.g. Sugar ×3)
- Add comprehensive integration test suite in tests/issue-122-addon-quantities.test.ts
…toggle to products addon modal

- Add server-side validateItemAddonGroupLimits helper in main/routes/orders.ts to enforce allow_multiple_quantities, min_selection, and max_selection on order placement
- Update Products page add-on group editor state, form submit handler, and modal UI to load, edit, and submit allow_multiple_quantities
- Add backend group limit enforcement integration test assertions in tests/issue-122-addon-quantities.test.ts
# Conflicts:
#	frontend/src/components/pos/AddonModal.tsx
…ddon count + inactive category indicators

- Unify layout in POS AddonModal so both single-select and multi-select rows show price next to name on the left and action controls (+ / [- 1 +]) on the right
- Add Add-ons column in Products page table showing total addon groups linked to each product
- Add Inactive Category warning badge to Products page table when a product's parent category is disabled
…e browser printing mode, and fix toggle alignment

- Enforce required add-on group selection in POS AddonModal (disabled Add to Cart button + red warning when required count not met)
- Handle browser print mode smoothly in usePrinter (call printViaBrowser instead of throwing uncaught Error)
- Add shrink-0, gap-4, and flex-1 min-w-0 to settings page toggle rows to prevent switch cutoff on small screens
@khaira777

Copy link
Copy Markdown
Contributor Author

PR #122 Summary: Add-on Multi-Quantity Support (Issue #83)

1. Overview & Architecture

This PR completes the full implementation of multi-quantity add-on support per add-on group. Store owners can configure whether an add-on group allows customers to select multiple quantities of individual add-on items (e.g. 2x Extra Shot, 3x Syrup) while strictly enforcing group minimum and maximum selection caps.


2. Key Changes

Database Schema

  • Migration v33: Added allow_multiple_quantities INTEGER DEFAULT 0 column to the addon_groups table with non-destructive schema migration and auto-backup.

Backend Routes & Validation (main/routes/)

  • Order Limits Validation (orders.ts): Implemented validateItemAddonGroupLimits shared between POST /orders and POST /orders/:id/items to validate:
    • Add-on item quantities are positive integers.
    • Multi-quantity items are rejected if allow_multiple_quantities is disabled for that group.
    • Total selected quantity across all group add-ons respects min_selection and max_selection.
  • Add-on Group API (addon-groups.ts): Sanitized all optional fields in PUT /api/addon-groups/:id to prevent better-sqlite3 undefined raw value exceptions.
  • Main Process Safety (index.ts): Added .catch() error handling to shell.openExternal calls to suppress unhandled OS Launch Services rejections.

POS & Frontend UI (frontend/src/)

  • POS AddonModal (AddonModal.tsx):
    • Rendered counter controls ( qty +) when allow_multiple_quantities is enabled.
    • Unified typography & layout: name + + aligned on left, action controls (+ / [ − 1 + ]) aligned on right for both single-select and multi-select groups.
    • Fixed numeric 0 JSX rendering glitch caused by uncast is_required database integers.
    • Enforced strict validation preventing item addition to cart when required add-on group selections are incomplete.
  • Products Table (products/page.tsx):
    • Added new Add-ons column displaying count of linked add-on groups.
    • Added Category Inactive warning badge and status subtitle for active products belonging to disabled parent categories.
  • Admin Configuration: Added the allow_multiple_quantities toggle to both the Add-on Groups page and Products page Add-on Group editor modals.
  • Settings Layout & Printer Handling:
    • Added shrink-0, gap-4, and flex-1 min-w-0 responsive flex properties across all Settings toggle rows to prevent switch cutoff on smaller screens.
    • Updated usePrinter.ts to handle browser print mode via printViaBrowser without throwing uncaught errors.

3. Automated Tests & Verification

  • Targeted Integration Test (tests/issue-122-addon-quantities.test.ts): 21/21 assertions passed (covering CRUD, order creation, item updates, error bounds, and legacy row default fallback).
  • Full Test Suite (npm test): 19/19 test suites passed with 0 failures.
  • TypeScript & ESLint (npm run lint, npx tsc --noEmit): Passed with 0 errors.
  • Frontend Static Export (npm run build:frontend): 22/22 static pages generated successfully.

@khaira777
khaira777 marked this pull request as ready for review July 23, 2026 14:36
@khaira777
khaira777 requested a review from itsbkm as a code owner July 23, 2026 14:36
@khaira777
khaira777 merged commit 3a51900 into main Jul 23, 2026
10 checks passed
@khaira777
khaira777 deleted the feature/addon-quantities branch July 23, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add-on Configuration UX & Multi-Quantity Support

1 participant