@pisell/pisellos 2.3.119 → 2.3.121
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.
|
@@ -31,9 +31,6 @@ export interface SmallTicketItem {
|
|
|
31
31
|
product_uid?: string | number;
|
|
32
32
|
booking_uid?: string | number;
|
|
33
33
|
}
|
|
34
|
-
export type SmallTicketDeliveryItem = Omit<SmallTicketItem, 'value'> & {
|
|
35
|
-
value?: string;
|
|
36
|
-
};
|
|
37
34
|
export interface SmallTicketProduct {
|
|
38
35
|
product_title: string;
|
|
39
36
|
product_quantity: number;
|
|
@@ -69,7 +66,7 @@ export interface SmallTicketLocaleData {
|
|
|
69
66
|
};
|
|
70
67
|
customer: SmallTicketItem[];
|
|
71
68
|
appointment: SmallTicketAppointment;
|
|
72
|
-
delivery?:
|
|
69
|
+
delivery?: SmallTicketItem[];
|
|
73
70
|
resources: Array<{
|
|
74
71
|
id: string | number;
|
|
75
72
|
code: string;
|
|
@@ -530,7 +530,7 @@ function isSameReceiptDiscount(left, right) {
|
|
|
530
530
|
return leftResourceId === rightResourceId && getReceiptDiscountBundleMapId(left) === getReceiptDiscountBundleMapId(right) && String((_ref10 = (_ref11 = (_left$amount = left === null || left === void 0 ? void 0 : left.amount) !== null && _left$amount !== void 0 ? _left$amount : left === null || left === void 0 ? void 0 : left.value) !== null && _ref11 !== void 0 ? _ref11 : left === null || left === void 0 ? void 0 : left.discount_amount) !== null && _ref10 !== void 0 ? _ref10 : '') === String((_ref12 = (_ref13 = (_right$amount = right === null || right === void 0 ? void 0 : right.amount) !== null && _right$amount !== void 0 ? _right$amount : right === null || right === void 0 ? void 0 : right.value) !== null && _ref13 !== void 0 ? _ref13 : right === null || right === void 0 ? void 0 : right.discount_amount) !== null && _ref12 !== void 0 ? _ref12 : '');
|
|
531
531
|
}
|
|
532
532
|
function resolveProductBasePrice(product) {
|
|
533
|
-
var _product$product_vari, _product$_origin, _product$_origin2;
|
|
533
|
+
var _product$product_vari, _ref14, _ref15, _product$product_quan2, _product$product_sku, _product$_origin, _product$_origin2;
|
|
534
534
|
var metadata = product.metadata || {};
|
|
535
535
|
var origin = product._origin || metadata.origin || {};
|
|
536
536
|
var variantId = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id;
|
|
@@ -538,7 +538,18 @@ function resolveProductBasePrice(product) {
|
|
|
538
538
|
return isSameId(item === null || item === void 0 ? void 0 : item.id, variantId);
|
|
539
539
|
}) : undefined;
|
|
540
540
|
var isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === '2';
|
|
541
|
-
|
|
541
|
+
var quantity = toNumber((_ref14 = (_ref15 = (_product$product_quan2 = product.product_quantity) !== null && _product$product_quan2 !== void 0 ? _product$product_quan2 : product.quantity) !== null && _ref15 !== void 0 ? _ref15 : product.num) !== null && _ref14 !== void 0 ? _ref14 : 1, 1);
|
|
542
|
+
var hasEntitlementPass = normalizeArray(product.discount_list).some(function (discount) {
|
|
543
|
+
return getProductWalletDiscountType(discount) === 'entitlement_pass';
|
|
544
|
+
});
|
|
545
|
+
var hasOptions = normalizeArray(product.options).length > 0 || normalizeArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option).length > 0;
|
|
546
|
+
var hasCombinations = normalizeArray(product.combinations).length > 0 || normalizeArray(product.product_bundle).length > 0 || normalizeArray(product.bundle).length > 0;
|
|
547
|
+
var aggregateSourcePrice = firstPresentValue(metadata.source_product_price, product.price);
|
|
548
|
+
var originalPrice = product.original_price;
|
|
549
|
+
// 部分旧 entitlement 商品把 source/price 持久化成了整行总价,但
|
|
550
|
+
// original_price 仍是单件价。仅在等式能明确证明该口径时做窄幅回退。
|
|
551
|
+
var useOriginalPriceAsLegacyUnitPrice = hasEntitlementPass && quantity > 1 && !hasOptions && !hasCombinations && isNumericAmount(aggregateSourcePrice) && isNumericAmount(originalPrice) && new Decimal(aggregateSourcePrice).eq(new Decimal(originalPrice).mul(quantity));
|
|
552
|
+
return firstPresentValue(useOriginalPriceAsLegacyUnitPrice ? originalPrice : undefined, metadata.source_product_price, variant === null || variant === void 0 ? void 0 : variant.price, (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.price, (_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.base_price, !isV2 ? metadata.main_product_original_price : undefined, product.base_price, product.price);
|
|
542
553
|
}
|
|
543
554
|
function normalizeProductDiscounts(params) {
|
|
544
555
|
var product = params.product,
|
|
@@ -546,16 +557,17 @@ function normalizeProductDiscounts(params) {
|
|
|
546
557
|
currencySymbol = params.currencySymbol,
|
|
547
558
|
quantity = params.quantity;
|
|
548
559
|
var rows = normalizeArray(product.discount_list).filter(function (discount) {
|
|
549
|
-
var
|
|
550
|
-
var amount = (
|
|
560
|
+
var _ref16, _discount$amount;
|
|
561
|
+
var amount = (_ref16 = (_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.value) !== null && _ref16 !== void 0 ? _ref16 : discount.discount_amount;
|
|
551
562
|
return isNonZero(amount);
|
|
552
563
|
}).map(function (discount) {
|
|
553
|
-
var
|
|
564
|
+
var _ref17, _discount$amount2;
|
|
554
565
|
var title = resolveDiscountTitleWithPercent(discount, locale);
|
|
555
|
-
var amount = (
|
|
566
|
+
var amount = (_ref17 = (_discount$amount2 = discount.amount) !== null && _discount$amount2 !== void 0 ? _discount$amount2 : discount.value) !== null && _ref17 !== void 0 ? _ref17 : discount.discount_amount;
|
|
556
567
|
var isMarkup = isManualMarkup(discount);
|
|
557
568
|
var isAggregatedBundleDiscount = Boolean(getReceiptDiscountBundleMapId(discount));
|
|
558
|
-
var
|
|
569
|
+
var isEntitlementPass = getProductWalletDiscountType(discount) === 'entitlement_pass';
|
|
570
|
+
var totalAmount = new Decimal(toMoneyNumber(amount)).mul(isAggregatedBundleDiscount || isEntitlementPass ? 1 : quantity);
|
|
559
571
|
var formattedAmount = isMarkup ? formatMoney(totalAmount.abs(), currencySymbol) : formatNegativeMoney(totalAmount, currencySymbol);
|
|
560
572
|
return {
|
|
561
573
|
item: title,
|
|
@@ -565,24 +577,24 @@ function normalizeProductDiscounts(params) {
|
|
|
565
577
|
});
|
|
566
578
|
return rows.sort(function (left, right) {
|
|
567
579
|
return Number(right.isMarkup) - Number(left.isMarkup);
|
|
568
|
-
}).map(function (
|
|
569
|
-
var _isMarkup =
|
|
570
|
-
row = _objectWithoutProperties(
|
|
580
|
+
}).map(function (_ref18) {
|
|
581
|
+
var _isMarkup = _ref18.isMarkup,
|
|
582
|
+
row = _objectWithoutProperties(_ref18, _excluded);
|
|
571
583
|
return row;
|
|
572
584
|
});
|
|
573
585
|
}
|
|
574
586
|
function isManualMarkup(discount) {
|
|
575
|
-
var _discount$discount,
|
|
587
|
+
var _discount$discount, _ref19, _discount$amount3;
|
|
576
588
|
if (discount.type !== 'product') return false;
|
|
577
589
|
if (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.discount_type) === 'change_price') return true;
|
|
578
|
-
var amount = (
|
|
590
|
+
var amount = (_ref19 = (_discount$amount3 = discount.amount) !== null && _discount$amount3 !== void 0 ? _discount$amount3 : discount.value) !== null && _ref19 !== void 0 ? _ref19 : discount.discount_amount;
|
|
579
591
|
return new Decimal(toMoneyNumber(amount)).isNegative();
|
|
580
592
|
}
|
|
581
593
|
function hasProductDiscount(product) {
|
|
582
594
|
var extensionList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
583
595
|
var hasDiscountListAmount = normalizeArray(product.discount_list).some(function (discount) {
|
|
584
|
-
var
|
|
585
|
-
return isNonZero((
|
|
596
|
+
var _ref20, _discount$amount4;
|
|
597
|
+
return isNonZero((_ref20 = (_discount$amount4 = discount.amount) !== null && _discount$amount4 !== void 0 ? _discount$amount4 : discount.value) !== null && _ref20 !== void 0 ? _ref20 : discount.discount_amount);
|
|
586
598
|
});
|
|
587
599
|
return hasDiscountListAmount || extensionList.some(function (row) {
|
|
588
600
|
return /^\s*-/.test(stringify(row === null || row === void 0 ? void 0 : row.value));
|
|
@@ -667,8 +679,8 @@ function resolveDiscountTitleWithPercent(discount, locale) {
|
|
|
667
679
|
return "".concat(title, " (").concat(percent, "%)");
|
|
668
680
|
}
|
|
669
681
|
function resolveDiscountTitle(discount, locale) {
|
|
670
|
-
var
|
|
671
|
-
var title = getLocalizedValue((
|
|
682
|
+
var _ref21, _ref22, _ref23, _ref24, _discount$discount$na, _discount$discount4, _discount$discount5, _discount$discount6;
|
|
683
|
+
var title = getLocalizedValue((_ref21 = (_ref22 = (_ref23 = (_ref24 = (_discount$discount$na = (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.name) !== null && _discount$discount$na !== void 0 ? _discount$discount$na : (_discount$discount5 = discount.discount) === null || _discount$discount5 === void 0 ? void 0 : _discount$discount5.title) !== null && _ref24 !== void 0 ? _ref24 : (_discount$discount6 = discount.discount) === null || _discount$discount6 === void 0 ? void 0 : _discount$discount6.message) !== null && _ref23 !== void 0 ? _ref23 : discount.name) !== null && _ref22 !== void 0 ? _ref22 : discount.title) !== null && _ref21 !== void 0 ? _ref21 : discount.message, locale);
|
|
672
684
|
if (title) return title;
|
|
673
685
|
if (discount.type === 'product') {
|
|
674
686
|
return label(locale, isManualMarkup(discount) ? 'manualMarkup' : 'manualDiscount');
|
|
@@ -688,17 +700,17 @@ function resolveProductTitle(params) {
|
|
|
688
700
|
return getProductTitleSource(fallbackProduct, locale);
|
|
689
701
|
}
|
|
690
702
|
function normalizeProductOptions(params) {
|
|
691
|
-
var _product$
|
|
703
|
+
var _product$product_sku2;
|
|
692
704
|
var product = params.product,
|
|
693
705
|
locale = params.locale,
|
|
694
706
|
currencySymbol = params.currencySymbol,
|
|
695
707
|
parentProduct = params.parentProduct;
|
|
696
|
-
var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$
|
|
708
|
+
var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$product_sku2 = product.product_sku) === null || _product$product_sku2 === void 0 ? void 0 : _product$product_sku2.option) ? product.product_sku.option : [];
|
|
697
709
|
return rawOptions.map(function (option) {
|
|
698
|
-
var
|
|
699
|
-
var price = (
|
|
700
|
-
var quantity = toNumber((
|
|
701
|
-
var value = (
|
|
710
|
+
var _ref25, _option$original_pric, _ref26, _option$num, _ref27, _option$value;
|
|
711
|
+
var price = (_ref25 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref25 !== void 0 ? _ref25 : option.price;
|
|
712
|
+
var quantity = toNumber((_ref26 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref26 !== void 0 ? _ref26 : 1, 1);
|
|
713
|
+
var value = (_ref27 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref27 !== void 0 ? _ref27 : option.item;
|
|
702
714
|
var name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
|
|
703
715
|
option: option,
|
|
704
716
|
parentProduct: parentProduct,
|
|
@@ -725,7 +737,7 @@ function normalizeProductCombinations(params) {
|
|
|
725
737
|
parentProduct = params.parentProduct;
|
|
726
738
|
var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
727
739
|
return bundles.map(function (bundle) {
|
|
728
|
-
var
|
|
740
|
+
var _ref28, _bundle$num;
|
|
729
741
|
var combinationsOptions = normalizeProductOptions({
|
|
730
742
|
product: {},
|
|
731
743
|
locale: locale,
|
|
@@ -741,7 +753,7 @@ function normalizeProductCombinations(params) {
|
|
|
741
753
|
});
|
|
742
754
|
var productNote = resolveProductNote(bundle, locale);
|
|
743
755
|
var nestedCombinations = Array.isArray(bundle.combinations) ? normalizeExistingCombinations(bundle.combinations, locale, currencySymbol) : [];
|
|
744
|
-
var quantity = toNumber((
|
|
756
|
+
var quantity = toNumber((_ref28 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref28 !== void 0 ? _ref28 : 1, 1);
|
|
745
757
|
var formattedPrice = formatBundlePrice(bundle, currencySymbol);
|
|
746
758
|
var optionsTotal = sumNormalizedOptionTotals(combinationsOptions, currencySymbol);
|
|
747
759
|
var explicitBasePrice = resolveCombinationBasePrice(bundle);
|
|
@@ -778,7 +790,7 @@ function normalizeProductCombinations(params) {
|
|
|
778
790
|
}
|
|
779
791
|
function normalizeExistingCombinations(combinations, locale, currencySymbol) {
|
|
780
792
|
return combinations.map(function (combination) {
|
|
781
|
-
var
|
|
793
|
+
var _ref29, _ref30, _combination$product_, _firstPresentValue;
|
|
782
794
|
if (!combination || _typeof(combination) !== 'object' || Array.isArray(combination)) {
|
|
783
795
|
return combination;
|
|
784
796
|
}
|
|
@@ -796,7 +808,7 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
|
|
|
796
808
|
delete snapshot.note;
|
|
797
809
|
delete snapshot.combinations;
|
|
798
810
|
delete snapshot.discount_list;
|
|
799
|
-
var quantity = toNumber((
|
|
811
|
+
var quantity = toNumber((_ref29 = (_ref30 = (_combination$product_ = combination.product_quantity) !== null && _combination$product_ !== void 0 ? _combination$product_ : combination.num) !== null && _ref30 !== void 0 ? _ref30 : combination.quantity) !== null && _ref29 !== void 0 ? _ref29 : 1, 1);
|
|
800
812
|
var unitPrice = (_firstPresentValue = firstPresentValue(combination.selling_price, combination.price, combination.original_price)) !== null && _firstPresentValue !== void 0 ? _firstPresentValue : 0;
|
|
801
813
|
var optionsAmount = sumMoneyValues(normalizedOptions.map(function (option) {
|
|
802
814
|
return option.total_price;
|
|
@@ -879,7 +891,7 @@ function buildProductAllergyMap(order, locale) {
|
|
|
879
891
|
return allergyByProductUid;
|
|
880
892
|
}
|
|
881
893
|
function resolveBundleProductTitle(params) {
|
|
882
|
-
var
|
|
894
|
+
var _ref31, _ref32, _bundle$bundle_produc;
|
|
883
895
|
var bundle = params.bundle,
|
|
884
896
|
productMap = params.productMap,
|
|
885
897
|
locale = params.locale,
|
|
@@ -892,7 +904,7 @@ function resolveBundleProductTitle(params) {
|
|
|
892
904
|
});
|
|
893
905
|
var parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
|
|
894
906
|
if (parentBundleTitle) return parentBundleTitle;
|
|
895
|
-
var productId = (
|
|
907
|
+
var productId = (_ref31 = (_ref32 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref32 !== void 0 ? _ref32 : bundle.product_id) !== null && _ref31 !== void 0 ? _ref31 : bundle.id;
|
|
896
908
|
var fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
897
909
|
if (!fallbackProduct) return '';
|
|
898
910
|
return getProductTitleSource(fallbackProduct, locale);
|
|
@@ -944,10 +956,10 @@ function resolveVariantTextFromSkuKey(params) {
|
|
|
944
956
|
}
|
|
945
957
|
function resolveVariantTextFromNameMap(params) {
|
|
946
958
|
if (!params.nameMap || _typeof(params.nameMap) !== 'object') return '';
|
|
947
|
-
return Object.entries(params.nameMap).map(function (
|
|
948
|
-
var
|
|
949
|
-
groupPositionId =
|
|
950
|
-
value =
|
|
959
|
+
return Object.entries(params.nameMap).map(function (_ref33) {
|
|
960
|
+
var _ref34 = _slicedToArray(_ref33, 2),
|
|
961
|
+
groupPositionId = _ref34[0],
|
|
962
|
+
value = _ref34[1];
|
|
951
963
|
var group = resolveVariantGroup(params.parentProduct, groupPositionId);
|
|
952
964
|
if (!group) return '';
|
|
953
965
|
var groupName = getLocalizedValue(group.name, params.locale);
|
|
@@ -981,12 +993,12 @@ function getProductTitleSource(source, locale) {
|
|
|
981
993
|
return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
|
|
982
994
|
}
|
|
983
995
|
function resolveTitleValue(value, locale) {
|
|
984
|
-
var
|
|
996
|
+
var _ref35, _ref36, _ref37, _ref38, _value$locale;
|
|
985
997
|
if (value === undefined || value === null) return '';
|
|
986
998
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
987
999
|
var dashedLocale = locale.replace('_', '-');
|
|
988
1000
|
var underscoredLocale = locale.replace('-', '_');
|
|
989
|
-
return stringify((
|
|
1001
|
+
return stringify((_ref35 = (_ref36 = (_ref37 = (_ref38 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref38 !== void 0 ? _ref38 : value[underscoredLocale]) !== null && _ref37 !== void 0 ? _ref37 : value.original) !== null && _ref36 !== void 0 ? _ref36 : value.auto) !== null && _ref35 !== void 0 ? _ref35 : '');
|
|
990
1002
|
}
|
|
991
1003
|
function resolveOptionTitleFromParentProduct(params) {
|
|
992
1004
|
var option = params.option,
|
|
@@ -1004,17 +1016,17 @@ function flattenOptionItems(parentProduct) {
|
|
|
1004
1016
|
return optionGroups.flatMap(function (group) {
|
|
1005
1017
|
var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
|
|
1006
1018
|
return items.map(function (item) {
|
|
1007
|
-
var
|
|
1019
|
+
var _ref39, _item$option_group_id;
|
|
1008
1020
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1009
|
-
option_group_id: (
|
|
1021
|
+
option_group_id: (_ref39 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref39 !== void 0 ? _ref39 : group.option_group_id
|
|
1010
1022
|
});
|
|
1011
1023
|
});
|
|
1012
1024
|
});
|
|
1013
1025
|
}
|
|
1014
1026
|
function isOptionItemMatch(option, item) {
|
|
1015
|
-
var
|
|
1016
|
-
var optionItemId = (
|
|
1017
|
-
var itemId = (
|
|
1027
|
+
var _ref40, _option$option_group_, _ref41, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
|
|
1028
|
+
var optionItemId = (_ref40 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref40 !== void 0 ? _ref40 : option.id;
|
|
1029
|
+
var itemId = (_ref41 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref41 !== void 0 ? _ref41 : item.id;
|
|
1018
1030
|
if (!isSameId(optionItemId, itemId)) return false;
|
|
1019
1031
|
var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
|
|
1020
1032
|
var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
|
|
@@ -1024,16 +1036,16 @@ function isOptionItemMatch(option, item) {
|
|
|
1024
1036
|
return true;
|
|
1025
1037
|
}
|
|
1026
1038
|
function resolveBundleItemFromParentProduct(params) {
|
|
1027
|
-
var
|
|
1039
|
+
var _ref42, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref44, _bundle$bundle_produc2;
|
|
1028
1040
|
var bundle = params.bundle,
|
|
1029
1041
|
parentProduct = params.parentProduct;
|
|
1030
1042
|
if (!parentProduct) return null;
|
|
1031
1043
|
var bundleItems = flattenBundleItems(parentProduct);
|
|
1032
|
-
var bundleVariantId = (
|
|
1044
|
+
var bundleVariantId = (_ref42 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref42 !== void 0 ? _ref42 : bundle.product_variant_id;
|
|
1033
1045
|
if (isNonZeroId(bundleVariantId)) {
|
|
1034
1046
|
var matchedByVariant = bundleItems.find(function (item) {
|
|
1035
|
-
var
|
|
1036
|
-
return isSameId((
|
|
1047
|
+
var _ref43, _item$bundle_variant_;
|
|
1048
|
+
return isSameId((_ref43 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref43 !== void 0 ? _ref43 : item.product_variant_id, bundleVariantId);
|
|
1037
1049
|
});
|
|
1038
1050
|
if (matchedByVariant) return matchedByVariant;
|
|
1039
1051
|
}
|
|
@@ -1046,18 +1058,18 @@ function resolveBundleItemFromParentProduct(params) {
|
|
|
1046
1058
|
if (matchedByBundleId) return matchedByBundleId;
|
|
1047
1059
|
}
|
|
1048
1060
|
var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
1049
|
-
var bundleProductId = (
|
|
1061
|
+
var bundleProductId = (_ref44 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref44 !== void 0 ? _ref44 : bundle.product_id;
|
|
1050
1062
|
if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
|
|
1051
1063
|
var matchedByGroupAndProduct = bundleItems.find(function (item) {
|
|
1052
|
-
var _item$group_id,
|
|
1053
|
-
return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((
|
|
1064
|
+
var _item$group_id, _ref45, _item$bundle_product_;
|
|
1065
|
+
return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref45 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref45 !== void 0 ? _ref45 : item.product_id, bundleProductId);
|
|
1054
1066
|
});
|
|
1055
1067
|
if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
|
|
1056
1068
|
}
|
|
1057
1069
|
if (isPresentId(bundleProductId)) {
|
|
1058
1070
|
return bundleItems.find(function (item) {
|
|
1059
|
-
var
|
|
1060
|
-
return isSameId((
|
|
1071
|
+
var _ref46, _item$bundle_product_2;
|
|
1072
|
+
return isSameId((_ref46 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref46 !== void 0 ? _ref46 : item.product_id, bundleProductId);
|
|
1061
1073
|
}) || null;
|
|
1062
1074
|
}
|
|
1063
1075
|
return null;
|
|
@@ -1067,9 +1079,9 @@ function flattenBundleItems(parentProduct) {
|
|
|
1067
1079
|
return bundleGroups.flatMap(function (group) {
|
|
1068
1080
|
var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
|
|
1069
1081
|
return items.map(function (item) {
|
|
1070
|
-
var
|
|
1082
|
+
var _ref47, _item$group_id2;
|
|
1071
1083
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1072
|
-
group_id: (
|
|
1084
|
+
group_id: (_ref47 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref47 !== void 0 ? _ref47 : group.group_id
|
|
1073
1085
|
});
|
|
1074
1086
|
});
|
|
1075
1087
|
});
|
|
@@ -1093,8 +1105,8 @@ function isSameId(left, right) {
|
|
|
1093
1105
|
return String(left) === String(right);
|
|
1094
1106
|
}
|
|
1095
1107
|
function formatBundlePrice(bundle, currencySymbol) {
|
|
1096
|
-
var
|
|
1097
|
-
var value = (
|
|
1108
|
+
var _ref48, _ref49, _bundle$bundle_sellin;
|
|
1109
|
+
var value = (_ref48 = (_ref49 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref49 !== void 0 ? _ref49 : bundle.price) !== null && _ref48 !== void 0 ? _ref48 : 0;
|
|
1098
1110
|
var amount = new Decimal(toMoneyNumber(value));
|
|
1099
1111
|
// 套餐价格协议:只有 markdown 是减价;加价与商品原价都保持正数。
|
|
1100
1112
|
var isNegative = bundle.price_type === 'markdown';
|
|
@@ -1112,9 +1124,9 @@ function buildFees(params) {
|
|
|
1112
1124
|
financials = params.financials;
|
|
1113
1125
|
var fees = [];
|
|
1114
1126
|
for (var _i2 = 0, _normalizeArray2 = normalizeArray(order.surcharges || summary.surcharges); _i2 < _normalizeArray2.length; _i2++) {
|
|
1115
|
-
var
|
|
1127
|
+
var _ref50, _surcharge$amount;
|
|
1116
1128
|
var surcharge = _normalizeArray2[_i2];
|
|
1117
|
-
var value = (
|
|
1129
|
+
var value = (_ref50 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref50 !== void 0 ? _ref50 : surcharge.total_amount;
|
|
1118
1130
|
if (!isNonZero(value)) continue;
|
|
1119
1131
|
fees.push({
|
|
1120
1132
|
item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
|
|
@@ -1216,9 +1228,9 @@ function resolveTaxTitle(params) {
|
|
|
1216
1228
|
}
|
|
1217
1229
|
function calculateProductOriginalAmount(order) {
|
|
1218
1230
|
return normalizeArray(order.products).reduce(function (total, product) {
|
|
1219
|
-
var
|
|
1220
|
-
var quantity = toNumber((
|
|
1221
|
-
var originalPrice = (
|
|
1231
|
+
var _ref51, _ref52, _product$product_quan3, _ref53, _ref54, _ref55, _product$original_pri2;
|
|
1232
|
+
var quantity = toNumber((_ref51 = (_ref52 = (_product$product_quan3 = product.product_quantity) !== null && _product$product_quan3 !== void 0 ? _product$product_quan3 : product.quantity) !== null && _ref52 !== void 0 ? _ref52 : product.num) !== null && _ref51 !== void 0 ? _ref51 : 1, 1);
|
|
1233
|
+
var originalPrice = (_ref53 = (_ref54 = (_ref55 = (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : product.selling_price) !== null && _ref55 !== void 0 ? _ref55 : product.payment_price) !== null && _ref54 !== void 0 ? _ref54 : product.price) !== null && _ref53 !== void 0 ? _ref53 : 0;
|
|
1222
1234
|
return total.plus(new Decimal(toMoneyNumber(originalPrice)).mul(quantity));
|
|
1223
1235
|
}, new Decimal(0));
|
|
1224
1236
|
}
|
|
@@ -1248,6 +1260,7 @@ function buildDelivery(order, locale) {
|
|
|
1248
1260
|
if (!serviceTypeLabelKey) return [];
|
|
1249
1261
|
var items = [{
|
|
1250
1262
|
item: label(locale, serviceTypeLabelKey),
|
|
1263
|
+
value: '',
|
|
1251
1264
|
size: 2
|
|
1252
1265
|
}];
|
|
1253
1266
|
var handoverTime = firstPresentValue(order.handover_time, order.handover_at, order.pickup_time, order.pickup_at, order.scheduled_pickup_time, order.delivery_time, order.delivery_at, order.scheduled_delivery_time, order.fulfillment_time, order.fulfillment_at, (_order$metadata3 = order.metadata) === null || _order$metadata3 === void 0 ? void 0 : _order$metadata3.handover_time, (_order$metadata4 = order.metadata) === null || _order$metadata4 === void 0 ? void 0 : _order$metadata4.handover_at, (_order$metadata5 = order.metadata) === null || _order$metadata5 === void 0 ? void 0 : _order$metadata5.pickup_time, (_order$metadata6 = order.metadata) === null || _order$metadata6 === void 0 ? void 0 : _order$metadata6.pickup_at, (_order$metadata7 = order.metadata) === null || _order$metadata7 === void 0 ? void 0 : _order$metadata7.scheduled_pickup_time, (_order$metadata8 = order.metadata) === null || _order$metadata8 === void 0 ? void 0 : _order$metadata8.delivery_time, (_order$metadata9 = order.metadata) === null || _order$metadata9 === void 0 ? void 0 : _order$metadata9.delivery_at, (_order$metadata10 = order.metadata) === null || _order$metadata10 === void 0 ? void 0 : _order$metadata10.scheduled_delivery_time, (_order$metadata11 = order.metadata) === null || _order$metadata11 === void 0 ? void 0 : _order$metadata11.fulfillment_time, (_order$metadata12 = order.metadata) === null || _order$metadata12 === void 0 ? void 0 : _order$metadata12.fulfillment_at);
|
|
@@ -1260,8 +1273,11 @@ function buildDelivery(order, locale) {
|
|
|
1260
1273
|
return items;
|
|
1261
1274
|
}
|
|
1262
1275
|
function buildAppointment(order, locale) {
|
|
1263
|
-
var _order$metadata13, _order$metadata14, _order$form_data;
|
|
1264
|
-
var
|
|
1276
|
+
var _order$metadata13, _order$metadata14, _order$metadata15, _order$form_data;
|
|
1277
|
+
var parentScheduleId = (_order$metadata13 = order.metadata) === null || _order$metadata13 === void 0 ? void 0 : _order$metadata13.appointment_booking_parent_schedule_id;
|
|
1278
|
+
var bookings = sortBookings(normalizeArray(order.bookings).filter(function (booking) {
|
|
1279
|
+
return isReceiptAppointmentBooking(booking, parentScheduleId);
|
|
1280
|
+
}));
|
|
1265
1281
|
if (bookings.length) {
|
|
1266
1282
|
var allResources = normalizeArray(order.resources || order.resource_list);
|
|
1267
1283
|
return bookings.flatMap(function (booking) {
|
|
@@ -1273,13 +1289,26 @@ function buildAppointment(order, locale) {
|
|
|
1273
1289
|
});
|
|
1274
1290
|
});
|
|
1275
1291
|
}
|
|
1276
|
-
var tableName = order.table_name || ((_order$
|
|
1292
|
+
var tableName = order.table_name || ((_order$metadata14 = order.metadata) === null || _order$metadata14 === void 0 ? void 0 : _order$metadata14.table_name) || ((_order$metadata15 = order.metadata) === null || _order$metadata15 === void 0 || (_order$metadata15 = _order$metadata15.table) === null || _order$metadata15 === void 0 ? void 0 : _order$metadata15.name) || ((_order$form_data = order.form_data) === null || _order$form_data === void 0 ? void 0 : _order$form_data.table_name);
|
|
1277
1293
|
if (!tableName) return [];
|
|
1278
1294
|
return [{
|
|
1279
1295
|
item: label(locale, 'table'),
|
|
1280
1296
|
value: getLocalizedValue(tableName, locale)
|
|
1281
1297
|
}];
|
|
1282
1298
|
}
|
|
1299
|
+
function isReceiptAppointmentBooking(booking, parentScheduleId) {
|
|
1300
|
+
if (!booking || _typeof(booking) !== 'object' || Array.isArray(booking)) {
|
|
1301
|
+
return false;
|
|
1302
|
+
}
|
|
1303
|
+
if (isPresentId(parentScheduleId) && isSameId(booking.schedule_event_id, parentScheduleId)) {
|
|
1304
|
+
return false;
|
|
1305
|
+
}
|
|
1306
|
+
var parentId = booking.parent_id;
|
|
1307
|
+
if (parentId === undefined || parentId === null || parentId === '') {
|
|
1308
|
+
return true;
|
|
1309
|
+
}
|
|
1310
|
+
return Number(parentId) !== 0;
|
|
1311
|
+
}
|
|
1283
1312
|
function buildAppointmentRows(params) {
|
|
1284
1313
|
var _booking$metadata, _booking$metadata2, _booking$holder$name, _booking$holder, _booking$metadata3;
|
|
1285
1314
|
var booking = params.booking,
|
|
@@ -1351,9 +1380,9 @@ function resolveBookingResourcesForReceipt(booking, allResources, bookingCount)
|
|
|
1351
1380
|
_step3;
|
|
1352
1381
|
try {
|
|
1353
1382
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1354
|
-
var
|
|
1383
|
+
var _ref57, _resource$id2;
|
|
1355
1384
|
var resource = _step3.value;
|
|
1356
|
-
var id = stringify((
|
|
1385
|
+
var id = stringify((_ref57 = (_resource$id2 = resource.id) !== null && _resource$id2 !== void 0 ? _resource$id2 : resource.resource_id) !== null && _ref57 !== void 0 ? _ref57 : resource.relation_id).trim();
|
|
1357
1386
|
if (id) resourceIds.add(id);
|
|
1358
1387
|
}
|
|
1359
1388
|
} catch (err) {
|
|
@@ -1363,8 +1392,8 @@ function resolveBookingResourcesForReceipt(booking, allResources, bookingCount)
|
|
|
1363
1392
|
}
|
|
1364
1393
|
if (resourceIds.size) {
|
|
1365
1394
|
var matched = allResources.filter(function (resource) {
|
|
1366
|
-
var
|
|
1367
|
-
return resourceIds.has(stringify((
|
|
1395
|
+
var _ref56, _resource$id;
|
|
1396
|
+
return resourceIds.has(stringify((_ref56 = (_resource$id = resource.id) !== null && _resource$id !== void 0 ? _resource$id : resource.resource_id) !== null && _ref56 !== void 0 ? _ref56 : resource.relation_id).trim());
|
|
1368
1397
|
});
|
|
1369
1398
|
if (matched.length) return matched;
|
|
1370
1399
|
}
|
|
@@ -1397,8 +1426,8 @@ function sortBookings(bookings) {
|
|
|
1397
1426
|
}
|
|
1398
1427
|
var bookingUidOrder = compareOptionalValues(firstPresentValue((_left$booking2 = left.booking) === null || _left$booking2 === void 0 || (_left$booking2 = _left$booking2.metadata) === null || _left$booking2 === void 0 ? void 0 : _left$booking2.unique_identification_number, (_left$booking3 = left.booking) === null || _left$booking3 === void 0 ? void 0 : _left$booking3.booking_uid), firstPresentValue((_right$booking2 = right.booking) === null || _right$booking2 === void 0 || (_right$booking2 = _right$booking2.metadata) === null || _right$booking2 === void 0 ? void 0 : _right$booking2.unique_identification_number, (_right$booking3 = right.booking) === null || _right$booking3 === void 0 ? void 0 : _right$booking3.booking_uid));
|
|
1399
1428
|
return bookingUidOrder || left.index - right.index;
|
|
1400
|
-
}).map(function (
|
|
1401
|
-
var booking =
|
|
1429
|
+
}).map(function (_ref58) {
|
|
1430
|
+
var booking = _ref58.booking;
|
|
1402
1431
|
return booking;
|
|
1403
1432
|
});
|
|
1404
1433
|
}
|
|
@@ -1460,8 +1489,8 @@ function buildRefundData(params) {
|
|
|
1460
1489
|
result.set(identity, candidate);
|
|
1461
1490
|
}
|
|
1462
1491
|
return result;
|
|
1463
|
-
}, new Map()).values()).filter(function (
|
|
1464
|
-
var refund =
|
|
1492
|
+
}, new Map()).values()).filter(function (_ref59) {
|
|
1493
|
+
var refund = _ref59.refund;
|
|
1465
1494
|
return isPrintableRefund(refund);
|
|
1466
1495
|
}).sort(function (left, right) {
|
|
1467
1496
|
var leftTime = refundTimestamp(left.refund);
|
|
@@ -1469,9 +1498,9 @@ function buildRefundData(params) {
|
|
|
1469
1498
|
if (leftTime !== rightTime) return leftTime < rightTime ? -1 : 1;
|
|
1470
1499
|
return left.index - right.index;
|
|
1471
1500
|
});
|
|
1472
|
-
return refunds.map(function (
|
|
1501
|
+
return refunds.map(function (_ref60) {
|
|
1473
1502
|
var _firstPresentValue8;
|
|
1474
|
-
var refund =
|
|
1503
|
+
var refund = _ref60.refund;
|
|
1475
1504
|
var payment = resolveRefundPayment(refund, payments);
|
|
1476
1505
|
var methodName = paymentMethodName(payment, params.locale) || label(params.locale, 'refund');
|
|
1477
1506
|
var amount = (_firstPresentValue8 = firstPresentValue(refund.amount, refund.refund_amount, refund.total_amount)) !== null && _firstPresentValue8 !== void 0 ? _firstPresentValue8 : 0;
|
|
@@ -2253,8 +2282,8 @@ function buildPaymentItems(params) {
|
|
|
2253
2282
|
virtualCurrencyUnit: virtualCurrencyUnit
|
|
2254
2283
|
})));
|
|
2255
2284
|
} else {
|
|
2256
|
-
var
|
|
2257
|
-
var remainingAmount = (
|
|
2285
|
+
var _ref61, _payment$remaining_am, _payment$metadata;
|
|
2286
|
+
var remainingAmount = (_ref61 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref61 !== void 0 ? _ref61 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
2258
2287
|
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
2259
2288
|
items.push({
|
|
2260
2289
|
item: label(locale, 'remainingAmount'),
|
|
@@ -2417,12 +2446,12 @@ function label(locale, key) {
|
|
|
2417
2446
|
return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
|
|
2418
2447
|
}
|
|
2419
2448
|
function getLocalizedValue(value, locale) {
|
|
2420
|
-
var
|
|
2449
|
+
var _ref62, _ref63, _ref64, _ref65, _ref66, _ref67, _value$locale2;
|
|
2421
2450
|
if (value === undefined || value === null) return '';
|
|
2422
2451
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
2423
2452
|
var dashedLocale = locale.replace('_', '-');
|
|
2424
2453
|
var underscoredLocale = locale.replace('-', '_');
|
|
2425
|
-
return stringify((
|
|
2454
|
+
return stringify((_ref62 = (_ref63 = (_ref64 = (_ref65 = (_ref66 = (_ref67 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref67 !== void 0 ? _ref67 : value[underscoredLocale]) !== null && _ref66 !== void 0 ? _ref66 : value.original) !== null && _ref65 !== void 0 ? _ref65 : value.auto) !== null && _ref64 !== void 0 ? _ref64 : value.default) !== null && _ref63 !== void 0 ? _ref63 : value.en) !== null && _ref62 !== void 0 ? _ref62 : '');
|
|
2426
2455
|
}
|
|
2427
2456
|
function resolveServiceTypeLabelKey(serviceType) {
|
|
2428
2457
|
return SERVICE_TYPE_LABEL_KEYS[serviceType] || null;
|
|
@@ -31,9 +31,6 @@ export interface SmallTicketItem {
|
|
|
31
31
|
product_uid?: string | number;
|
|
32
32
|
booking_uid?: string | number;
|
|
33
33
|
}
|
|
34
|
-
export type SmallTicketDeliveryItem = Omit<SmallTicketItem, 'value'> & {
|
|
35
|
-
value?: string;
|
|
36
|
-
};
|
|
37
34
|
export interface SmallTicketProduct {
|
|
38
35
|
product_title: string;
|
|
39
36
|
product_quantity: number;
|
|
@@ -69,7 +66,7 @@ export interface SmallTicketLocaleData {
|
|
|
69
66
|
};
|
|
70
67
|
customer: SmallTicketItem[];
|
|
71
68
|
appointment: SmallTicketAppointment;
|
|
72
|
-
delivery?:
|
|
69
|
+
delivery?: SmallTicketItem[];
|
|
73
70
|
resources: Array<{
|
|
74
71
|
id: string | number;
|
|
75
72
|
code: string;
|
|
@@ -511,7 +511,16 @@ function resolveProductBasePrice(product) {
|
|
|
511
511
|
const variantId = product.product_variant_id ?? product.variant_id;
|
|
512
512
|
const variant = Array.isArray(origin.variant) && isPresentId(variantId) ? origin.variant.find(item => isSameId(item?.id, variantId)) : undefined;
|
|
513
513
|
const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === '2';
|
|
514
|
-
|
|
514
|
+
const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
|
|
515
|
+
const hasEntitlementPass = normalizeArray(product.discount_list).some(discount => getProductWalletDiscountType(discount) === 'entitlement_pass');
|
|
516
|
+
const hasOptions = normalizeArray(product.options).length > 0 || normalizeArray(product.product_sku?.option).length > 0;
|
|
517
|
+
const hasCombinations = normalizeArray(product.combinations).length > 0 || normalizeArray(product.product_bundle).length > 0 || normalizeArray(product.bundle).length > 0;
|
|
518
|
+
const aggregateSourcePrice = firstPresentValue(metadata.source_product_price, product.price);
|
|
519
|
+
const originalPrice = product.original_price;
|
|
520
|
+
// 部分旧 entitlement 商品把 source/price 持久化成了整行总价,但
|
|
521
|
+
// original_price 仍是单件价。仅在等式能明确证明该口径时做窄幅回退。
|
|
522
|
+
const useOriginalPriceAsLegacyUnitPrice = hasEntitlementPass && quantity > 1 && !hasOptions && !hasCombinations && isNumericAmount(aggregateSourcePrice) && isNumericAmount(originalPrice) && new _decimal.default(aggregateSourcePrice).eq(new _decimal.default(originalPrice).mul(quantity));
|
|
523
|
+
return firstPresentValue(useOriginalPriceAsLegacyUnitPrice ? originalPrice : undefined, metadata.source_product_price, variant?.price, product._origin?.price, product._origin?.base_price, !isV2 ? metadata.main_product_original_price : undefined, product.base_price, product.price);
|
|
515
524
|
}
|
|
516
525
|
function normalizeProductDiscounts(params) {
|
|
517
526
|
const {
|
|
@@ -528,7 +537,8 @@ function normalizeProductDiscounts(params) {
|
|
|
528
537
|
const amount = discount.amount ?? discount.value ?? discount.discount_amount;
|
|
529
538
|
const isMarkup = isManualMarkup(discount);
|
|
530
539
|
const isAggregatedBundleDiscount = Boolean(getReceiptDiscountBundleMapId(discount));
|
|
531
|
-
const
|
|
540
|
+
const isEntitlementPass = getProductWalletDiscountType(discount) === 'entitlement_pass';
|
|
541
|
+
const totalAmount = new _decimal.default(toMoneyNumber(amount)).mul(isAggregatedBundleDiscount || isEntitlementPass ? 1 : quantity);
|
|
532
542
|
const formattedAmount = isMarkup ? formatMoney(totalAmount.abs(), currencySymbol) : formatNegativeMoney(totalAmount, currencySymbol);
|
|
533
543
|
return {
|
|
534
544
|
item: title,
|
|
@@ -1178,6 +1188,7 @@ function buildDelivery(order, locale) {
|
|
|
1178
1188
|
if (!serviceTypeLabelKey) return [];
|
|
1179
1189
|
const items = [{
|
|
1180
1190
|
item: label(locale, serviceTypeLabelKey),
|
|
1191
|
+
value: '',
|
|
1181
1192
|
size: 2
|
|
1182
1193
|
}];
|
|
1183
1194
|
const handoverTime = firstPresentValue(order.handover_time, order.handover_at, order.pickup_time, order.pickup_at, order.scheduled_pickup_time, order.delivery_time, order.delivery_at, order.scheduled_delivery_time, order.fulfillment_time, order.fulfillment_at, order.metadata?.handover_time, order.metadata?.handover_at, order.metadata?.pickup_time, order.metadata?.pickup_at, order.metadata?.scheduled_pickup_time, order.metadata?.delivery_time, order.metadata?.delivery_at, order.metadata?.scheduled_delivery_time, order.metadata?.fulfillment_time, order.metadata?.fulfillment_at);
|
|
@@ -1190,7 +1201,8 @@ function buildDelivery(order, locale) {
|
|
|
1190
1201
|
return items;
|
|
1191
1202
|
}
|
|
1192
1203
|
function buildAppointment(order, locale) {
|
|
1193
|
-
const
|
|
1204
|
+
const parentScheduleId = order.metadata?.appointment_booking_parent_schedule_id;
|
|
1205
|
+
const bookings = sortBookings(normalizeArray(order.bookings).filter(booking => isReceiptAppointmentBooking(booking, parentScheduleId)));
|
|
1194
1206
|
if (bookings.length) {
|
|
1195
1207
|
const allResources = normalizeArray(order.resources || order.resource_list);
|
|
1196
1208
|
return bookings.flatMap(booking => buildAppointmentRows({
|
|
@@ -1207,6 +1219,19 @@ function buildAppointment(order, locale) {
|
|
|
1207
1219
|
value: getLocalizedValue(tableName, locale)
|
|
1208
1220
|
}];
|
|
1209
1221
|
}
|
|
1222
|
+
function isReceiptAppointmentBooking(booking, parentScheduleId) {
|
|
1223
|
+
if (!booking || typeof booking !== 'object' || Array.isArray(booking)) {
|
|
1224
|
+
return false;
|
|
1225
|
+
}
|
|
1226
|
+
if (isPresentId(parentScheduleId) && isSameId(booking.schedule_event_id, parentScheduleId)) {
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
const parentId = booking.parent_id;
|
|
1230
|
+
if (parentId === undefined || parentId === null || parentId === '') {
|
|
1231
|
+
return true;
|
|
1232
|
+
}
|
|
1233
|
+
return Number(parentId) !== 0;
|
|
1234
|
+
}
|
|
1210
1235
|
function buildAppointmentRows(params) {
|
|
1211
1236
|
const {
|
|
1212
1237
|
booking,
|