@managesome/eposmatic-toolkit 0.2.721 → 0.2.732

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,9 +8,12 @@ exports.syncOrderEngineItem = syncOrderEngineItem;
8
8
  exports.checkIfModifiersExist = checkIfModifiersExist;
9
9
  exports.makeSpaceForFreeOptions = makeSpaceForFreeOptions;
10
10
  exports.applyChooseExpensiveSegmentPrice = applyChooseExpensiveSegmentPrice;
11
- exports.getOrderEnginePriceReferences = getOrderEnginePriceReferences;
11
+ exports.getOrderEngineOptionSegmentValue = getOrderEngineOptionSegmentValue;
12
12
  exports.hasFlaggedHalfHalfOption = hasFlaggedHalfHalfOption;
13
+ exports.getBlockedHalfHalfOptionPaths = getBlockedHalfHalfOptionPaths;
14
+ exports.getHalfHalfBlockedItemIds = getHalfHalfBlockedItemIds;
13
15
  exports.applyNestedChooseExpensiveSegmentPrice = applyNestedChooseExpensiveSegmentPrice;
16
+ exports.applySegmentPriceFloor = applySegmentPriceFloor;
14
17
  exports.convertOrderEngineItemToOrderItem = convertOrderEngineItemToOrderItem;
15
18
  exports.convertItemDiscountToOrderItemDiscount = convertItemDiscountToOrderItemDiscount;
16
19
  exports.convertCatalogItemToOrderEngineItem = convertCatalogItemToOrderEngineItem;
@@ -163,6 +166,11 @@ function syncOrderEngineItem(orderEngineItem) {
163
166
  const option = modifier.options[j];
164
167
  if (!option.default)
165
168
  continue;
169
+ // `is_free` means NOT charged (the cart math —
170
+ // `calculateItemModifiersPrice` — skips them too): free options keep
171
+ // their price for reference but must never add to the totals.
172
+ if (option.is_free)
173
+ continue;
166
174
  const quantity = option.quantity || 1;
167
175
  // Add option price to total
168
176
  total += (option.price || 0) * quantity;
@@ -303,11 +311,16 @@ function makeSpaceForFreeOptions(options, num_free_options) {
303
311
  * baked into the option price at conversion. choose_expensive compares every
304
312
  * segment option (option price + required/price-defining modifier prices —
305
313
  * e.g. a "Pizza Size" group whose Small/Large/X-Large options are part of the
306
- * item's price) and levels the cheaper ones to the most expensive SELECTED
314
+ * item's price) and levels the cheaper PICK to the most expensive SELECTED
307
315
  * half — `A($5)+B($5)` charges 5+5, `B($5)+C($6)` charges 6+6, and switching
308
- * `C+D -> A+B` lowers them again. Unselected options are levelled too, so the
309
- * drawer can SHOW what an option would cost before it is picked (they never
310
- * contribute to totals while unselected). The raise is applied to the FIRST
316
+ * `C+D -> A+B` lowers them again. Every option is levelled to `max(own value,
317
+ * the max of the OTHER segments' selected values)` — the level its OWN pick
318
+ * would produce: choosing an unselected sibling REPLACES its segment's
319
+ * current pick, so that pick never inflates its own siblings' prices (a
320
+ * segment holding the expensive half keeps its other options at their own
321
+ * prices — you can only pick the next half from the NEXT segment), while a
322
+ * segment with no pick yet previews the full level. Unselected options never
323
+ * contribute to totals. The raise is applied to the FIRST
311
324
  * PRICED element along the segment's price chain: the segment option's own
312
325
  * price when non-zero, else the first priced required leaf ("First Half ->
313
326
  * ROMA -> Pizza Size -> Large 13"") — see `findRaiseTarget`. Optional/upsell
@@ -346,26 +359,6 @@ function applyChooseExpensiveSegmentPrice(orderEngineItem, options) {
346
359
  * (ids are BSON ObjectIds so `_` is unambiguous).
347
360
  */
348
361
  const buildOptionPath = (modifierPath, optionId) => `${modifierPath}_${optionId}`;
349
- /**
350
- * Records the ORIGINAL price of every option in the engine tree, keyed by its
351
- * option path (see `TOrderEnginePriceReferences`). One walk, no copies — the
352
- * map is the engine's memory for reversible price normalization.
353
- */
354
- function getOrderEnginePriceReferences(orderEngineItem) {
355
- const references = {};
356
- const walk = (modifiers, parentPath) => {
357
- modifiers.forEach((modifier) => {
358
- const modifierPath = parentPath ? `${parentPath}_${modifier._id}` : modifier._id;
359
- (modifier.options ?? []).forEach((option) => {
360
- const optionPath = buildOptionPath(modifierPath, option._id);
361
- references[optionPath] = option.price ?? 0;
362
- walk(option.modifiers ?? [], optionPath);
363
- });
364
- });
365
- };
366
- walk(orderEngineItem.modifiers ?? [], '');
367
- return references;
368
- }
369
362
  /**
370
363
  * Re-bases engine option prices from `references` (option path -> original
371
364
  * price). The scope decides WHICH options are re-based:
@@ -408,6 +401,73 @@ function rebaseEngineOptionPrices(modifiers, references, parentPath, scope, insi
408
401
  });
409
402
  return treeChanged ? nextModifiers : modifiers;
410
403
  }
404
+ /**
405
+ * The option a required (price-defining) group contributes to the segment
406
+ * value: the SELECTED (default) one for a multi-option group, or the only
407
+ * option of a single-option group — never an unselected sibling.
408
+ */
409
+ function getSelectedRequiredOption(modifier) {
410
+ const options = modifier.options ?? [];
411
+ return options.find((option) => option.default) ?? (options.length === 1 ? options[0] : null);
412
+ }
413
+ /** Required (price-defining) group: at least one selection is mandatory. */
414
+ function isRequiredModifierGroup(modifier) {
415
+ return ((modifier.min_num_options != null && modifier.min_num_options > 0) ||
416
+ (modifier.min_aggregate_options_quantity != null && modifier.min_aggregate_options_quantity > 0));
417
+ }
418
+ /**
419
+ * Value of the SELECTED option of every required (price-defining) modifier
420
+ * group, at any depth — e.g. "Pizza Size" -> "Large 13"" is part of the
421
+ * item's price whichever size is picked, and only the picked size is charged.
422
+ * Optional/upsell groups, unselected siblings and the add-ons chosen on top of
423
+ * the item are excluded: they must not influence the comparison.
424
+ */
425
+ function getRequiredOptionPrices(modifiers) {
426
+ let total = 0;
427
+ (modifiers ?? []).forEach((modifier) => {
428
+ if (!isRequiredModifierGroup(modifier))
429
+ return;
430
+ const selected = getSelectedRequiredOption(modifier);
431
+ if (selected == null)
432
+ return;
433
+ total += (selected.price ?? 0) * (selected.quantity || 1);
434
+ total += getRequiredOptionPrices(selected.modifiers);
435
+ });
436
+ return total;
437
+ }
438
+ /**
439
+ * Value `choose_expensive_segment_price` compares and levels: the option price
440
+ * (base + item/option level upsell, merged at conversion) + the prices of its
441
+ * SELECTED required (price-defining) options. Exposed so callers that show a
442
+ * price for a single segment (e.g. the segment customization drawer) use the
443
+ * SAME math.
444
+ */
445
+ function getOrderEngineOptionSegmentValue(option) {
446
+ return (option.price ?? 0) + getRequiredOptionPrices(option.modifiers);
447
+ }
448
+ /**
449
+ * First priced required leaf reachable from `modifiers` (direct children):
450
+ * the single option of a single-option required group (its price is fixed —
451
+ * e.g. "ROMA -> Pizza Size -> Large 13""), or the selected/default option
452
+ * of a multi-option required group (never an unselected sibling).
453
+ */
454
+ function findPricedRequiredLeaf(modifiers) {
455
+ for (const modifier of modifiers ?? []) {
456
+ if (!isRequiredModifierGroup(modifier))
457
+ continue;
458
+ const candidate = getSelectedRequiredOption(modifier);
459
+ if (candidate != null && (candidate.price ?? 0) > 0)
460
+ return candidate;
461
+ }
462
+ return null;
463
+ }
464
+ /** Raises the option `targetId` inside its (direct) modifier group by `delta`. */
465
+ function raiseOptionPriceInModifiers(modifiers, targetId, delta) {
466
+ return modifiers.map((modifier) => ({
467
+ ...modifier,
468
+ options: modifier.options.map((option) => option._id === targetId ? { ...option, price: (option.price ?? 0) + delta } : option),
469
+ }));
470
+ }
411
471
  /**
412
472
  * Core `choose_expensive_segment_price` normalization over a list of segment
413
473
  * groups (single-select: one option per group). Used for standalone HALF_HALF
@@ -418,57 +478,14 @@ function rebaseEngineOptionPrices(modifiers, references, parentPath, scope, insi
418
478
  * segment), otherwise the raised segment groups.
419
479
  */
420
480
  function applyChooseExpensiveSegmentPriceToModifiers(segmentGroups) {
421
- // Prices of ALL options of required (price-defining) modifier groups, at
422
- // any depth — e.g. "Pizza Size" -> "Large 13"" is part of the item's price
423
- // whichever size is picked (mirrors `getSegmentItemTotalPrice` used by the
424
- // modern workable converter). Optional/upsell modifier groups are excluded:
425
- // they add on top and must not influence the comparison.
426
- const getRequiredOptionPrices = (modifiers) => {
427
- let total = 0;
428
- (modifiers ?? []).forEach((modifier) => {
429
- const isRequired = (modifier.min_num_options != null && modifier.min_num_options > 0) ||
430
- (modifier.min_aggregate_options_quantity != null && modifier.min_aggregate_options_quantity > 0);
431
- if (!isRequired)
432
- return;
433
- (modifier.options ?? []).forEach((option) => {
434
- total += (option.price ?? 0) * (option.quantity || 1);
435
- total += getRequiredOptionPrices(option.modifiers);
436
- });
437
- });
438
- return total;
439
- };
440
- // Segment price = option price (base + item/option level upsell, already
441
- // merged at conversion) + required (price-defining) modifier prices.
442
- const getSegmentTotal = (option) => (option.price ?? 0) + getRequiredOptionPrices(option.modifiers);
443
481
  // One selected option per segment group (segments are single-select).
444
- const selections = [];
445
- for (let g = 0; g < segmentGroups.length; g++) {
446
- const options = segmentGroups[g].options ?? [];
447
- for (let o = 0; o < options.length; o++) {
448
- const option = options[o];
449
- if (!option.default || option.is_free)
450
- continue;
451
- selections.push({ groupIndex: g, optionIndex: o });
452
- break; // single-select: at most one selected option
453
- }
454
- }
455
- if (selections.length === 0)
482
+ const selections = segmentGroups.map((group) => (group.options ?? []).find((option) => option.default && !option.is_free) ?? null);
483
+ if (selections.every((selection) => selection == null))
456
484
  return null;
457
- // Max over the SELECTED segment options only — the expensive half is the
458
- // most expensive one the user actually PICKED, not the setup's global max:
459
- // picking A($5)+B($5) must charge 5+5 even though C($6)/D($6) exist.
460
- // Free options never drive the comparison.
461
- let maxSegmentValue = 0;
462
- for (const selection of selections) {
463
- const option = segmentGroups[selection.groupIndex].options[selection.optionIndex];
464
- if (option.is_free)
465
- continue;
466
- const segmentValue = getSegmentTotal(option);
467
- if (segmentValue > maxSegmentValue) {
468
- maxSegmentValue = segmentValue;
469
- }
470
- }
471
- if (maxSegmentValue <= 0)
485
+ // Value of every segment's SELECTED option — only picks are charged, and
486
+ // only picks drive the level.
487
+ const selectedValues = selections.map((selection) => selection == null ? 0 : getOrderEngineOptionSegmentValue(selection));
488
+ if (Math.max(...selectedValues, 0) <= 0)
472
489
  return null;
473
490
  // RULE for where the raise lands: on the FIRST PRICED element along the
474
491
  // segment's price chain —
@@ -481,54 +498,43 @@ function applyChooseExpensiveSegmentPriceToModifiers(segmentGroups) {
481
498
  // 3. otherwise, the segment option's own price (even when 0).
482
499
  // This keeps the raise where the price actually lives and never invents a
483
500
  // price on an empty slot or an unselected option.
484
- const findRaiseTarget = (option) => {
485
- if ((option.price ?? 0) > 0)
486
- return option;
487
- for (const modifier of option.modifiers ?? []) {
488
- const isRequired = (modifier.min_num_options != null && modifier.min_num_options > 0) ||
489
- (modifier.min_aggregate_options_quantity != null && modifier.min_aggregate_options_quantity > 0);
490
- if (!isRequired)
491
- continue;
492
- const options = modifier.options ?? [];
493
- const candidate = options.length === 1 ? options[0] : (options.find((opt) => opt.default) ?? null);
494
- if (candidate != null && (candidate.price ?? 0) > 0)
495
- return candidate;
496
- }
497
- return null;
498
- };
501
+ const findRaiseTarget = (option) => (option.price ?? 0) > 0 ? option : findPricedRequiredLeaf(option.modifiers);
499
502
  const raiseSegmentOption = (option, delta) => {
500
503
  const target = findRaiseTarget(option);
501
504
  if (target == null || target._id === option._id) {
502
505
  return { ...option, price: (option.price ?? 0) + delta };
503
506
  }
507
+ return { ...option, modifiers: raiseOptionPriceInModifiers(option.modifiers, target._id, delta) };
508
+ };
509
+ // Every option is levelled to `max(own value, the max of the OTHER
510
+ // segments' selected values)` — the level its OWN pick would produce:
511
+ // - the selected option of a segment is CHARGED that way (the most
512
+ // expensive selected half drives every pick),
513
+ // - an unselected SIBLING replaces its segment's current pick when
514
+ // chosen, so that pick must not inflate the sibling's price (the
515
+ // expensive half's own list keeps its other options at their prices),
516
+ // - every option of a segment with no pick yet previews the full level
517
+ // (what picking it right now would cost).
518
+ // Free (`is_free`) options never drive the comparison and are never raised.
519
+ return segmentGroups.map((modifier, groupIndex) => {
520
+ const otherSegmentsMax = Math.max(...selectedValues.filter((_, index) => index !== groupIndex), 0);
504
521
  return {
505
- ...option,
506
- modifiers: option.modifiers.map((modifier) => ({
507
- ...modifier,
508
- options: modifier.options.map((opt) => opt._id === target._id ? { ...opt, price: (opt.price ?? 0) + delta } : opt),
509
- })),
522
+ ...modifier,
523
+ options: (modifier.options ?? []).map((option) => {
524
+ if (option.is_free)
525
+ return option;
526
+ const segmentValue = getOrderEngineOptionSegmentValue(option);
527
+ const target = Math.max(segmentValue, otherSegmentsMax);
528
+ if (target <= segmentValue)
529
+ return option;
530
+ // Level by the difference so the option's final segment value
531
+ // (base + upsell + required modifiers) equals the target — applied
532
+ // to the priced leaf when available (see `raiseSegmentOption`). The
533
+ // IHalfHalfSetup upsell (item price) is untouched.
534
+ return raiseSegmentOption(option, target - segmentValue);
535
+ }),
510
536
  };
511
- };
512
- // Every option whose segment price is below that max is levelled to it:
513
- // selected halves are CHARGED that way, unselected ones SHOW what they would
514
- // cost if picked (they never contribute to totals while unselected), and
515
- // free options are never raised.
516
- return segmentGroups.map((modifier) => ({
517
- ...modifier,
518
- options: (modifier.options ?? []).map((option) => {
519
- if (option.is_free)
520
- return option;
521
- const segmentValue = getSegmentTotal(option);
522
- // Already at (or above) the most expensive selected segment: keep as is.
523
- if (segmentValue >= maxSegmentValue)
524
- return option;
525
- // Level by the difference so the segment's final price (base + upsell +
526
- // required modifiers) equals the expensive selected half — applied to
527
- // the priced leaf when available (see `raiseSegmentOption`). The
528
- // IHalfHalfSetup upsell (item price) is untouched.
529
- return raiseSegmentOption(option, maxSegmentValue - segmentValue);
530
- }),
531
- }));
537
+ });
532
538
  }
533
539
  /**
534
540
  * True when the item has a top-level modifier group option that is a nested
@@ -537,6 +543,84 @@ function applyChooseExpensiveSegmentPriceToModifiers(segmentGroups) {
537
543
  function hasFlaggedHalfHalfOption(orderEngineItem) {
538
544
  return (orderEngineItem.modifiers ?? []).some((modifier) => (modifier.options ?? []).some((option) => option.ref_type === constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.HALF_HALF && option.choose_expensive_segment_price === true));
539
545
  }
546
+ /**
547
+ * Half-half selection rule: an item may fill at most `segments - 1` halves —
548
+ * it may never make ALL sides of the half-half (otherwise it is not a half-half
549
+ * anymore). Returns the option PATHS that would complete "all sides" when
550
+ * selected, formatted exactly like `setCheckFieldInOrderEngineItem`
551
+ * identifiers (`seg-2_roma`, `mod-pizza_halfhalf-1_seg-2_milan`), so callers
552
+ * can block, guard and label them.
553
+ *
554
+ * Handles both shapes:
555
+ * - a HALF_HALF item (its top-level groups are the segments — pass
556
+ * `isHalfHalfSegmentItem: false`),
557
+ * - a flagged half-half option nested in a SPECIAL (its own modifier groups
558
+ * are the segments).
559
+ * A drawer opened for a single half-half SEGMENT passes
560
+ * `isHalfHalfSegmentItem: true` so the item's own option groups are never
561
+ * treated as segments.
562
+ */
563
+ function getBlockedHalfHalfOptionPaths(orderEngineItem, isHalfHalfSegmentItem = false) {
564
+ const blocked = new Set();
565
+ const blockSegments = (segments, segmentsPath) => {
566
+ const total = segments.length;
567
+ if (total < 2)
568
+ return;
569
+ const selectedBySegment = segments.map((segment) => segment.options.find((option) => option.default) ?? null);
570
+ segments.forEach((segment, index) => {
571
+ const segmentPath = segmentsPath ? `${segmentsPath}_${segment._id}` : segment._id;
572
+ segment.options.forEach((option) => {
573
+ const others = selectedBySegment.filter((selected, otherIndex) => otherIndex !== index && selected != null && selected._id === option._id).length;
574
+ if (others >= total - 1) {
575
+ blocked.add(`${segmentPath}_${option._id}`);
576
+ }
577
+ });
578
+ });
579
+ };
580
+ const walkNestedHalfHalf = (modifiers, parentPath) => {
581
+ modifiers.forEach((modifier) => {
582
+ const modifierPath = parentPath ? `${parentPath}_${modifier._id}` : modifier._id;
583
+ modifier.options.forEach((option) => {
584
+ const optionPath = `${modifierPath}_${option._id}`;
585
+ if (option.ref_type === constants_1.MODIFIER_OPTION_REF_TYPE_ENUM.HALF_HALF &&
586
+ option.choose_expensive_segment_price === true) {
587
+ blockSegments(option.modifiers ?? [], optionPath);
588
+ }
589
+ walkNestedHalfHalf(option.modifiers ?? [], optionPath);
590
+ });
591
+ });
592
+ };
593
+ if (orderEngineItem.item_type === constants_1.ORDER_ITEM_TYPE_ENUM.HALF_HALF && !isHalfHalfSegmentItem) {
594
+ blockSegments((orderEngineItem.modifiers ?? []).filter((modifier) => modifier.depth === 0), '');
595
+ }
596
+ walkNestedHalfHalf(orderEngineItem.modifiers ?? [], '');
597
+ return blocked;
598
+ }
599
+ /**
600
+ * Same half-half selection rule for the MODERN selection list (no engine tree
601
+ * yet): the item ids that cannot be picked for `segmentIndex` because doing so
602
+ * would make them occupy every segment. `segmentIndex` is the segment being
603
+ * picked/edited (its own current item does not count against itself).
604
+ */
605
+ function getHalfHalfBlockedItemIds(orderItems, segmentIndex) {
606
+ if (segmentIndex == null)
607
+ return [];
608
+ const totalSegments = orderItems.length;
609
+ if (totalSegments < 2)
610
+ return [];
611
+ const blocked = [];
612
+ const checked = new Set();
613
+ orderItems.forEach((orderItem) => {
614
+ if (orderItem == null || checked.has(orderItem.item_id))
615
+ return;
616
+ checked.add(orderItem.item_id);
617
+ const others = orderItems.filter((other, index) => index !== segmentIndex && other != null && other.item_id === orderItem.item_id).length;
618
+ if (others >= totalSegments - 1) {
619
+ blocked.push(orderItem.item_id);
620
+ }
621
+ });
622
+ return blocked;
623
+ }
540
624
  /**
541
625
  * `choose_expensive_segment_price` for a half-half option nested in a special:
542
626
  * the option's own top-level modifiers are its segment groups, so they get the
@@ -571,6 +655,37 @@ function applyNestedChooseExpensiveSegmentPrice(orderEngineItem, options) {
571
655
  }));
572
656
  return syncOrderEngineItem({ ...rebased, modifiers });
573
657
  }
658
+ /**
659
+ * Levels the item's segment VALUE (item price + required option prices — the
660
+ * value `getOrderEngineOptionSegmentValue` / `applyChooseExpensiveSegmentPrice`
661
+ * compare) UP to `floorPrice`, using the same raise mechanics as the rule: the
662
+ * raise lands on the FIRST PRICED element — the item price when non-zero,
663
+ * otherwise the first priced required leaf, otherwise the item price.
664
+ *
665
+ * Used by the drawer that edits a SINGLE half-half segment: the half-half
666
+ * screen passes the max value of the OTHER selected halves as the floor, so
667
+ * the drawer shows the amount this segment is actually charged once the
668
+ * choose_expensive rule levels it. It never lowers.
669
+ */
670
+ function applySegmentPriceFloor(orderEngineItem, floorPrice) {
671
+ if (!(floorPrice > 0))
672
+ return orderEngineItem;
673
+ const currentValue = (orderEngineItem.price ?? 0) + getRequiredOptionPrices(orderEngineItem.modifiers);
674
+ const delta = floorPrice - currentValue;
675
+ if (delta <= 0)
676
+ return orderEngineItem;
677
+ if ((orderEngineItem.price ?? 0) > 0) {
678
+ return syncOrderEngineItem({ ...orderEngineItem, price: orderEngineItem.price + delta });
679
+ }
680
+ const target = findPricedRequiredLeaf(orderEngineItem.modifiers);
681
+ if (target == null) {
682
+ return syncOrderEngineItem({ ...orderEngineItem, price: (orderEngineItem.price ?? 0) + delta });
683
+ }
684
+ return syncOrderEngineItem({
685
+ ...orderEngineItem,
686
+ modifiers: raiseOptionPriceInModifiers(orderEngineItem.modifiers, target._id, delta),
687
+ });
688
+ }
574
689
  function convertCatalogItemModifierToOrderEngineItemModifier({ modifiers, orderItemModifiers, platform, tenantId, excludeRefs, zeroPriceRefs, loyaltyRefs, voucherRefs, keepOptionalModifiersAtBottom, soldoutModifiers, depth = 0, priceReferences, parentPath, }) {
575
690
  function getSortedModifiers(modifiers = []) {
576
691
  const sortedModifiers = modifiers.sort((a, b) => a.sort_id - b.sort_id);
@@ -673,6 +788,10 @@ function convertCatalogItemModifierToOrderEngineItemModifier({ modifiers, orderI
673
788
  price: optionPrice,
674
789
  quantity: qty,
675
790
  modifiers: newModifiers,
791
+ // `zeroPriceRefs` (half-half `exclusive_refs`) mutate the PRICE only
792
+ // (`optionPrice` above) — they must never set `is_free`: the "Free"
793
+ // tag belongs exclusively to `num_free_options` options
794
+ // (`makeSpaceForFreeOptions`).
676
795
  is_free,
677
796
  loyalty_applied: false,
678
797
  voucher_applied: false,
@@ -1130,21 +1249,12 @@ function setCheckFieldInOrderEngineItem(orderEngineItem, identifier, shouldCheck
1130
1249
  const allIds = identifier.split('_').filter((id) => id.trim() !== '');
1131
1250
  const modifiers = setUpdateModifiers(orderEngineItem.modifiers, allIds, 0);
1132
1251
  const updatedOrderEngineItem = syncOrderEngineItem({ ...orderEngineItem, modifiers });
1133
- // Half-half classic view: `choose_expensive_segment_price` depends on which
1134
- // halves the user actually picked, so it cannot run during
1135
- // `IHalfHalfSetup -> IItem` conversion — it is applied right here, after
1136
- // every selection, whenever the caller passes the setup flag. It compares
1137
- // EVERY segment option (option base + item upsell + required/price-defining
1138
- // modifiers) and raises the selected ones to the setup's most expensive
1139
- // segment. Idempotent: it never lowers a price, so re-running is safe.
1140
- if (orderEngineItem.item_type === constants_1.ORDER_ITEM_TYPE_ENUM.HALF_HALF && chooseExpensiveSegmentPrice === true) {
1141
- return applyChooseExpensiveSegmentPrice(updatedOrderEngineItem);
1142
- }
1143
- // Half-half option nested in a special: normalize its own segment groups
1144
- // (the option's top-level modifiers) whenever it carries the setup flag.
1145
- if (orderEngineItem.item_type === constants_1.ORDER_ITEM_TYPE_ENUM.SPECIAL && hasFlaggedHalfHalfOption(updatedOrderEngineItem)) {
1146
- return applyNestedChooseExpensiveSegmentPrice(updatedOrderEngineItem);
1147
- }
1252
+ // `choose_expensive_segment_price` is NOT applied here: price normalization
1253
+ // has a single entry point (`applyChooseExpensiveSegmentPrice` /
1254
+ // `applyNestedChooseExpensiveSegmentPrice`, called with the original price
1255
+ // references by the drawer after this mutation). The flag parameter is kept
1256
+ // for API compatibility and ignored.
1257
+ void chooseExpensiveSegmentPrice;
1148
1258
  return updatedOrderEngineItem;
1149
1259
  }
1150
1260
  function setIncrementOrderEngineItemQuantity(orderEngineItem, increment) {
@@ -0,0 +1 @@
1
+ export {};