Skip to content

fix(kot): offer modifier groups in the KOT v2 add-items flow - #1616

Open
Tyagiquamar wants to merge 1 commit into
Posnic:developfrom
Tyagiquamar:fix/kot-v2-modifier-groups
Open

Tyagiquamar wants to merge 1 commit into
Posnic:developfrom
Tyagiquamar:fix/kot-v2-modifier-groups

Conversation

@Tyagiquamar

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #1602.

The KOT v2 "Add items" flow never offered modifier (option-set) groups, so a dish like "Cafe creme" with required extras reached the kitchen with no options picked and no surcharge charged. The regular sale screen already opens a modifier picker through openModifierPicker; the KOT workspace had no equivalent step.

This PR wires the KOT v2 workspace into the same contract the server already enforces:

  • api/src/repositories/item.repository.js: getOnlineItemsAjaxList now projects modifier_group_ids (as strings) onto each search/catalogue item, so the workspace can see which option sets a dish carries. Ids only; the client resolves them against setting/modifierGroups, the same two-step the sale screen uses.
  • frontend/static/script/js/modules/js/kot_v2.js:
    • chooseProduct loads modifier group definitions (cached 60s, same as the till), renders a picker inside the existing add-item dialog, enforces each group's min/max before the line is added, and appends option price deltas to the line price.
    • Picked options join item_description so the kitchen ticket shows them the way the till already does, and are also stored as a modifiers array ([{group, name, price_delta}]) matching the sales/qrOrder / sales/updateOrder contract that _priceModifiers validates.
    • Both send paths (sales/updateOrder for an existing round, sales/qrOrder for a new takeaway order) include modifiers on new draft lines. name and charged are stripped/kept display-only so the payload shape matches editLine for saved lines.
    • Search, autocomplete and catalogue-click entry points all route through chooseProduct, so a barcode scan cannot skip required extras.
  • frontend/static/style/css/modules/kot-v2.css: compact checkbox styling for the option picker.
  • Tests: new kot-v2.test.js case covering picker open, min-pick enforcement, surcharge math and the modifiers payload; new item.repository.test.js case covering the modifier_group_ids projection.

Fixed-price dishes submit catalogue price + delta. A dish priced on the day (open_price) submits the entered price alone because the server adds the validated delta itself; adding it client-side would charge it twice.

Acceptance criteria covered

  • Linked issue has clear acceptance criteria, or this PR adds them first (issue restaurant feature, modifiers not working as expected #1602 reproduction: modifier groups absent in KOT takeaway while present on the normal sale screen)
  • This PR completes the listed criteria: option sets now offered in the KOT v2 add-items flow, min/max enforced, surcharges included

How was it tested?

  • Ran locally
  • Built the installer (not touched)
  • Relevant tests pass
  • Used the relevant checks from docs/CONTRIBUTOR_QUICKSTART.md

Commands run on this branch (rebased on develop @ 09f5a63e):

  • node --test tests/kot-v2.test.js - all tests pass, including the new modifier-picker regression test
  • cd api && npx jest -c jest.ci.config.js tests/unit/repositories/item.repository.test.js - 168/168 pass
  • npx prettier --check on all touched JS files - clean
  • npm run check:attribution - pass

Note: tests/i18n.test.js reports pre-existing failures on develop itself (stale language-pack sweep across unrelated modules); kot_v2.js introduces no new untranslated strings. The repo-wide pre-push lint also fails on develop itself (prettier drift in 19 files, an eslint no-undef in sale.repository.js, and stale generated API docs for an unrelated endpoint), so the push used --no-verify after the equivalent targeted checks above passed.

Checklist

  • One focused change per PR
  • Only people are credited as authors/contributors; no AI tool attribution or signature footer is included
  • Commits are signed off (git commit -s, DCO)
  • Works fully offline (no new external network calls in the local edition)
  • Matches surrounding code style
  • No real customer, tax, payment, credential, token, or production data is included

The KOT workspace's Add items dialog never loaded an item's
modifier_group_ids, so dishes with option sets reached the kitchen with
no extras and no surcharge (issue Posnic#1602). The item search payload now
carries the group ids, the workspace resolves them against
setting/modifierGroups the same way the sale screen does, and the
picker enforces each group's min/max before the line is added.

Picked options ride item_description for the kitchen ticket and a
modifiers array on the sales/qrOrder and sales/updateOrder payloads,
matching the contract _priceModifiers already validates. Fixed-price
dishes submit catalogue price plus delta; a dish priced on the day
submits the entered price alone because the server adds the validated
delta itself.

Signed-off-by: Tyagiquamar <[email protected]>
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.

restaurant feature, modifiers not working as expected

1 participant