Skip to content

feat(orders): let ready-made items skip the kitchen and add a hybrid service model - #1626

Merged
itsbkm merged 4 commits into
mainfrom
feat/hybrid-service-model
Nov 25, 2026
Merged

itsbkm merged 4 commits into
mainfrom
feat/hybrid-service-model

Conversation

@itsbkm

@itsbkm itsbkm commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Products get a "Goes to kitchen" flag (requires_kitchen, default on, migration v126). Order lines snapshot it; ready-made lines are created served and are excluded from the KDS, kitchen board, customer display board, order-status derivation and kitchen tickets.
  • New hybrid service model (setup card and Settings select): dine_in orders are paid after service, every other order type is prepaid. Backend settlement gates and the POS follow the order type; tables_required is forced on.
  • Docs: new product invariant, order lifecycle and API reference updates. Strings added to all 32 locales.

Verification

  • New test:hybrid-service-model (35 assertions) plus a v126 case in test:upgrade-path; KDS, multi-counter, kitchen-delivery, scheduled-order, refund, first-run, telemetry and customer-display suites pass.
  • lint, build, build:frontend, i18n:check, docs:check:policy pass. Playwright E2E and the full npm test were not run.

Limits

  • No category-level flag yet; ready-made-only dine-in orders are completed manually; non-English strings have not had a native-speaker review.

🤖 Generated with Claude Code

…service model

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Route ready-made items around the kitchen and support hybrid service

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Let ready-made products bypass kitchen workflows without changing how they are sold or billed.
• Add hybrid service: dine-in orders are postpaid; all other order types are prepaid.
• Document the new rules and test order behavior and database upgrades.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 2 capabilities

  • 2 affected capabilities span independent functional scopes: restaurant service-mode and kitchen workflow, restaurant service-mode and payment workflow.
  • The catalog flag, order-item snapshot, KDS/kitchen queries, customer-display projection, settlement checks, and order-status derivation all implement one bounded end-to-end outcome: whether a sold line requires kitchen work.
  • The legacy KDS server is a consumer of the same order-item behavior, not an independent capability.
  • The backend payment policy, bill settlement gate, order completion gate, POS payment prompt, held-order behavior, setup, and settings UI implement one end-to-end bounded outcome: payment timing by order type.
  • These are related consumers of one service-model configuration, not independent deployment capabilities.
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before: every order line followed the ordinary kitchen status flow and all consumers could treat the line as kitchen work.
  • After: a product flag is persisted on each order line, ready-made lines begin in served state, catalog edits do not rewrite historical lines, and multiple consumers must consistently distinguish kitchen and non-kitchen lines.
  • New correctness conditions: the snapshot must remain stable across catalog edits, ready-made lines must be excluded from every kitchen/status/settlement path, mixed orders must retain kitchen work only for kitchen lines, and legacy rows without the field must continue to behave as kitchen lines.
  • The direct status assignment is straightforward, but the changed persistent state and cross-consumer compatibility create interacting conditions.
Potential damage 🔴 High 🩹 Financial error

  • If the changed service-model behavior regresses, a dine-in order could be treated as prepaid or a counter/delivery order as postpaid.
  • That can change when funds are collected, when completion is allowed, and whether the POS prompts for payment.
  • The supported consequence is a potentially incorrect financial state or settlement timing within the affected order; it is not evidence of confidentiality or irreversible data loss.
  • Code rollback restores future policy decisions but does not automatically reconcile orders created or paid under the wrong policy.
  • Recovery requires reviewing affected bills/orders and, depending on whether an external payment was captured, refunding, collecting, or manually reconciling the difference.
  • The source does not establish automatic compensation for every transition case.
Assessed commit 1b8d5e5
Diagram

graph TD
  A["Product catalog"] --> B["Order lines"] --> C{"Kitchen required?"}
  C -->|yes| D["Kitchen workflows"]
  C -->|no| E["Served immediately"]
  F["Service settings"] --> G{"Dine in?"} --> H["Payment timing"]
  B --> G
Loading
High-Level Assessment

Keep the product-level flag and snapshot it on order lines: this preserves historical kitchen routing when the catalog changes. A category-level flag would not handle mixed products reliably. Retaining the existing global billing setting for non-hybrid venues limits behavioral changes while the hybrid policy follows order type.

Files changed (63) +1185 / -206

Enhancement (25) +302 / -70
page.tsxApply order-type payment timing in POS +7/-3

Apply order-type payment timing in POS

• Loads the service model into POS settings and uses it to choose immediate payment and postpaid dine-in order holding.

frontend/src/app/(dashboard)/pos/page.tsx

page.tsxAdd the Goes to kitchen product control +22/-0

Add the Goes to kitchen product control

• Adds a restaurant product checkbox, initializes it for new products, and includes its value when loading and saving products.

frontend/src/app/(dashboard)/products/page.tsx

page.tsxLoad and save the business service model +9/-0

Load and save the business service model

• Adds serviceModel to the business form and both settings save paths.

frontend/src/app/(dashboard)/settings/page.tsx

page.tsxOffer hybrid service during setup +8/-3

Offer hybrid service during setup

• Adds a third service-model card with localized label and explanatory text.

frontend/src/app/setup/page.tsx

CartPanel.tsxReflect hybrid billing and ready-made items in the cart +8/-2

Reflect hybrid billing and ready-made items in the cart

• Determines whether dine-in orders can be held using service-model-aware billing and labels ready-made cart items.

frontend/src/components/pos/CartPanel.tsx

ProductGrid.tsxIdentify ready-made products in POS +5/-0

Identify ready-made products in POS

• Displays a no-kitchen label on products whose kitchen flag is false.

frontend/src/components/pos/ProductGrid.tsx

GeneralSettingsTab.tsxExpose service-model selection in General Settings +70/-27

Expose service-model selection in General Settings

• Adds the hybrid option and explanation. Hides global billing and table-requirement controls while hybrid is selected.

frontend/src/components/settings/GeneralSettingsTab.tsx

customer-display.tsSuppress ready-made-only board status +4/-0

Suppress ready-made-only board status

• Prevents an order containing only ready-made lines from inheriting an active customer-board status.

frontend/src/lib/customer-display.ts

settings-search.tsIndex service-model settings +8/-0

Index service-model settings

• Adds localized service-model terms and English aliases to Settings search.

frontend/src/lib/settings-search.ts

types.tsType hybrid tenants and product kitchen flags +3/-1

Type hybrid tenants and product kitchen flags

• Extends the tenant service-model union and adds an optional product requires_kitchen field for older payload compatibility.

frontend/src/lib/types.ts

pos-settings.tsStore service model and resolve POS billing +25/-0

Store service model and resolve POS billing

• Hydrates and normalizes serviceModel and adds a helper that makes only dine-in orders postpaid in hybrid mode.

frontend/src/store/pos-settings.ts

db.tsMigrate kitchen flags and filter kitchen-only orders +21/-0

Migrate kitchen flags and filter kitchen-only orders

• Migration v126 adds default-on requires_kitchen columns to products and order_items. A shared SQL predicate excludes ready-made-only orders from active kitchen selections.

main/db.ts

auth.tsAccept hybrid during initial setup +3/-3

Accept hybrid during initial setup

• Uses shared service-model validation, requires tables for hybrid setup, and seeds its profile using the fine-dining seed path.

main/routes/auth.ts

bills.tsMake the bill kitchen gate order-specific +2/-4

Make the bill kitchen gate order-specific

• Checks the order's effective prepaid policy instead of the venue-wide billing setting before enforcing kitchen delivery.

main/routes/bills.ts

kds.tsExclude ready-made lines from KDS endpoints +2/-1

Exclude ready-made lines from KDS endpoints

• Filters both KDS order items and display items by the snapshotted kitchen flag.

main/routes/kds.ts

kitchen.tsExclude ready-made lines from kitchen orders +1/-1

Exclude ready-made lines from kitchen orders

• Limits kitchen-board order items to lines requiring kitchen work.

main/routes/kitchen.ts

orders.tsSnapshot kitchen routing on order creation +18/-13

Snapshot kitchen routing on order creation

• Creates ready-made lines as served in both order insertion paths and preserves that status on restoration. Completion enforcement now uses the order's effective prepaid policy.

main/routes/orders.ts

products.tsValidate and persist product kitchen flags +19/-3

Validate and persist product kitchen flags

• Adds requires_kitchen to catalog reads, validates boolean writes, defaults new products to kitchen-required, and supports partial updates.

main/routes/products.ts

settings.tsPersist and validate hybrid service settings +9/-1

Persist and validate hybrid service settings

• Returns and validates service_model in business settings and forces tables_required on when hybrid is selected.

main/routes/settings.ts

customer-display-tokens.tsExclude ready-made-only orders from board pages +3/-1

Exclude ready-made-only orders from board pages

• Applies the shared kitchen-work predicate to both customer-display order pagination queries.

main/services/customer-display-tokens.ts

kds.tsFilter ready-made lines from KDS snapshots +2/-1

Filter ready-made lines from KDS snapshots

• Limits active KDS snapshot items and item counts to lines requiring kitchen work.

main/services/kds.ts

orders.tsDerive order status from kitchen lines +12/-4

Derive order status from kitchen lines

• Passes snapshotted requires_kitchen values into both active-order reconciliation paths.

main/services/orders.ts

scheduled-orders.tsPreserve ready-made status at scheduled release +1/-1

Preserve ready-made status at scheduled release

• Releases ready-made lines as served rather than resetting them to pending.

main/services/scheduled-orders.ts

service-model.tsCentralize backend service-model payment policy +29/-0

Centralize backend service-model payment policy

• Defines valid service models and helpers for determining prepaid status by order type or order ID.

main/services/service-model.ts

order-item-status.tsIgnore ready-made lines in kitchen status derivation +11/-1

Ignore ready-made lines in kitchen status derivation

• Adds a backward-compatible kitchen-line predicate and excludes ready-made lines when deriving order status.

shared/order-item-status.ts

Tests (3) +354 / -1
package.jsonRegister the hybrid service integration suite +2/-1

Register the hybrid service integration suite

• Adds a dedicated test command and includes it in the npm test chain.

package.json

hybrid-service-model.test.tsTest ready-made routing and hybrid billing +290/-0

Test ready-made routing and hybrid billing

• Covers catalog validation and snapshots, KDS exclusion, status and ticket eligibility, catalog edits, settings validation, and payment timing by order type.

tests/hybrid-service-model.test.ts

upgrade-path.test.tsVerify the v126 migration from an existing database +62/-0

Verify the v126 migration from an existing database

• Checks both new columns and their defaults, preservation of a legacy product's kitchen behavior, and schema health after upgrade.

tests/upgrade-path.test.ts

Documentation (3) +49 / -7
order-lifecycle.mdDocument kitchen routing and settlement behavior +8/-3

Document kitchen routing and settlement behavior

• Explains order-line kitchen snapshots, kitchen-only status derivation, and the order-specific settlement gate.

docs/architecture/order-lifecycle.md

api.mdDescribe product and service-model API fields +4/-4

Describe product and service-model API fields

• Documents requires_kitchen on product writes and service_model on business settings, including validation and hybrid behavior.

docs/reference/api.md

product-invariants.mdDefine ready-made product invariants +37/-0

Define ready-made product invariants

• Specifies kitchen exclusion, preserved sales behavior, hybrid payment timing, verification commands, and guidance for new kitchen consumers.

docs/reference/product-invariants.md

Other (32) +480 / -128
ar.jsonLocalize ready-made and hybrid service UI in Arabic +15/-4

Localize ready-made and hybrid service UI in Arabic

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ar.json

bn.jsonLocalize ready-made and hybrid service UI in Bengali +15/-4

Localize ready-made and hybrid service UI in Bengali

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/bn.json

de.jsonLocalize ready-made and hybrid service UI in German +15/-4

Localize ready-made and hybrid service UI in German

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/de.json

en.jsonAdd English ready-made and hybrid service text +15/-4

Add English ready-made and hybrid service text

• Defines POS labels, product guidance, Settings options, and setup-card copy for the new workflows.

frontend/src/lib/i18n/messages/en.json

es.jsonLocalize ready-made and hybrid service UI in Spanish +15/-4

Localize ready-made and hybrid service UI in Spanish

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/es.json

fa.jsonLocalize ready-made and hybrid service UI in Persian +15/-4

Localize ready-made and hybrid service UI in Persian

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/fa.json

fil.jsonLocalize ready-made and hybrid service UI in Filipino +15/-4

Localize ready-made and hybrid service UI in Filipino

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/fil.json

fr.jsonLocalize ready-made and hybrid service UI in French +15/-4

Localize ready-made and hybrid service UI in French

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/fr.json

ha.jsonLocalize ready-made and hybrid service UI in Hausa +15/-4

Localize ready-made and hybrid service UI in Hausa

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ha.json

hi.jsonLocalize ready-made and hybrid service UI in Hindi +15/-4

Localize ready-made and hybrid service UI in Hindi

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/hi.json

id.jsonLocalize ready-made and hybrid service UI in Indonesian +15/-4

Localize ready-made and hybrid service UI in Indonesian

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/id.json

it.jsonLocalize ready-made and hybrid service UI in Italian +15/-4

Localize ready-made and hybrid service UI in Italian

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/it.json

ja.jsonLocalize ready-made and hybrid service UI in Japanese +15/-4

Localize ready-made and hybrid service UI in Japanese

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ja.json

jv.jsonLocalize ready-made and hybrid service UI in Javanese +15/-4

Localize ready-made and hybrid service UI in Javanese

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/jv.json

ko.jsonLocalize ready-made and hybrid service UI in Korean +15/-4

Localize ready-made and hybrid service UI in Korean

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ko.json

mr.jsonLocalize ready-made and hybrid service UI in Marathi +15/-4

Localize ready-made and hybrid service UI in Marathi

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/mr.json

ne.jsonLocalize ready-made and hybrid service UI in Nepali +15/-4

Localize ready-made and hybrid service UI in Nepali

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ne.json

nl.jsonLocalize ready-made and hybrid service UI in Dutch +15/-4

Localize ready-made and hybrid service UI in Dutch

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/nl.json

pa.jsonLocalize ready-made and hybrid service UI in Punjabi +15/-4

Localize ready-made and hybrid service UI in Punjabi

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/pa.json

pt.jsonLocalize ready-made and hybrid service UI in Portuguese +15/-4

Localize ready-made and hybrid service UI in Portuguese

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/pt.json

ru.jsonLocalize ready-made and hybrid service UI in Russian +15/-4

Localize ready-made and hybrid service UI in Russian

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ru.json

sq.jsonLocalize ready-made and hybrid service UI in Albanian +15/-4

Localize ready-made and hybrid service UI in Albanian

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/sq.json

sw.jsonLocalize ready-made and hybrid service UI in Swahili +15/-4

Localize ready-made and hybrid service UI in Swahili

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/sw.json

ta.jsonLocalize ready-made and hybrid service UI in Tamil +15/-4

Localize ready-made and hybrid service UI in Tamil

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ta.json

te.jsonLocalize ready-made and hybrid service UI in Telugu +15/-4

Localize ready-made and hybrid service UI in Telugu

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/te.json

th.jsonLocalize ready-made and hybrid service UI in Thai +15/-4

Localize ready-made and hybrid service UI in Thai

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/th.json

tr.jsonLocalize ready-made and hybrid service UI in Turkish +15/-4

Localize ready-made and hybrid service UI in Turkish

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/tr.json

uk.jsonLocalize ready-made and hybrid service UI in Ukrainian +15/-4

Localize ready-made and hybrid service UI in Ukrainian

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/uk.json

ur.jsonLocalize ready-made and hybrid service UI in Urdu +15/-4

Localize ready-made and hybrid service UI in Urdu

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/ur.json

vi.jsonLocalize ready-made and hybrid service UI in Vietnamese +15/-4

Localize ready-made and hybrid service UI in Vietnamese

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/vi.json

zh-tw.jsonLocalize ready-made and hybrid service UI in Traditional Chinese +15/-4

Localize ready-made and hybrid service UI in Traditional Chinese

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/zh-tw.json

zh.jsonLocalize ready-made and hybrid service UI in Simplified Chinese +15/-4

Localize ready-made and hybrid service UI in Simplified Chinese

• Adds POS, product, Settings, and setup text for the new kitchen flag and service model.

frontend/src/lib/i18n/messages/zh.json

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (7) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Ready-made orders print empty kitchen tickets 🐞 Bug ≡ Correctness
Description
printKotIfEnabled sends newly created orders to the printer without checking whether any line is
eligible for a kitchen ticket, while the new insertion path marks every ready-made line served.
With automatic kitchen printing enabled and a WebUSB printer, a ready-made-only order produces a
ticket headed by the order details and containing “no pending items.”
Code

main/routes/orders.ts[1234]

+      productRequiresKitchen(product) ? initialStatus : 'served',
Evidence
The new status removes ready-made lines from the encoder's item loop, but does not prevent automatic
print dispatch or the encoder's explicit empty-ticket output.

main/routes/orders.ts[1231-1237]
frontend/src/app/(dashboard)/pos/page.tsx[1234-1245]
frontend/src/lib/printer/kot-encoder.ts[303-313]
frontend/src/lib/printer/kot-encoder.ts[424-435]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Ready-made-only orders trigger automatic printing of an empty kitchen ticket.
## Fix Focus Areas
- frontend/src/app/(dashboard)/pos/page.tsx[1234-1245]
- frontend/src/lib/printer/kot-encoder.ts[303-310]
## Recommended Fix
Before dispatching an automatic kitchen ticket, check that it contains an eligible kitchen line. Keep the printer paths from producing a header-only ticket when no eligible lines remain.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Hybrid stores can lose required tables 🐞 Bug ≡ Correctness
Description
PUT /business forces tables_required on only when the request itself contains `service_model:
'hybrid'`, rather than checking the effective stored model. An already-hybrid store can persist
tables_required: false through a partial business update or the generic settings endpoint, after
which the POS no longer requires a table for dine-in orders.
Code

main/routes/settings.ts[536]

+      tables_required: service_model === 'hybrid' ? true : tables_required,
Evidence
The new conditional uses only the submitted model; both settings paths can persist false while the
stored model remains hybrid, and the POS table gates use that false value.

main/routes/settings.ts[532-536]
main/routes/settings.ts[2403-2415]
main/routes/settings.ts[2560-2583]
frontend/src/app/(dashboard)/pos/page.tsx[2061-2074]
frontend/src/app/(dashboard)/pos/page.tsx[3925-3934]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An existing hybrid store can disable required tables through settings updates.
## Fix Focus Areas
- main/routes/settings.ts[532-536]
- main/routes/settings.ts[2403-2415]
- main/routes/settings.ts[2560-2583]
## Recommended Fix
Determine the effective service model from the submitted value or stored setting before saving `tables_required`. Apply the same hybrid invariant to the generic settings write path, and test partial updates and generic writes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Ready-made lines can reach kitchen tickets 🐞 Bug ≡ Correctness
Description
The new requires_kitchen snapshot is not checked by kitchen-ticket filtering, which still admits
lines solely according to isKotItemPending(status). An authorized item-status update can change a
ready-made line from served to pending or preparing, causing a subsequent manual
kitchen-ticket print to include it.
Code

main/routes/orders.ts[1237]

+      productRequiresKitchen(product) ? 1 : 0,
Evidence
The new snapshot records that the line must skip the kitchen, but the existing status-update
endpoints can alter its status and each printing path relies on status alone.

main/routes/orders.ts[1234-1237]
main/routes/kds.ts[636-649]
shared/print/document.ts[851-855]
main/routes/printers.ts[1464-1471]
frontend/src/lib/printer/kot-encoder.ts[303-310]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A ready-made line whose status changes can appear on a kitchen ticket despite its persisted flag.
## Fix Focus Areas
- main/routes/printers.ts[1464-1471]
- frontend/src/lib/printer/kot-encoder.ts[303-310]
- frontend/src/lib/printer/print-document.ts[378-386]
- frontend/src/lib/printer/kot-web-print.ts[209-212]
## Recommended Fix
Make kitchen-ticket eligibility require `requires_kitchen` as well as an eligible status across desktop, WebUSB, and browser printing. Preserve compatibility for older items that lack the field.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View review recommended (4)
4. Removing a bottled drink from an order counts it as waste 🐞 Bug ≡ Correctness
Description
Ready-made lines are created with status 'served', and the item-edit handler treats every line whose
status is not 'pending' as already started (isPendingLine = oldItem.status === 'pending').
Lowering the quantity of a ready-made line therefore takes the started-decrease path: the dropped
units are logged as wasted_quantity and never go back into stock. Swapping the line for another
product is also rejected with 'Cannot replace an item once kitchen preparation has started'.
Code

main/routes/orders.ts[R2635-2638]

+            productRequiresKitchen(product) ? 'pending' : 'served',
         itemCreatedAt,
         itemCreatedAt,
+            productRequiresKitchen(product) ? 1 : 0,
Evidence
The PR inserts ready-made lines as 'served' at order creation (orders.ts 2635) and in
insertOrderItems (1234). The edit route decides 'started' purely from status (6768-6772). For a
non-pending decrease it scales down inventory_deducted_quantity, keeping the dropped stock out of
inventory, and sets wastedQuantity (6823-6881). That value is written to the audit log (7109).
Replacing a non-pending line throws a 400 (6778-6784). A cola that never went to the kitchen now
gets kitchen-waste treatment.

main/routes/orders.ts[6768-6784]
main/routes/orders.ts[6823-6881]
main/routes/orders.ts[7097-7111]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Ready-made order lines (requires_kitchen = 0) are created with status 'served'. The item-edit route treats them as kitchen-started lines. A quantity decrease records the dropped units as waste and does not restore stock, and replacing the line is rejected.
## Fix Focus Areas
- main/routes/orders.ts[6768-6784]
- main/routes/orders.ts[6910-6924]
## Recommended Fix
Compute `isPendingLine` as `oldItem.status === 'pending' || (Number(oldItem.requires_kitchen) === 0 && oldItem.status === 'served')`. Ready-made lines then use the pending-line cancel/reinsert path, which restores stock and records no waste, and they can be replaced. Add a test that decreases and replaces a ready-made line and asserts that stock is restored and no `wasted_quantity` is recorded.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Refunding a ready-made-only order puts it on the customer screen 🐞 Bug ≡ Correctness
Description
orderHasKitchenWorkSql counts any order_items row with requires_kitchen = 1, whatever its
status. The refund path inserts a void_adjustment row without setting requires_kitchen, so the
row gets the default of 1. After a refund, an order made only of ready-made items, which stays in
'pending' because derivation returns null, passes the board filter and appears on the customer
display board as a pending order.
Code

main/db.ts[R11788-11791]

+  return `(
+      EXISTS (SELECT 1 FROM order_items kitchen_oi WHERE kitchen_oi.order_id = ${orderAlias}.id AND kitchen_oi.requires_kitchen = 1)
+      OR NOT EXISTS (SELECT 1 FROM order_items ready_oi WHERE ready_oi.order_id = ${orderAlias}.id AND ready_oi.requires_kitchen = 0)
+    )`;
Evidence
The migration sets the column to NOT NULL DEFAULT 1 (db.ts 10404). refund.ts inserts the
'void_adjustment' row with no requires_kitchen column (451-467), so it defaults to 1. The new
predicate's first EXISTS branch has no status filter (db.ts 11789). selectBoardEligibleOrderPage
selects by order status plus this predicate only (customer-display-tokens.ts 346-353).
deriveOrderStatusFromItems ignores ready-made lines and returns null, so reconciliation leaves the
order 'pending' (services/orders.ts 432-434). KDS hides the order only because its item queries also
drop void_adjustment rows; the board query does not.

main/services/refund.ts[451-467]
main/db.ts[11786-11798]
main/services/customer-display-tokens.ts[343-373]
main/services/orders.ts[425-434]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `void_adjustment` rows inserted by refunds (and item voids) default to requires_kitchen = 1. That makes `orderHasKitchenWorkSql` true for ready-made-only orders, so they show up on the customer display board.
## Fix Focus Areas
- main/db.ts[11787-11792]
- main/services/refund.ts[462-467]
- main/routes/orders.ts[6404-6408]
## Recommended Fix
In the first EXISTS of `orderHasKitchenWorkSql`, also require `kitchen_oi.status NOT IN ('void_adjustment','cancelled','voided','refunded')`. As well, copy the original line's `requires_kitchen` into the adjustment rows inserted in refund.ts and orders.ts, so the snapshot stays consistent. Add a test that refunds an item on a ready-made-only order and asserts the order stays off the board.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Completed orders show 'preparing' on the customer screen too early 🐞 Bug ≡ Correctness
Description
selectBoardEligibleOrderPage loads completed-order items without requires_kitchen, so
isKitchenItem treats ready-made lines as kitchen work when deriving their board status. In a mixed
order paid before kitchen work starts, a served ready-made line can make the board show preparing
instead of pending; on a recent ready-made-only completed order, an authorized item-status update
can also make the completed feed show an order excluded from the filtered active feed.
Code

shared/order-item-status.ts[R37-38]

+export function isKitchenItem(item: { requires_kitchen?: unknown } | null | undefined): boolean {
+  return item != null && Number(item.requires_kitchen ?? 1) !== 0;
Evidence
isKitchenItem defaults a missing requires_kitchen value to 1, while the completed-order item
query selects only order_id, status, and quantity before passing those rows to
projectBoardStatusFromItems. Because served is a started status, a pending kitchen line paired
with a served ready-made line derives preparing. The active feed has a kitchen-work condition, but
the completed feed accepts eligible projected statuses without that condition; item-status updates
can supply such a status. The backend reconciler was updated to select requires_kitchen, but this
projection path was not.

shared/order-item-status.ts[36-83]
main/services/customer-display-tokens.ts[259-289]
main/services/orders.ts[425-432]
main/services/customer-display-tokens.ts[207-220]
main/services/customer-display-tokens.ts[250-283]
main/services/customer-display-tokens.ts[346-370]
shared/order-item-status.ts[36-38]
main/routes/kds.ts[636-649]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The completed-order customer-display projection lacks `requires_kitchen`, causing ready-made lines to count as kitchen progress and allowing ready-made-only completed orders into the feed after an eligible item-status update.
## Fix Focus Areas
- main/services/customer-display-tokens.ts[207-220]
- main/services/customer-display-tokens.ts[250-283]
- main/services/customer-display-tokens.ts[346-370]
## Recommended Fix
Select `requires_kitchen` alongside `order_id`, `status`, and `quantity` in the completed-order item query and widen the bucket type so `projectBoardStatusFromItems` can skip ready-made lines. Restrict completed-order candidates to orders with actual kitchen work. Check other callers of `deriveOrderStatusFromItems` and `projectBoardStatusFromItems` for item rows missing this column, and test a completed ready-made-only order after an item-status update.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Paid ready-made-only checkout orders never leave pending 🐞 Bug ☼ Reliability
Description
reconcileOrderSettlement does not complete an order whose dispatch_policy is 'on_payment'. It
relies on kitchen progress to move the order forward, but ready-made lines are created 'served' and
deriveOrderStatusFromItems now returns null when no kitchen lines exist. A takeaway order made
only of ready-made items, created through the POS send-to-payment flow (`dispatch_policy:
'on_payment'`), stays 'pending' after payment and remains in active-order lists and table occupancy
until someone completes it by hand; the PR's Limits section mentions only dine-in.
Code

shared/order-item-status.ts[R51-55]

+    (item) =>
+      item != null &&
+      isKitchenItem(item) &&
+      !isTerminalItemStatus(item.status) &&
+      Number(item.quantity) > 0,
Evidence
The on_payment branch of reconcileOrderSettlement only marks the checkout paid and queues release;
it never sets status to completed (bills.ts 3032-3043). The immediate branch completes the order
(3050-3065). With no kitchen items, derivation returns null and reconciliation is a no-op
(services/orders.ts 432-434), so nothing moves the order out of 'pending'. The POS creates
on_payment orders in the send-to-payment flow (pos/page.tsx 2650).

main/routes/bills.ts[3032-3065]
main/services/orders.ts[425-434]
frontend/src/app/(dashboard)/pos/page.tsx[2635-2655]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An on_payment order made only of ready-made items is never completed after payment, because completion for on_payment orders relies on kitchen progress and ready-made lines skip the kitchen.
## Fix Focus Areas
- main/routes/bills.ts[3032-3043]
- main/services/orders.ts[425-434]
## Recommended Fix
In the on_payment branch of `reconcileOrderSettlement`, once the order is settled and released, check whether it has any live kitchen line (requires_kitchen = 1, non-terminal status). If it has none, complete the order (status 'completed', completed_at, free the table) the same way the immediate branch does. Alternatively, have `reconcileActiveOrderStatusFromItems` return 'served' for orders whose live lines are all ready-made. Add a test for a paid on_payment order containing only ready-made items.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@itsbkm
itsbkm merged commit 8b0387a into main Nov 25, 2026
23 checks passed
@itsbkm
itsbkm deleted the feat/hybrid-service-model branch November 25, 2026 19:37
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.

1 participant