@pisell/pisellos 0.10.31 → 0.10.33
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.
- package/dist/modules/OpenData/index.d.ts +1 -1
- package/dist/modules/OpenData/index.js +19 -11
- package/dist/modules/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +18 -3
- package/dist/server/index.js +4 -5
- package/dist/server/utils/small-ticket.d.ts +5 -1
- package/dist/server/utils/small-ticket.js +180 -101
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +548 -485
- package/dist/utils/os-private-payload.d.ts +5 -0
- package/dist/utils/os-private-payload.js +17 -0
- package/lib/modules/OpenData/index.d.ts +1 -1
- package/lib/modules/OpenData/index.js +9 -1
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +12 -1
- package/lib/server/index.js +4 -5
- package/lib/server/utils/small-ticket.d.ts +5 -1
- package/lib/server/utils/small-ticket.js +107 -34
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +32 -3
- package/lib/utils/os-private-payload.d.ts +5 -0
- package/lib/utils/os-private-payload.js +22 -0
- package/package.json +1 -1
|
@@ -39,7 +39,7 @@ var LABELS = {
|
|
|
39
39
|
balance: 'Balance',
|
|
40
40
|
remainingAmount: 'Remaining amount',
|
|
41
41
|
redeemPoints: 'Redeem points',
|
|
42
|
-
remainingPoints: '
|
|
42
|
+
remainingPoints: 'Point Balance',
|
|
43
43
|
table: 'Table',
|
|
44
44
|
orderDiscount: 'Order discount',
|
|
45
45
|
manualDiscount: 'Manual discount',
|
|
@@ -72,7 +72,7 @@ var LABELS = {
|
|
|
72
72
|
balance: '余额',
|
|
73
73
|
remainingAmount: '剩余金额',
|
|
74
74
|
redeemPoints: '本次使用积分',
|
|
75
|
-
remainingPoints: '
|
|
75
|
+
remainingPoints: '积分余额',
|
|
76
76
|
table: '桌台',
|
|
77
77
|
orderDiscount: '整单折扣',
|
|
78
78
|
manualDiscount: '手动折扣',
|
|
@@ -105,7 +105,7 @@ var LABELS = {
|
|
|
105
105
|
balance: '餘額',
|
|
106
106
|
remainingAmount: '剩餘金額',
|
|
107
107
|
redeemPoints: '本次使用積分',
|
|
108
|
-
remainingPoints: '
|
|
108
|
+
remainingPoints: '積分餘額',
|
|
109
109
|
table: '桌台',
|
|
110
110
|
orderDiscount: '整單折扣',
|
|
111
111
|
manualDiscount: '手動折扣',
|
|
@@ -136,7 +136,7 @@ var LABELS = {
|
|
|
136
136
|
balance: '残高',
|
|
137
137
|
remainingAmount: '残高',
|
|
138
138
|
redeemPoints: '利用ポイント',
|
|
139
|
-
remainingPoints: '
|
|
139
|
+
remainingPoints: 'ポイント残高',
|
|
140
140
|
table: 'テーブル',
|
|
141
141
|
orderDiscount: '注文割引',
|
|
142
142
|
manualDiscount: '手動割引',
|
|
@@ -168,7 +168,7 @@ var LABELS = {
|
|
|
168
168
|
balance: 'Saldo',
|
|
169
169
|
remainingAmount: 'Saldo restante',
|
|
170
170
|
redeemPoints: 'Pontos utilizados',
|
|
171
|
-
remainingPoints: '
|
|
171
|
+
remainingPoints: 'Saldo de pontos',
|
|
172
172
|
table: 'Mesa',
|
|
173
173
|
orderDiscount: 'Desconto do pedido',
|
|
174
174
|
manualDiscount: 'Desconto manual',
|
|
@@ -255,14 +255,14 @@ function buildLocaleData(params) {
|
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
function buildBaseData(params) {
|
|
258
|
-
var _order$metadata;
|
|
258
|
+
var _financials$amountGap, _order$metadata;
|
|
259
259
|
var order = params.order,
|
|
260
260
|
shopInfo = params.shopInfo,
|
|
261
261
|
locale = params.locale,
|
|
262
262
|
currencySymbol = params.currencySymbol,
|
|
263
263
|
financials = params.financials;
|
|
264
264
|
var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
265
|
-
return _objectSpread(
|
|
265
|
+
return _objectSpread({
|
|
266
266
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
267
267
|
note: stringify(order.note),
|
|
268
268
|
shop_order_number: stringify(order.shop_order_number),
|
|
@@ -273,10 +273,8 @@ function buildBaseData(params) {
|
|
|
273
273
|
original_payment_status: financials.paymentStatus,
|
|
274
274
|
payment_status: financials.paymentStatus,
|
|
275
275
|
total_amount: formatMoney(financials.totalAmount, currencySymbol),
|
|
276
|
-
has_pay: formatMoney(financials.netPaymentApplied, currencySymbol)
|
|
277
|
-
|
|
278
|
-
amount_gap: formatMoney(financials.amountGap, currencySymbol)
|
|
279
|
-
} : {}), {}, {
|
|
276
|
+
has_pay: formatMoney(financials.netPaymentApplied, currencySymbol),
|
|
277
|
+
amount_gap: formatCalculatedMoney((_financials$amountGap = financials.amountGap) !== null && _financials$amountGap !== void 0 ? _financials$amountGap : 0, currencySymbol),
|
|
280
278
|
is_repeat: 0,
|
|
281
279
|
buzzer: stringify(order.buzzer || order.pickup_number || ((_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata.buzzer)),
|
|
282
280
|
order_no: orderNumber,
|
|
@@ -328,15 +326,20 @@ function buildProducts(order, locale, productMap) {
|
|
|
328
326
|
});
|
|
329
327
|
var productNote = resolveProductNote(product, locale);
|
|
330
328
|
var basePrice = resolveProductBasePrice(product);
|
|
331
|
-
|
|
329
|
+
var resolvedCombinations = Array.isArray(product.combinations) && product.combinations.length ? normalizeExistingCombinations(product.combinations, locale, currencySymbol) : combinations;
|
|
330
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
332
331
|
product_title: productTitle,
|
|
333
332
|
product_quantity: quantity,
|
|
334
333
|
selling_price: formatMoney(sellingPrice, currencySymbol),
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
base_price:
|
|
334
|
+
total_selling_price: formatCalculatedMoney(new Decimal(toMoneyNumber(sellingPrice)).mul(quantity), currencySymbol),
|
|
335
|
+
original_price: formatMoney(originalPrice, currencySymbol),
|
|
336
|
+
base_price: formatCalculatedMoney(basePrice !== null && basePrice !== void 0 ? basePrice : 0, currencySymbol),
|
|
337
|
+
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol)
|
|
338
|
+
}, options.length ? {
|
|
339
|
+
options_total_price: sumNormalizedOptionTotals(options, currencySymbol)
|
|
340
|
+
} : {}), resolvedCombinations.length ? {
|
|
341
|
+
package_items_total_price: sumCombinationTotals(resolvedCombinations, currencySymbol)
|
|
338
342
|
} : {}), {}, {
|
|
339
|
-
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
340
343
|
extension_list: extensionList
|
|
341
344
|
}, isPresentId(productUid) ? {
|
|
342
345
|
product_uid: productUid
|
|
@@ -348,10 +351,8 @@ function buildProducts(order, locale, productMap) {
|
|
|
348
351
|
options: options
|
|
349
352
|
} : {}), resolvedVariant ? {
|
|
350
353
|
variant: resolvedVariant
|
|
351
|
-
} : {}),
|
|
352
|
-
combinations:
|
|
353
|
-
} : combinations.length ? {
|
|
354
|
-
combinations: combinations
|
|
354
|
+
} : {}), resolvedCombinations.length ? {
|
|
355
|
+
combinations: resolvedCombinations
|
|
355
356
|
} : {});
|
|
356
357
|
});
|
|
357
358
|
}
|
|
@@ -371,10 +372,14 @@ function normalizeProductDiscounts(params) {
|
|
|
371
372
|
locale = params.locale,
|
|
372
373
|
currencySymbol = params.currencySymbol,
|
|
373
374
|
quantity = params.quantity;
|
|
374
|
-
return normalizeArray(product.discount_list).
|
|
375
|
+
return normalizeArray(product.discount_list).filter(function (discount) {
|
|
375
376
|
var _ref8, _discount$amount;
|
|
376
|
-
var title = resolveDiscountTitleWithPercent(discount, locale);
|
|
377
377
|
var amount = (_ref8 = (_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.value) !== null && _ref8 !== void 0 ? _ref8 : discount.discount_amount;
|
|
378
|
+
return isNonZero(amount);
|
|
379
|
+
}).map(function (discount) {
|
|
380
|
+
var _ref9, _discount$amount2;
|
|
381
|
+
var title = resolveDiscountTitleWithPercent(discount, locale);
|
|
382
|
+
var amount = (_ref9 = (_discount$amount2 = discount.amount) !== null && _discount$amount2 !== void 0 ? _discount$amount2 : discount.value) !== null && _ref9 !== void 0 ? _ref9 : discount.discount_amount;
|
|
378
383
|
var formattedAmount = formatNegativeMoney(new Decimal(toMoneyNumber(amount)).mul(quantity), currencySymbol);
|
|
379
384
|
return {
|
|
380
385
|
item: title,
|
|
@@ -458,8 +463,8 @@ function resolveDiscountTitleWithPercent(discount, locale) {
|
|
|
458
463
|
return "".concat(title, " (").concat(percent, "%)");
|
|
459
464
|
}
|
|
460
465
|
function resolveDiscountTitle(discount, locale) {
|
|
461
|
-
var
|
|
462
|
-
var title = getLocalizedValue((
|
|
466
|
+
var _ref10, _ref11, _ref12, _ref13, _discount$discount$na, _discount$discount3, _discount$discount4, _discount$discount5;
|
|
467
|
+
var title = getLocalizedValue((_ref10 = (_ref11 = (_ref12 = (_ref13 = (_discount$discount$na = (_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.name) !== null && _discount$discount$na !== void 0 ? _discount$discount$na : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.title) !== null && _ref13 !== void 0 ? _ref13 : (_discount$discount5 = discount.discount) === null || _discount$discount5 === void 0 ? void 0 : _discount$discount5.message) !== null && _ref12 !== void 0 ? _ref12 : discount.name) !== null && _ref11 !== void 0 ? _ref11 : discount.title) !== null && _ref10 !== void 0 ? _ref10 : discount.message, locale);
|
|
463
468
|
if (title) return title;
|
|
464
469
|
if (discount.type === 'product') return label(locale, 'manualDiscount');
|
|
465
470
|
return '';
|
|
@@ -484,9 +489,10 @@ function normalizeProductOptions(params) {
|
|
|
484
489
|
parentProduct = params.parentProduct;
|
|
485
490
|
var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) ? product.product_sku.option : [];
|
|
486
491
|
return rawOptions.map(function (option) {
|
|
487
|
-
var
|
|
488
|
-
var price = (
|
|
489
|
-
var
|
|
492
|
+
var _ref14, _option$original_pric, _ref15, _option$num, _ref16, _option$value;
|
|
493
|
+
var price = (_ref14 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref14 !== void 0 ? _ref14 : option.price;
|
|
494
|
+
var quantity = toNumber((_ref15 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref15 !== void 0 ? _ref15 : 1, 1);
|
|
495
|
+
var value = (_ref16 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref16 !== void 0 ? _ref16 : option.item;
|
|
490
496
|
var name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
|
|
491
497
|
option: option,
|
|
492
498
|
parentProduct: parentProduct,
|
|
@@ -495,10 +501,12 @@ function normalizeProductOptions(params) {
|
|
|
495
501
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
496
502
|
name: name
|
|
497
503
|
}, option.num !== undefined || option.quantity !== undefined ? {
|
|
498
|
-
num:
|
|
504
|
+
num: quantity
|
|
499
505
|
} : {}), price !== undefined && price !== null && price !== '' ? {
|
|
500
506
|
price: formatMoney(price, currencySymbol)
|
|
501
|
-
} : {}),
|
|
507
|
+
} : {}), {}, {
|
|
508
|
+
total_price: formatCalculatedMoney(new Decimal(toMoneyNumber(price !== null && price !== void 0 ? price : 0)).mul(quantity), currencySymbol)
|
|
509
|
+
}, value !== undefined && value !== null && value !== '' ? {
|
|
502
510
|
value: getLocalizedValue(value, locale)
|
|
503
511
|
} : {});
|
|
504
512
|
});
|
|
@@ -511,7 +519,7 @@ function normalizeProductCombinations(params) {
|
|
|
511
519
|
parentProduct = params.parentProduct;
|
|
512
520
|
var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
513
521
|
return bundles.map(function (bundle) {
|
|
514
|
-
var
|
|
522
|
+
var _ref17, _bundle$num, _bundle$metadata;
|
|
515
523
|
var combinationsOptions = normalizeProductOptions({
|
|
516
524
|
product: {},
|
|
517
525
|
locale: locale,
|
|
@@ -526,43 +534,97 @@ function normalizeProductCombinations(params) {
|
|
|
526
534
|
parentProduct: parentProduct
|
|
527
535
|
});
|
|
528
536
|
var productNote = resolveProductNote(bundle, locale);
|
|
529
|
-
var nestedCombinations = Array.isArray(bundle.combinations) ? normalizeExistingCombinations(bundle.combinations, locale) : [];
|
|
530
|
-
|
|
537
|
+
var nestedCombinations = Array.isArray(bundle.combinations) ? normalizeExistingCombinations(bundle.combinations, locale, currencySymbol) : [];
|
|
538
|
+
var quantity = toNumber((_ref17 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref17 !== void 0 ? _ref17 : 1, 1);
|
|
539
|
+
var formattedPrice = formatBundlePrice(bundle, currencySymbol);
|
|
540
|
+
var optionsTotal = sumNormalizedOptionTotals(combinationsOptions, currencySymbol);
|
|
541
|
+
var explicitBasePrice = firstPresentValue(bundle.base_price, (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata.source_product_price);
|
|
542
|
+
var basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
|
|
543
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
531
544
|
product_title: baseTitle,
|
|
532
|
-
product_quantity:
|
|
533
|
-
price:
|
|
545
|
+
product_quantity: quantity,
|
|
546
|
+
price: formattedPrice,
|
|
547
|
+
total_selling_price: formatCalculatedMoney(new Decimal(toMoneyNumber(formattedPrice)).mul(quantity), currencySymbol),
|
|
548
|
+
base_price: formatCalculatedMoney(basePrice, currencySymbol),
|
|
534
549
|
combinations_options: combinationsOptions
|
|
535
|
-
},
|
|
550
|
+
}, combinationsOptions.length ? {
|
|
551
|
+
options_total_price: optionsTotal
|
|
552
|
+
} : {}), nestedCombinations.length ? {
|
|
553
|
+
package_items_total_price: sumCombinationTotals(nestedCombinations, currencySymbol)
|
|
554
|
+
} : {}), productNote ? {
|
|
536
555
|
product_note: productNote
|
|
537
556
|
} : {}), nestedCombinations.length ? {
|
|
538
557
|
combinations: nestedCombinations
|
|
539
558
|
} : {});
|
|
540
559
|
});
|
|
541
560
|
}
|
|
542
|
-
function normalizeExistingCombinations(combinations, locale) {
|
|
561
|
+
function normalizeExistingCombinations(combinations, locale, currencySymbol) {
|
|
543
562
|
return combinations.map(function (combination) {
|
|
563
|
+
var _ref18, _ref19, _combination$product_, _firstPresentValue;
|
|
544
564
|
if (!combination || _typeof(combination) !== 'object' || Array.isArray(combination)) {
|
|
545
565
|
return combination;
|
|
546
566
|
}
|
|
547
567
|
var productNote = resolveProductNote(combination, locale);
|
|
548
|
-
var
|
|
568
|
+
var rawOptions = Array.isArray(combination.combinations_options) ? combination.combinations_options : Array.isArray(combination.options) ? combination.options : [];
|
|
569
|
+
var normalizedOptions = normalizeProductOptions({
|
|
570
|
+
product: {},
|
|
571
|
+
locale: locale,
|
|
572
|
+
currencySymbol: currencySymbol,
|
|
573
|
+
options: rawOptions
|
|
574
|
+
});
|
|
575
|
+
var nestedCombinations = Array.isArray(combination.combinations) ? normalizeExistingCombinations(combination.combinations, locale, currencySymbol) : [];
|
|
549
576
|
var snapshot = _objectSpread({}, combination);
|
|
550
577
|
delete snapshot.product_note;
|
|
551
578
|
delete snapshot.note;
|
|
552
|
-
|
|
579
|
+
delete snapshot.combinations;
|
|
580
|
+
var quantity = toNumber((_ref18 = (_ref19 = (_combination$product_ = combination.product_quantity) !== null && _combination$product_ !== void 0 ? _combination$product_ : combination.num) !== null && _ref19 !== void 0 ? _ref19 : combination.quantity) !== null && _ref18 !== void 0 ? _ref18 : 1, 1);
|
|
581
|
+
var unitPrice = (_firstPresentValue = firstPresentValue(combination.selling_price, combination.price, combination.original_price)) !== null && _firstPresentValue !== void 0 ? _firstPresentValue : 0;
|
|
582
|
+
var optionsAmount = sumMoneyValues(normalizedOptions.map(function (option) {
|
|
583
|
+
return option.total_price;
|
|
584
|
+
}));
|
|
585
|
+
var explicitBasePrice = firstPresentValue(combination.base_price);
|
|
586
|
+
var basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
|
|
587
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, snapshot), {}, {
|
|
588
|
+
product_quantity: quantity,
|
|
589
|
+
total_selling_price: formatCalculatedMoney(new Decimal(toMoneyNumber(unitPrice)).mul(quantity), currencySymbol),
|
|
590
|
+
base_price: formatCalculatedMoney(basePrice, currencySymbol)
|
|
591
|
+
}, Array.isArray(combination.combinations_options) ? {
|
|
592
|
+
combinations_options: normalizedOptions
|
|
593
|
+
} : Array.isArray(combination.options) ? {
|
|
594
|
+
options: normalizedOptions
|
|
595
|
+
} : {}), normalizedOptions.length ? {
|
|
596
|
+
options_total_price: formatCalculatedMoney(optionsAmount, currencySymbol)
|
|
597
|
+
} : {}), nestedCombinations.length ? {
|
|
598
|
+
package_items_total_price: sumCombinationTotals(nestedCombinations, currencySymbol)
|
|
599
|
+
} : {}), productNote ? {
|
|
553
600
|
product_note: productNote
|
|
554
|
-
} : {}), nestedCombinations ? {
|
|
601
|
+
} : {}), nestedCombinations.length ? {
|
|
555
602
|
combinations: nestedCombinations
|
|
556
603
|
} : {});
|
|
557
604
|
});
|
|
558
605
|
}
|
|
606
|
+
function sumMoneyValues(values) {
|
|
607
|
+
return values.reduce(function (sum, value) {
|
|
608
|
+
return sum.plus(toMoneyNumber(value));
|
|
609
|
+
}, new Decimal(0));
|
|
610
|
+
}
|
|
611
|
+
function sumNormalizedOptionTotals(options, currencySymbol) {
|
|
612
|
+
return formatCalculatedMoney(sumMoneyValues(options.map(function (option) {
|
|
613
|
+
return option.total_price;
|
|
614
|
+
})), currencySymbol);
|
|
615
|
+
}
|
|
616
|
+
function sumCombinationTotals(combinations, currencySymbol) {
|
|
617
|
+
return formatCalculatedMoney(sumMoneyValues(combinations.map(function (combination) {
|
|
618
|
+
return combination.total_selling_price;
|
|
619
|
+
})), currencySymbol);
|
|
620
|
+
}
|
|
559
621
|
function resolveProductNote(product, locale) {
|
|
560
622
|
var productNote = getLocalizedValue(product.product_note, locale).trim();
|
|
561
623
|
if (productNote) return productNote;
|
|
562
624
|
return getLocalizedValue(product.note, locale).trim();
|
|
563
625
|
}
|
|
564
626
|
function resolveBundleProductTitle(params) {
|
|
565
|
-
var
|
|
627
|
+
var _ref20, _ref21, _bundle$bundle_produc;
|
|
566
628
|
var bundle = params.bundle,
|
|
567
629
|
productMap = params.productMap,
|
|
568
630
|
locale = params.locale,
|
|
@@ -575,7 +637,7 @@ function resolveBundleProductTitle(params) {
|
|
|
575
637
|
});
|
|
576
638
|
var parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
|
|
577
639
|
if (parentBundleTitle) return parentBundleTitle;
|
|
578
|
-
var productId = (
|
|
640
|
+
var productId = (_ref20 = (_ref21 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref21 !== void 0 ? _ref21 : bundle.product_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.id;
|
|
579
641
|
var fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
580
642
|
if (!fallbackProduct) return '';
|
|
581
643
|
return getProductTitleSource(fallbackProduct, locale);
|
|
@@ -627,10 +689,10 @@ function resolveVariantTextFromSkuKey(params) {
|
|
|
627
689
|
}
|
|
628
690
|
function resolveVariantTextFromNameMap(params) {
|
|
629
691
|
if (!params.nameMap || _typeof(params.nameMap) !== 'object') return '';
|
|
630
|
-
return Object.entries(params.nameMap).map(function (
|
|
631
|
-
var
|
|
632
|
-
groupPositionId =
|
|
633
|
-
value =
|
|
692
|
+
return Object.entries(params.nameMap).map(function (_ref22) {
|
|
693
|
+
var _ref23 = _slicedToArray(_ref22, 2),
|
|
694
|
+
groupPositionId = _ref23[0],
|
|
695
|
+
value = _ref23[1];
|
|
634
696
|
var group = resolveVariantGroup(params.parentProduct, groupPositionId);
|
|
635
697
|
if (!group) return '';
|
|
636
698
|
var groupName = getLocalizedValue(group.name, params.locale);
|
|
@@ -664,12 +726,12 @@ function getProductTitleSource(source, locale) {
|
|
|
664
726
|
return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
|
|
665
727
|
}
|
|
666
728
|
function resolveTitleValue(value, locale) {
|
|
667
|
-
var
|
|
729
|
+
var _ref24, _ref25, _ref26, _ref27, _value$locale;
|
|
668
730
|
if (value === undefined || value === null) return '';
|
|
669
731
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
670
732
|
var dashedLocale = locale.replace('_', '-');
|
|
671
733
|
var underscoredLocale = locale.replace('-', '_');
|
|
672
|
-
return stringify((
|
|
734
|
+
return stringify((_ref24 = (_ref25 = (_ref26 = (_ref27 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref27 !== void 0 ? _ref27 : value[underscoredLocale]) !== null && _ref26 !== void 0 ? _ref26 : value.original) !== null && _ref25 !== void 0 ? _ref25 : value.auto) !== null && _ref24 !== void 0 ? _ref24 : '');
|
|
673
735
|
}
|
|
674
736
|
function resolveOptionTitleFromParentProduct(params) {
|
|
675
737
|
var option = params.option,
|
|
@@ -687,17 +749,17 @@ function flattenOptionItems(parentProduct) {
|
|
|
687
749
|
return optionGroups.flatMap(function (group) {
|
|
688
750
|
var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
|
|
689
751
|
return items.map(function (item) {
|
|
690
|
-
var
|
|
752
|
+
var _ref28, _item$option_group_id;
|
|
691
753
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
692
|
-
option_group_id: (
|
|
754
|
+
option_group_id: (_ref28 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref28 !== void 0 ? _ref28 : group.option_group_id
|
|
693
755
|
});
|
|
694
756
|
});
|
|
695
757
|
});
|
|
696
758
|
}
|
|
697
759
|
function isOptionItemMatch(option, item) {
|
|
698
|
-
var
|
|
699
|
-
var optionItemId = (
|
|
700
|
-
var itemId = (
|
|
760
|
+
var _ref29, _option$option_group_, _ref30, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
|
|
761
|
+
var optionItemId = (_ref29 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref29 !== void 0 ? _ref29 : option.id;
|
|
762
|
+
var itemId = (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : item.id;
|
|
701
763
|
if (!isSameId(optionItemId, itemId)) return false;
|
|
702
764
|
var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
|
|
703
765
|
var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
|
|
@@ -707,16 +769,16 @@ function isOptionItemMatch(option, item) {
|
|
|
707
769
|
return true;
|
|
708
770
|
}
|
|
709
771
|
function resolveBundleItemFromParentProduct(params) {
|
|
710
|
-
var
|
|
772
|
+
var _ref31, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref33, _bundle$bundle_produc2;
|
|
711
773
|
var bundle = params.bundle,
|
|
712
774
|
parentProduct = params.parentProduct;
|
|
713
775
|
if (!parentProduct) return null;
|
|
714
776
|
var bundleItems = flattenBundleItems(parentProduct);
|
|
715
|
-
var bundleVariantId = (
|
|
777
|
+
var bundleVariantId = (_ref31 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref31 !== void 0 ? _ref31 : bundle.product_variant_id;
|
|
716
778
|
if (isNonZeroId(bundleVariantId)) {
|
|
717
779
|
var matchedByVariant = bundleItems.find(function (item) {
|
|
718
|
-
var
|
|
719
|
-
return isSameId((
|
|
780
|
+
var _ref32, _item$bundle_variant_;
|
|
781
|
+
return isSameId((_ref32 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref32 !== void 0 ? _ref32 : item.product_variant_id, bundleVariantId);
|
|
720
782
|
});
|
|
721
783
|
if (matchedByVariant) return matchedByVariant;
|
|
722
784
|
}
|
|
@@ -729,18 +791,18 @@ function resolveBundleItemFromParentProduct(params) {
|
|
|
729
791
|
if (matchedByBundleId) return matchedByBundleId;
|
|
730
792
|
}
|
|
731
793
|
var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
732
|
-
var bundleProductId = (
|
|
794
|
+
var bundleProductId = (_ref33 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref33 !== void 0 ? _ref33 : bundle.product_id;
|
|
733
795
|
if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
|
|
734
796
|
var matchedByGroupAndProduct = bundleItems.find(function (item) {
|
|
735
|
-
var _item$group_id,
|
|
736
|
-
return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((
|
|
797
|
+
var _item$group_id, _ref34, _item$bundle_product_;
|
|
798
|
+
return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref34 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref34 !== void 0 ? _ref34 : item.product_id, bundleProductId);
|
|
737
799
|
});
|
|
738
800
|
if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
|
|
739
801
|
}
|
|
740
802
|
if (isPresentId(bundleProductId)) {
|
|
741
803
|
return bundleItems.find(function (item) {
|
|
742
|
-
var
|
|
743
|
-
return isSameId((
|
|
804
|
+
var _ref35, _item$bundle_product_2;
|
|
805
|
+
return isSameId((_ref35 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref35 !== void 0 ? _ref35 : item.product_id, bundleProductId);
|
|
744
806
|
}) || null;
|
|
745
807
|
}
|
|
746
808
|
return null;
|
|
@@ -750,9 +812,9 @@ function flattenBundleItems(parentProduct) {
|
|
|
750
812
|
return bundleGroups.flatMap(function (group) {
|
|
751
813
|
var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
|
|
752
814
|
return items.map(function (item) {
|
|
753
|
-
var
|
|
815
|
+
var _ref36, _item$group_id2;
|
|
754
816
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
755
|
-
group_id: (
|
|
817
|
+
group_id: (_ref36 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref36 !== void 0 ? _ref36 : group.group_id
|
|
756
818
|
});
|
|
757
819
|
});
|
|
758
820
|
});
|
|
@@ -776,8 +838,8 @@ function isSameId(left, right) {
|
|
|
776
838
|
return String(left) === String(right);
|
|
777
839
|
}
|
|
778
840
|
function formatBundlePrice(bundle, currencySymbol) {
|
|
779
|
-
var
|
|
780
|
-
var value = (
|
|
841
|
+
var _ref37, _ref38, _bundle$bundle_sellin;
|
|
842
|
+
var value = (_ref37 = (_ref38 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref38 !== void 0 ? _ref38 : bundle.price) !== null && _ref37 !== void 0 ? _ref37 : 0;
|
|
781
843
|
var amount = new Decimal(toMoneyNumber(value));
|
|
782
844
|
// 套餐价格协议:只有 markdown 是减价;加价与商品原价都保持正数。
|
|
783
845
|
var isNegative = bundle.price_type === 'markdown';
|
|
@@ -785,7 +847,7 @@ function formatBundlePrice(bundle, currencySymbol) {
|
|
|
785
847
|
return formatMoney(amount, currencySymbol);
|
|
786
848
|
}
|
|
787
849
|
function buildFees(params) {
|
|
788
|
-
var
|
|
850
|
+
var _firstPresentValue2, _firstPresentValue3;
|
|
789
851
|
var order = params.order,
|
|
790
852
|
shopInfo = params.shopInfo,
|
|
791
853
|
locale = params.locale,
|
|
@@ -795,9 +857,9 @@ function buildFees(params) {
|
|
|
795
857
|
financials = params.financials;
|
|
796
858
|
var fees = [];
|
|
797
859
|
for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
|
|
798
|
-
var
|
|
860
|
+
var _ref39, _surcharge$amount;
|
|
799
861
|
var surcharge = _normalizeArray[_i];
|
|
800
|
-
var value = (
|
|
862
|
+
var value = (_ref39 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref39 !== void 0 ? _ref39 : surcharge.total_amount;
|
|
801
863
|
if (!isNonZero(value)) continue;
|
|
802
864
|
fees.push({
|
|
803
865
|
item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
|
|
@@ -834,14 +896,16 @@ function buildFees(params) {
|
|
|
834
896
|
});
|
|
835
897
|
}
|
|
836
898
|
var productExpectAmount = firstPresentValue(summary.product_expect_amount, summary.product_amount, order.product_expect_amount);
|
|
837
|
-
var productOriginalAmount = (
|
|
899
|
+
var productOriginalAmount = (_firstPresentValue2 = firstPresentValue(summary.product_original_amount, order.product_original_amount)) !== null && _firstPresentValue2 !== void 0 ? _firstPresentValue2 : calculateProductOriginalAmount(order);
|
|
838
900
|
var totalSavingsAmount = new Decimal(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
|
|
901
|
+
var itemDiscountAmount = new Decimal(toMoneyNumber(productExpectAmount !== null && productExpectAmount !== void 0 ? productExpectAmount : 0)).minus(toMoneyNumber(productOriginalAmount));
|
|
839
902
|
return {
|
|
840
903
|
fees: fees,
|
|
841
904
|
countFee: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
842
|
-
total_amount: formatMoney((
|
|
905
|
+
total_amount: formatMoney((_firstPresentValue3 = firstPresentValue(summary.total_amount, order.total_amount)) !== null && _firstPresentValue3 !== void 0 ? _firstPresentValue3 : 0, currencySymbol),
|
|
843
906
|
original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
|
|
844
907
|
product_expect_amount: formatMoney(productExpectAmount !== null && productExpectAmount !== void 0 ? productExpectAmount : 0, currencySymbol),
|
|
908
|
+
item_discount_amount: formatCalculatedMoney(itemDiscountAmount, currencySymbol),
|
|
845
909
|
expect_amount: formatMoney(financials.totalAmount, currencySymbol),
|
|
846
910
|
product_quantity: toNumber(firstPresentValue(summary.product_quantity, products.reduce(function (sum, product) {
|
|
847
911
|
return sum + product.product_quantity;
|
|
@@ -866,15 +930,15 @@ function buildFees(params) {
|
|
|
866
930
|
};
|
|
867
931
|
}
|
|
868
932
|
function resolveReceiptFinancials(order, summary) {
|
|
869
|
-
var
|
|
870
|
-
var totalAmount = (
|
|
933
|
+
var _firstPresentValue4, _firstPresentValue5, _firstPresentValue6, _firstPresentValue7;
|
|
934
|
+
var totalAmount = (_firstPresentValue4 = firstPresentValue(summary.expect_amount, order.expect_amount, summary.total_amount, order.total_amount)) !== null && _firstPresentValue4 !== void 0 ? _firstPresentValue4 : 0;
|
|
871
935
|
var rawPayProcessingFee = firstPresentValue(summary.pay_service_charge_amount, order.pay_service_charge_amount);
|
|
872
936
|
var payProcessingFee = rawPayProcessingFee !== null && rawPayProcessingFee !== void 0 ? rawPayProcessingFee : 0;
|
|
873
|
-
var orderPaidAmount = (
|
|
874
|
-
var totalRefundAmount = (
|
|
937
|
+
var orderPaidAmount = (_firstPresentValue5 = firstPresentValue(summary.order_paid_amount, order.order_paid_amount, sumAppliedPayments(order.payments))) !== null && _firstPresentValue5 !== void 0 ? _firstPresentValue5 : 0;
|
|
938
|
+
var totalRefundAmount = (_firstPresentValue6 = firstPresentValue(summary.total_refund_amount, order.total_refund_amount)) !== null && _firstPresentValue6 !== void 0 ? _firstPresentValue6 : 0;
|
|
875
939
|
var netPaymentApplied = Decimal.max(new Decimal(toMoneyNumber(orderPaidAmount)).minus(toMoneyNumber(totalRefundAmount)), 0);
|
|
876
940
|
var fallbackCustomerPaidAmount = Decimal.max(sumCustomerPaidPayments(order.payments), new Decimal(toMoneyNumber(orderPaidAmount)).plus(toMoneyNumber(payProcessingFee)));
|
|
877
|
-
var customerPaidAmount = (
|
|
941
|
+
var customerPaidAmount = (_firstPresentValue7 = firstPresentValue(summary.customer_paid_amount, order.customer_paid_amount, fallbackCustomerPaidAmount)) !== null && _firstPresentValue7 !== void 0 ? _firstPresentValue7 : 0;
|
|
878
942
|
var amountGap = firstPresentValue(summary.amount_gap, order.amount_gap);
|
|
879
943
|
return {
|
|
880
944
|
totalAmount: totalAmount,
|
|
@@ -903,9 +967,9 @@ function resolveTaxTitle(params) {
|
|
|
903
967
|
}
|
|
904
968
|
function calculateProductOriginalAmount(order) {
|
|
905
969
|
return normalizeArray(order.products).reduce(function (total, product) {
|
|
906
|
-
var
|
|
907
|
-
var quantity = toNumber((
|
|
908
|
-
var originalPrice = (
|
|
970
|
+
var _ref40, _ref41, _product$product_quan2, _ref42, _ref43, _ref44, _product$original_pri2;
|
|
971
|
+
var quantity = toNumber((_ref40 = (_ref41 = (_product$product_quan2 = product.product_quantity) !== null && _product$product_quan2 !== void 0 ? _product$product_quan2 : product.quantity) !== null && _ref41 !== void 0 ? _ref41 : product.num) !== null && _ref40 !== void 0 ? _ref40 : 1, 1);
|
|
972
|
+
var originalPrice = (_ref42 = (_ref43 = (_ref44 = (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : product.selling_price) !== null && _ref44 !== void 0 ? _ref44 : product.payment_price) !== null && _ref43 !== void 0 ? _ref43 : product.price) !== null && _ref42 !== void 0 ? _ref42 : 0;
|
|
909
973
|
return total.plus(new Decimal(toMoneyNumber(originalPrice)).mul(quantity));
|
|
910
974
|
}, new Decimal(0));
|
|
911
975
|
}
|
|
@@ -993,8 +1057,8 @@ function sortBookings(bookings) {
|
|
|
993
1057
|
}
|
|
994
1058
|
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));
|
|
995
1059
|
return bookingUidOrder || left.index - right.index;
|
|
996
|
-
}).map(function (
|
|
997
|
-
var booking =
|
|
1060
|
+
}).map(function (_ref45) {
|
|
1061
|
+
var booking = _ref45.booking;
|
|
998
1062
|
return booking;
|
|
999
1063
|
});
|
|
1000
1064
|
}
|
|
@@ -1037,7 +1101,9 @@ function buildPaymentData(params) {
|
|
|
1037
1101
|
payment: payment,
|
|
1038
1102
|
locale: params.locale,
|
|
1039
1103
|
currencySymbol: params.currencySymbol,
|
|
1040
|
-
includeFundRecordBalance: false
|
|
1104
|
+
includeFundRecordBalance: false,
|
|
1105
|
+
includeFundRecordUsage: true,
|
|
1106
|
+
includePaymentAmount: true
|
|
1041
1107
|
});
|
|
1042
1108
|
});
|
|
1043
1109
|
}
|
|
@@ -1054,8 +1120,8 @@ function buildRefundData(params) {
|
|
|
1054
1120
|
result.set(identity, candidate);
|
|
1055
1121
|
}
|
|
1056
1122
|
return result;
|
|
1057
|
-
}, new Map()).values()).filter(function (
|
|
1058
|
-
var refund =
|
|
1123
|
+
}, new Map()).values()).filter(function (_ref46) {
|
|
1124
|
+
var refund = _ref46.refund;
|
|
1059
1125
|
return isPrintableRefund(refund);
|
|
1060
1126
|
}).sort(function (left, right) {
|
|
1061
1127
|
var leftTime = refundTimestamp(left.refund);
|
|
@@ -1063,12 +1129,12 @@ function buildRefundData(params) {
|
|
|
1063
1129
|
if (leftTime !== rightTime) return leftTime < rightTime ? -1 : 1;
|
|
1064
1130
|
return left.index - right.index;
|
|
1065
1131
|
});
|
|
1066
|
-
return refunds.map(function (
|
|
1067
|
-
var
|
|
1068
|
-
var refund =
|
|
1132
|
+
return refunds.map(function (_ref47) {
|
|
1133
|
+
var _firstPresentValue8;
|
|
1134
|
+
var refund = _ref47.refund;
|
|
1069
1135
|
var payment = resolveRefundPayment(refund, payments);
|
|
1070
1136
|
var methodName = paymentMethodName(payment, params.locale) || label(params.locale, 'refund');
|
|
1071
|
-
var amount = (
|
|
1137
|
+
var amount = (_firstPresentValue8 = firstPresentValue(refund.amount, refund.refund_amount, refund.total_amount)) !== null && _firstPresentValue8 !== void 0 ? _firstPresentValue8 : 0;
|
|
1072
1138
|
var items = [{
|
|
1073
1139
|
item: methodName,
|
|
1074
1140
|
value: formatNegativeMoney(amount, params.currencySymbol)
|
|
@@ -1133,7 +1199,9 @@ function buildWallets(params) {
|
|
|
1133
1199
|
payment: payment,
|
|
1134
1200
|
locale: params.locale,
|
|
1135
1201
|
currencySymbol: params.currencySymbol,
|
|
1136
|
-
includeFundRecordBalance: true
|
|
1202
|
+
includeFundRecordBalance: true,
|
|
1203
|
+
includeFundRecordUsage: false,
|
|
1204
|
+
includePaymentAmount: false
|
|
1137
1205
|
});
|
|
1138
1206
|
});
|
|
1139
1207
|
var displayedWalletPassIds = collectDisplayedWalletPassIds(displayedWalletPayments);
|
|
@@ -1254,11 +1322,13 @@ function buildPaymentItems(params) {
|
|
|
1254
1322
|
var payment = params.payment,
|
|
1255
1323
|
locale = params.locale,
|
|
1256
1324
|
currencySymbol = params.currencySymbol,
|
|
1257
|
-
includeFundRecordBalance = params.includeFundRecordBalance
|
|
1325
|
+
includeFundRecordBalance = params.includeFundRecordBalance,
|
|
1326
|
+
includeFundRecordUsage = params.includeFundRecordUsage,
|
|
1327
|
+
includePaymentAmount = params.includePaymentAmount;
|
|
1258
1328
|
var serviceFee = getPaymentServiceFee(payment);
|
|
1259
1329
|
var items = [{
|
|
1260
1330
|
item: paymentMethodName(payment, locale),
|
|
1261
|
-
value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
|
|
1331
|
+
value: includePaymentAmount ? formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol) : ''
|
|
1262
1332
|
}];
|
|
1263
1333
|
items.push.apply(items, _toConsumableArray(buildCashChangePaymentItems({
|
|
1264
1334
|
payment: payment,
|
|
@@ -1278,11 +1348,12 @@ function buildPaymentItems(params) {
|
|
|
1278
1348
|
fundRecord: fundRecord,
|
|
1279
1349
|
locale: locale,
|
|
1280
1350
|
currencySymbol: currencySymbol,
|
|
1281
|
-
includeBalance: includeFundRecordBalance
|
|
1351
|
+
includeBalance: includeFundRecordBalance,
|
|
1352
|
+
includeUsage: includeFundRecordUsage
|
|
1282
1353
|
})));
|
|
1283
1354
|
} else {
|
|
1284
|
-
var
|
|
1285
|
-
var remainingAmount = (
|
|
1355
|
+
var _ref48, _payment$remaining_am, _payment$metadata;
|
|
1356
|
+
var remainingAmount = (_ref48 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref48 !== void 0 ? _ref48 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
1286
1357
|
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
1287
1358
|
items.push({
|
|
1288
1359
|
item: label(locale, 'remainingAmount'),
|
|
@@ -1342,16 +1413,19 @@ function buildFundRecordPaymentItems(params) {
|
|
|
1342
1413
|
fundRecord = params.fundRecord,
|
|
1343
1414
|
locale = params.locale,
|
|
1344
1415
|
currencySymbol = params.currencySymbol,
|
|
1345
|
-
includeBalance = params.includeBalance
|
|
1416
|
+
includeBalance = params.includeBalance,
|
|
1417
|
+
includeUsage = params.includeUsage;
|
|
1346
1418
|
var items = [];
|
|
1347
1419
|
var usingBeforeValue = fundRecord.using_before_value;
|
|
1348
1420
|
var usingAfterValue = fundRecord.using_after_value;
|
|
1349
1421
|
if (isPointCardPayment(payment) && usingBeforeValue !== undefined && usingAfterValue !== undefined) {
|
|
1350
1422
|
var usedPoints = new Decimal(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1423
|
+
if (includeUsage) {
|
|
1424
|
+
items.push({
|
|
1425
|
+
item: label(locale, 'redeemPoints'),
|
|
1426
|
+
value: trimDecimal(usedPoints)
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1355
1429
|
if (includeBalance) {
|
|
1356
1430
|
items.push({
|
|
1357
1431
|
item: label(locale, 'remainingPoints'),
|
|
@@ -1362,7 +1436,7 @@ function buildFundRecordPaymentItems(params) {
|
|
|
1362
1436
|
}
|
|
1363
1437
|
if (includeBalance && usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
1364
1438
|
items.push({
|
|
1365
|
-
item: label(locale, '
|
|
1439
|
+
item: label(locale, 'balance'),
|
|
1366
1440
|
value: formatMoney(usingAfterValue, currencySymbol)
|
|
1367
1441
|
});
|
|
1368
1442
|
}
|
|
@@ -1433,12 +1507,12 @@ function label(locale, key) {
|
|
|
1433
1507
|
return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
|
|
1434
1508
|
}
|
|
1435
1509
|
function getLocalizedValue(value, locale) {
|
|
1436
|
-
var
|
|
1510
|
+
var _ref49, _ref50, _ref51, _ref52, _ref53, _ref54, _value$locale2;
|
|
1437
1511
|
if (value === undefined || value === null) return '';
|
|
1438
1512
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
1439
1513
|
var dashedLocale = locale.replace('_', '-');
|
|
1440
1514
|
var underscoredLocale = locale.replace('-', '_');
|
|
1441
|
-
return stringify((
|
|
1515
|
+
return stringify((_ref49 = (_ref50 = (_ref51 = (_ref52 = (_ref53 = (_ref54 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref54 !== void 0 ? _ref54 : value[underscoredLocale]) !== null && _ref53 !== void 0 ? _ref53 : value.original) !== null && _ref52 !== void 0 ? _ref52 : value.auto) !== null && _ref51 !== void 0 ? _ref51 : value.default) !== null && _ref50 !== void 0 ? _ref50 : value.en) !== null && _ref49 !== void 0 ? _ref49 : '');
|
|
1442
1516
|
}
|
|
1443
1517
|
function resolveServiceTypeLabelKey(serviceType, order) {
|
|
1444
1518
|
var normalized = serviceType.trim().toLowerCase().replace(/[\s-]+/g, '_');
|
|
@@ -1480,6 +1554,11 @@ function formatMoney(value, currencySymbol) {
|
|
|
1480
1554
|
var amount = new Decimal(toMoneyNumber(value));
|
|
1481
1555
|
return "".concat(currencySymbol).concat(amount.toFixed(2));
|
|
1482
1556
|
}
|
|
1557
|
+
function formatCalculatedMoney(value, currencySymbol) {
|
|
1558
|
+
var amount = new Decimal(toMoneyNumber(value));
|
|
1559
|
+
var sign = amount.isNegative() ? '-' : '';
|
|
1560
|
+
return "".concat(sign).concat(currencySymbol).concat(amount.abs().toFixed(2));
|
|
1561
|
+
}
|
|
1483
1562
|
function formatNegativeMoney(value, currencySymbol) {
|
|
1484
1563
|
var amount = new Decimal(toMoneyNumber(value)).abs();
|
|
1485
1564
|
return "-".concat(currencySymbol).concat(amount.toFixed(2));
|