From a8257b250917e9c13746f08fb0e4aa457b722e08 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Wed, 11 Mar 2026 17:06:18 -0700 Subject: [PATCH] Fix inverted modifier groups in KDS The inverted group header item isn't always an order line item itself, so RemovedDefaults was never computed. Now detects inverted groups via children's ParentIsInvertedGroup flag and attaches RemovedDefaults to the first child as a proxy. KDS JS handles both patterns. Also skips showing default modifiers from inverted groups since those are represented by "NO removed-item" instead. Co-Authored-By: Claude Opus 4.6 --- api/orders/listForKDS.cfm | 18 +++++++++++++----- kds/kds.js | 13 +++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/api/orders/listForKDS.cfm b/api/orders/listForKDS.cfm index 65daded..c73b855 100644 --- a/api/orders/listForKDS.cfm +++ b/api/orders/listForKDS.cfm @@ -126,7 +126,8 @@ i.IsCheckedByDefault, i.IsInvertedGroup, i.StationID, - parent.Name AS ItemParentName + parent.Name AS ItemParentName, + COALESCE(parent.IsInvertedGroup, 0) AS ParentIsInvertedGroup FROM OrderLineItems oli INNER JOIN Items i ON i.ID = oli.ItemID LEFT JOIN Items parent ON parent.ID = i.ParentItemID @@ -149,15 +150,20 @@ "ItemParentName": qLineItems.ItemParentName, "IsCheckedByDefault": qLineItems.IsCheckedByDefault, "IsInvertedGroup": qLineItems.IsInvertedGroup, + "ParentIsInvertedGroup": qLineItems.ParentIsInvertedGroup, "StationID": qLineItems.StationID, "StatusID": val(qLineItems.StatusID) })> + + - - + + + + + diff --git a/kds/kds.js b/kds/kds.js index 9370d81..15f4da4 100644 --- a/kds/kds.js +++ b/kds/kds.js @@ -408,20 +408,21 @@ function renderAllModifiers(modifiers, allItems) { function collectLeafModifiers(mods, depth = 0) { mods.forEach(mod => { // Inverted groups: show removed defaults with "NO" prefix instead of listing all selected defaults - if (mod.IsInvertedGroup || mod.ISINVERTEDGROUP) { + // Check both the item itself (if group header is in order) and proxy (first child carries the data) + const isInverted = mod.IsInvertedGroup || mod.ISINVERTEDGROUP || mod.IsInvertedGroupProxy || mod.ISINVERTEDGROUPPROXY; + if (isInverted) { const removed = mod.RemovedDefaults || mod.REMOVEDDEFAULTS || []; if (removed.length > 0) { + const groupName = mod.ItemParentName || mod.Name; removed.forEach(name => { - leafModifiers.push({ mod: { Name: 'NO ' + name, ItemParentName: mod.Name }, path: [] }); + leafModifiers.push({ mod: { Name: 'NO ' + name, ItemParentName: groupName }, path: [] }); }); } return; } - // Skip default modifiers only inside non-inverted groups - // (Inverted groups are already handled above with "NO" prefix) - // For regular groups, show all selected modifiers including defaults - + // Skip default modifiers inside inverted groups — handled above with "NO" prefix + if (mod.IsCheckedByDefault && (mod.ParentIsInvertedGroup || mod.PARENTISINVERTEDGROUP)) return; const children = allItems.filter(item => item.ParentOrderLineItemID === mod.OrderLineItemID); if (children.length === 0) {