@vita-mojo/amounts 0.0.68 → 0.0.69
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/package.json +8 -6
- package/src/discounts/applyPromotion.d.ts +4 -4
- package/src/discounts/checkMeetsRequiredConditions.js +1 -2
- package/src/discounts/checkMeetsRequiredConditions.js.map +1 -1
- package/src/discounts/distributeDiscount.js +1 -2
- package/src/discounts/distributeDiscount.js.map +1 -1
- package/src/discounts/distributeDiscountAmount.js +1 -2
- package/src/discounts/distributeDiscountAmount.js.map +1 -1
- package/src/discounts/distributeDiscounts/bundle.util.d.ts +26 -26
- package/src/discounts/distributeDiscounts/bundle.util.js +2 -2
- package/src/discounts/distributeDiscounts/bundle.util.js.map +1 -1
- package/src/discounts/distributeDiscounts/distributeDiscounts.js +1 -2
- package/src/discounts/distributeDiscounts/distributeDiscounts.js.map +1 -1
- package/src/discounts/multiplePromotions/sortPromotions.js +1 -2
- package/src/discounts/multiplePromotions/sortPromotions.js.map +1 -1
- package/src/discounts/promoIsApplicable.js +1 -2
- package/src/discounts/promoIsApplicable.js.map +1 -1
- package/src/discounts/util.d.ts +20 -20
- package/src/discounts/util.js +2 -2
- package/src/discounts/util.js.map +1 -1
- package/src/index.d.ts +19 -7
- package/src/index.js.map +1 -1
- package/src/lib/distribute-discount.js +3 -5
- package/src/lib/distribute-discount.js.map +1 -1
- package/src/lib/distribute-refund.d.ts +25 -25
- package/src/lib/distribute-refund.js +28 -26
- package/src/lib/distribute-refund.js.map +1 -1
- package/src/lib/final-price.d.ts +44 -44
- package/src/lib/final-price.js +6 -5
- package/src/lib/final-price.js.map +1 -1
- package/src/lib/subtotals.d.ts +73 -44
- package/src/lib/subtotals.js +10 -9
- package/src/lib/subtotals.js.map +1 -1
- package/src/lib/tax-totals.d.ts +29 -29
- package/src/lib/tax.d.ts +84 -84
- package/src/lib/tax.js +19 -16
- package/src/lib/tax.js.map +1 -1
- package/src/lib/totals.d.ts +72 -72
- package/src/lib/totals.js +6 -8
- package/src/lib/totals.js.map +1 -1
- package/src/number-wrapper/bignumber.d.ts +10 -10
- package/src/number-wrapper/currency.d.ts +10 -10
- package/src/number-wrapper/index.d.ts +109 -109
- package/src/tax/tax.js +3 -4
- package/src/tax/tax.js.map +1 -1
- package/src/utils/order-vat.js +2 -3
- package/src/utils/order-vat.js.map +1 -1
- package/src/utils/pipe-merge.d.ts +1 -1
- package/src/utils/pipe-merge.js +5 -3
- package/src/utils/pipe-merge.js.map +1 -1
- package/src/discounts/mocks/index.d.ts +0 -6
- package/src/discounts/mocks/index.js +0 -10
- package/src/discounts/mocks/index.js.map +0 -1
- package/src/discounts/mocks/mockDeal.d.ts +0 -2
- package/src/discounts/mocks/mockDeal.js +0 -9
- package/src/discounts/mocks/mockDeal.js.map +0 -1
- package/src/discounts/mocks/mockDiscountGroup.d.ts +0 -2
- package/src/discounts/mocks/mockDiscountGroup.js +0 -9
- package/src/discounts/mocks/mockDiscountGroup.js.map +0 -1
- package/src/discounts/mocks/mockProduct.d.ts +0 -2
- package/src/discounts/mocks/mockProduct.js +0 -9
- package/src/discounts/mocks/mockProduct.js.map +0 -1
- package/src/discounts/mocks/mockProductPromotion.d.ts +0 -2
- package/src/discounts/mocks/mockProductPromotion.js +0 -9
- package/src/discounts/mocks/mockProductPromotion.js.map +0 -1
- package/src/discounts/mocks/mockPromotion.d.ts +0 -3
- package/src/discounts/mocks/mockPromotion.js +0 -45
- package/src/discounts/mocks/mockPromotion.js.map +0 -1
- package/src/discounts/mocks/mockTag.d.ts +0 -2
- package/src/discounts/mocks/mockTag.js +0 -9
- package/src/discounts/mocks/mockTag.js.map +0 -1
- package/src/discounts/multiplePromotions/mocks/index.d.ts +0 -4
- package/src/discounts/multiplePromotions/mocks/index.js +0 -8
- package/src/discounts/multiplePromotions/mocks/index.js.map +0 -1
- package/src/discounts/multiplePromotions/mocks/mockDiscountedProduct.d.ts +0 -2
- package/src/discounts/multiplePromotions/mocks/mockDiscountedProduct.js +0 -15
- package/src/discounts/multiplePromotions/mocks/mockDiscountedProduct.js.map +0 -1
- package/src/discounts/multiplePromotions/mocks/mockInputDeal.d.ts +0 -2
- package/src/discounts/multiplePromotions/mocks/mockInputDeal.js +0 -9
- package/src/discounts/multiplePromotions/mocks/mockInputDeal.js.map +0 -1
- package/src/discounts/multiplePromotions/mocks/mockProduct.d.ts +0 -2
- package/src/discounts/multiplePromotions/mocks/mockProduct.js +0 -9
- package/src/discounts/multiplePromotions/mocks/mockProduct.js.map +0 -1
- package/src/discounts/multiplePromotions/mocks/mockPromotion.d.ts +0 -2
- package/src/discounts/multiplePromotions/mocks/mockPromotion.js +0 -13
- package/src/discounts/multiplePromotions/mocks/mockPromotion.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribute-discount.js","sourceRoot":"","sources":["../../../../../packages/amounts/src/lib/distribute-discount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"distribute-discount.js","sourceRoot":"","sources":["../../../../../packages/amounts/src/lib/distribute-discount.ts"],"names":[],"mappings":";;;AAAA,oFAAmF;AAGnF,oCAAoC;AAE7B,MAAM,sBAAsB,GAAG,CAAC,OAA8B,EAAE,EAAE;IACvE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAA2B,EAAE,EAAE;;QACjD,OAAO,IAAA,uDAA2B,EAChC,MAAM,EACN,CAAC,MAA2B,EAAE,KAAa,EAAE,EAAE,WAC7C,OAAA,IAAA,gBAAQ,EAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,mCAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA,EAAA,EAC1C,CAAC,IAAqB,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,mCAAI,CAAC,CAAA,EAAA,EAChD,CAAC,IAAqB,EAAE,QAAgB,EAAE,EAAE,CAAC,iCACxC,IAAI,KACP,QAAQ,IACR,EACF,EAAE,UAAU,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,CAAC,EAAE,CACtC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAdW,QAAA,sBAAsB,0BAcjC;AAEK,MAAM,4BAA4B,GAAG,CAAC,KAAkB,EAAE,EAAE;;IACjE,MAAM,OAAO,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC;IACrC,MAAM,mCAAmC,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAE5E,OAAO;QACL,OAAO,EAAE,mCAAmC;KAC7C,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,4BAA4B,gCAOvC"}
|
|
@@ -11,33 +11,33 @@ export declare const distributeRefund: (order: Order.Order) => {
|
|
|
11
11
|
serviceChargeRefund: number;
|
|
12
12
|
totalAmount: number;
|
|
13
13
|
subtotalAmount: number;
|
|
14
|
-
subtotalAmountBeforeRefund?: number
|
|
15
|
-
vatAmount?: number
|
|
16
|
-
vatAmountBeforeRefund?: number
|
|
14
|
+
subtotalAmountBeforeRefund?: number;
|
|
15
|
+
vatAmount?: number;
|
|
16
|
+
vatAmountBeforeRefund?: number;
|
|
17
17
|
price: number;
|
|
18
|
-
discount?: number
|
|
19
|
-
provider?: string
|
|
20
|
-
currency?: string
|
|
21
|
-
status?: string
|
|
22
|
-
meta?: string
|
|
23
|
-
name?: string
|
|
24
|
-
deliveryVatRate?: number | null
|
|
25
|
-
type?: string
|
|
26
|
-
refundSumUp?: number
|
|
27
|
-
salesTaxRate?: number | null
|
|
28
|
-
serviceCharge?: number
|
|
29
|
-
serviceChargeBeforeRefund?: number
|
|
30
|
-
serviceChargePercentage?: number | null
|
|
18
|
+
discount?: number;
|
|
19
|
+
provider?: string;
|
|
20
|
+
currency?: string;
|
|
21
|
+
status?: string;
|
|
22
|
+
meta?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
deliveryVatRate?: number | null;
|
|
25
|
+
type?: string;
|
|
26
|
+
refundSumUp?: number;
|
|
27
|
+
salesTaxRate?: number | null;
|
|
28
|
+
serviceCharge?: number;
|
|
29
|
+
serviceChargeBeforeRefund?: number;
|
|
30
|
+
serviceChargePercentage?: number | null;
|
|
31
31
|
deliveryFee: number;
|
|
32
|
-
deliveryFeeBeforeRefund?: number
|
|
33
|
-
transactions?: Order.Payment.Transaction[]
|
|
34
|
-
refundAmountExcludingTax?: number
|
|
35
|
-
isTaxExclusive?: boolean
|
|
36
|
-
discountedDeliveryFee?: number
|
|
37
|
-
discountedServiceCharge?: number
|
|
38
|
-
deliveryFeeTaxAmount?: number
|
|
39
|
-
totalDeliveryFee?: number
|
|
40
|
-
requireExternalPayment?: boolean
|
|
32
|
+
deliveryFeeBeforeRefund?: number;
|
|
33
|
+
transactions?: Order.Payment.Transaction[];
|
|
34
|
+
refundAmountExcludingTax?: number;
|
|
35
|
+
isTaxExclusive?: boolean;
|
|
36
|
+
discountedDeliveryFee?: number;
|
|
37
|
+
discountedServiceCharge?: number;
|
|
38
|
+
deliveryFeeTaxAmount?: number;
|
|
39
|
+
totalDeliveryFee?: number;
|
|
40
|
+
requireExternalPayment?: boolean;
|
|
41
41
|
};
|
|
42
42
|
bundles: Order.Bundle.Bundle[];
|
|
43
43
|
};
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.distributeRefund = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const proportional_distribution_1 = require("@vita-mojo/proportional-distribution");
|
|
6
|
-
const
|
|
5
|
+
const ramda_1 = require("ramda");
|
|
7
6
|
const number_wrapper_1 = require("../number-wrapper");
|
|
8
7
|
const tax_1 = require("../tax");
|
|
9
8
|
const utils_1 = require("../utils");
|
|
10
|
-
const getBundleItems =
|
|
9
|
+
const getBundleItems = (bundle) => { var _a; return (0, utils_1.getItems)((_a = bundle === null || bundle === void 0 ? void 0 : bundle.itemTypes) !== null && _a !== void 0 ? _a : []); };
|
|
11
10
|
const distributeRefund = (order) => {
|
|
12
|
-
var _a, _b, _c, _d;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
13
12
|
const MathWrapper = (0, number_wrapper_1.getNumber)();
|
|
14
|
-
const bundles =
|
|
15
|
-
const orderPayment =
|
|
13
|
+
const bundles = ((_a = order === null || order === void 0 ? void 0 : order.bundles) !== null && _a !== void 0 ? _a : []);
|
|
14
|
+
const orderPayment = (_b = order === null || order === void 0 ? void 0 : order.payment) !== null && _b !== void 0 ? _b : {};
|
|
16
15
|
const refundSumUp = orderPayment.refundSumUp || 0;
|
|
17
|
-
const tenantSettings = (
|
|
18
|
-
const storeSettings = (
|
|
19
|
-
const isTakeAway =
|
|
20
|
-
const salesTaxRate = (
|
|
21
|
-
const isTaxExclusive = (
|
|
22
|
-
const serviceChargeBeforeRefund = +
|
|
23
|
-
const deliveryFeeBeforeRefund = +
|
|
16
|
+
const tenantSettings = ((_c = order === null || order === void 0 ? void 0 : order.tenantSettings) !== null && _c !== void 0 ? _c : {});
|
|
17
|
+
const storeSettings = ((_d = order === null || order === void 0 ? void 0 : order.storeSettings) !== null && _d !== void 0 ? _d : {});
|
|
18
|
+
const isTakeAway = ((_e = order === null || order === void 0 ? void 0 : order.takeaway) !== null && _e !== void 0 ? _e : false);
|
|
19
|
+
const salesTaxRate = (_f = orderPayment.salesTaxRate) !== null && _f !== void 0 ? _f : 0;
|
|
20
|
+
const isTaxExclusive = (_g = orderPayment.isTaxExclusive) !== null && _g !== void 0 ? _g : false;
|
|
21
|
+
const serviceChargeBeforeRefund = +((_h = orderPayment.serviceChargeBeforeRefund) !== null && _h !== void 0 ? _h : 0);
|
|
22
|
+
const deliveryFeeBeforeRefund = +((_j = orderPayment.deliveryFeeBeforeRefund) !== null && _j !== void 0 ? _j : 0);
|
|
24
23
|
const { deliveryFeeVatRate = 20 } = tenantSettings;
|
|
25
24
|
const { 'preorder.delivery.fee.vatRate': deliveryVatRate = deliveryFeeVatRate, } = storeSettings !== null && storeSettings !== void 0 ? storeSettings : {};
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// `features` is not on Order, and `refundedItems` is not on Payment. Both were reached
|
|
26
|
+
// through R.path(), which returns `any` -- so these accesses type-checked by accident. Cast
|
|
27
|
+
// locally rather than widening @vita-mojo/types: runtime behaviour is unchanged, and whether
|
|
28
|
+
// these fields belong in the shared types is a separate question for that package's owners.
|
|
29
|
+
const itemRefundFeature = Boolean((_k = order === null || order === void 0 ? void 0 : order.features) === null || _k === void 0 ? void 0 : _k.itemRefund);
|
|
30
|
+
const deliveryFeeDiscount = (_l = orderPayment.discountedDeliveryFee) !== null && _l !== void 0 ? _l : 0;
|
|
28
31
|
const deliveryFeeWithDiscount = new MathWrapper(deliveryFeeBeforeRefund)
|
|
29
32
|
.subtract(deliveryFeeDiscount)
|
|
30
33
|
.value();
|
|
@@ -34,7 +37,7 @@ const distributeRefund = (order) => {
|
|
|
34
37
|
const totalDeliveryFeeBeforeRefund = isTaxExclusive
|
|
35
38
|
? new MathWrapper(deliveryFeeWithDiscount).add(deliveryFeeTaxAmount).value()
|
|
36
39
|
: deliveryFeeWithDiscount;
|
|
37
|
-
const serviceChargeDiscount = (
|
|
40
|
+
const serviceChargeDiscount = (_m = orderPayment.discountedServiceCharge) !== null && _m !== void 0 ? _m : 0;
|
|
38
41
|
const serviceChargeWithDiscount = new MathWrapper(serviceChargeBeforeRefund)
|
|
39
42
|
.subtract(serviceChargeDiscount)
|
|
40
43
|
.value();
|
|
@@ -44,7 +47,7 @@ const distributeRefund = (order) => {
|
|
|
44
47
|
let basketRefund = 0;
|
|
45
48
|
let basketRefundTaxAmount = 0;
|
|
46
49
|
// assumption: partial refund is not possible after item refund
|
|
47
|
-
const refundedItems = (
|
|
50
|
+
const refundedItems = (orderPayment === null || orderPayment === void 0 ? void 0 : orderPayment.refundedItems);
|
|
48
51
|
if (refundedItems && refundedItems.length && itemRefundFeature) {
|
|
49
52
|
bundlesWithRefund = bundles.map((bundle) => {
|
|
50
53
|
bundle.refund = 0;
|
|
@@ -54,11 +57,9 @@ const distributeRefund = (order) => {
|
|
|
54
57
|
bundle.itemTypes.map((itemType) => {
|
|
55
58
|
itemType.items.map((item) => {
|
|
56
59
|
var _a, _b, _c, _d, _e, _f;
|
|
57
|
-
const itemRefund = (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
R.propEq('basketUUID', bundle.basketUUID),
|
|
61
|
-
]))(refundedItems));
|
|
60
|
+
const itemRefund = (refundedItems.find((refunded) => refunded.uuid === item.itemUUID &&
|
|
61
|
+
refunded.itemTypeUUID === itemType.uuid &&
|
|
62
|
+
refunded.basketUUID === bundle.basketUUID));
|
|
62
63
|
item.refund = 0;
|
|
63
64
|
if (itemRefund) {
|
|
64
65
|
item.refundIncludingTax =
|
|
@@ -96,11 +97,11 @@ const distributeRefund = (order) => {
|
|
|
96
97
|
.value();
|
|
97
98
|
return bundle;
|
|
98
99
|
});
|
|
99
|
-
const deliveryFeeItemRefund = (
|
|
100
|
+
const deliveryFeeItemRefund = (refundedItems.find((refunded) => refunded.type === 'deliveryFee'));
|
|
100
101
|
deliveryFeeRefundIncludingTax = deliveryFeeItemRefund
|
|
101
102
|
? deliveryFeeItemRefund.amount
|
|
102
103
|
: 0;
|
|
103
|
-
const serviceChargeItemRefund = (
|
|
104
|
+
const serviceChargeItemRefund = (refundedItems.find((refunded) => refunded.type === 'serviceCharge'));
|
|
104
105
|
serviceChargeRefundIncludingTax = serviceChargeItemRefund
|
|
105
106
|
? serviceChargeItemRefund.amount
|
|
106
107
|
: 0;
|
|
@@ -122,7 +123,8 @@ const distributeRefund = (order) => {
|
|
|
122
123
|
return Object.assign(Object.assign({}, item), { refundIncludingTax: distributedValue });
|
|
123
124
|
}, { distribute: refundSumUp });
|
|
124
125
|
bundlesWithRefund = bundlesWithDistributedRefund.map((bundle) => {
|
|
125
|
-
|
|
126
|
+
var _a;
|
|
127
|
+
const getBundleItemsMemoized = (0, ramda_1.memoizeWith)((b) => b.basketUUID, getBundleItems);
|
|
126
128
|
const bundleVATOverwrites = (0, utils_1.findBundleVATOverwrite)(bundle.itemTypes);
|
|
127
129
|
const bundleWithItemRefunds = (0, proportional_distribution_1.distributeProportionalValue)(bundle, (bundle, index) => getBundleItemsMemoized(bundle)[index], (item) => item.totalAmountBeforeRefund, (item, refundIncludingTax) => {
|
|
128
130
|
const taxRate = isTaxExclusive
|
|
@@ -137,7 +139,7 @@ const distributeRefund = (order) => {
|
|
|
137
139
|
.subtract(refundTaxAmount)
|
|
138
140
|
.value()
|
|
139
141
|
: refundIncludingTax });
|
|
140
|
-
}, { distribute:
|
|
142
|
+
}, { distribute: (_a = bundle.refundIncludingTax) !== null && _a !== void 0 ? _a : 0 });
|
|
141
143
|
const { bundleRefund, bundleRefundTaxAmount } = getBundleItems(bundleWithItemRefunds).reduce((acc, itm) => {
|
|
142
144
|
var _a, _b;
|
|
143
145
|
return ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribute-refund.js","sourceRoot":"","sources":["../../../../../packages/amounts/src/lib/distribute-refund.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"distribute-refund.js","sourceRoot":"","sources":["../../../../../packages/amounts/src/lib/distribute-refund.ts"],"names":[],"mappings":";;;AAAA,oFAAmF;AAEnF,iCAAoC;AAEpC,sDAA8C;AAC9C,gCAAoC;AACpC,oCAKkB;AAgBlB,MAAM,cAAc,GAAG,CAAC,MAA2B,EAAE,EAAE,WACrD,OAAA,IAAA,gBAAQ,EAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,mCAAI,EAAE,CAAC,CAAA,EAAA,CAAC;AAE7B,MAAM,gBAAgB,GAAG,CAAC,KAAkB,EAAE,EAAE;;IACrD,MAAM,WAAW,GAAG,IAAA,0BAAS,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AAG,IAAI,WAAW,CAAC,YAAY,CAAC;SAC/C,GAAG,CAAC,iBAAiB,CAAC;SACtB,GAAG,CAAC,mBAAmB,CAAC;SACxB,KAAK,EAAE,CAAC;IAEX,MAAM,eAAe,GAAG,IAAI,WAAW,CAAC,qBAAqB,CAAC;SAC3D,GAAG,CAAC,0BAA0B,CAAC;SAC/B,GAAG,CAAC,4BAA4B,CAAC;SACjC,KAAK,EAAE,CAAC;IAEX,OAAO;QACL,OAAO,kCACF,YAAY,KACf,eAAe;YACf,YAAY;YACZ,6BAA6B;YAC7B,0BAA0B;YAC1B,iBAAiB;YACjB,+BAA+B;YAC/B,4BAA4B;YAC5B,mBAAmB,GACpB;QACD,OAAO,EAAE,iBAAiB;KAC3B,CAAC;AACJ,CAAC,CAAC;AA7SW,QAAA,gBAAgB,oBA6S3B"}
|
package/src/lib/final-price.d.ts
CHANGED
|
@@ -8,22 +8,22 @@ export declare const assignFinalPrices: (order: Order.Order) => {
|
|
|
8
8
|
finalPrice: number;
|
|
9
9
|
name: string;
|
|
10
10
|
uuid: string;
|
|
11
|
-
kitchenTicketName?: string | null
|
|
12
|
-
kitchenZone?: Order.Item.KitchenZone | null
|
|
11
|
+
kitchenTicketName?: string | null;
|
|
12
|
+
kitchenZone?: Order.Item.KitchenZone | null;
|
|
13
13
|
itemUUID: string;
|
|
14
14
|
straightToPickup: boolean;
|
|
15
15
|
price: number;
|
|
16
16
|
priceEatIn: number;
|
|
17
17
|
hasEatInPrice: boolean;
|
|
18
18
|
appStraightToPickup: Order.Item.AppStraightToPickup;
|
|
19
|
-
refund?: number
|
|
20
|
-
totalAmountBeforeRefund?: number
|
|
21
|
-
refundIncludingTax?: number
|
|
22
|
-
bundleVATOverwriteTakeaway?: number
|
|
23
|
-
bundleVATOverwriteEatin?: number
|
|
24
|
-
refundTaxAmount?: number
|
|
25
|
-
refundUUID?: string
|
|
26
|
-
salesTax?: number
|
|
19
|
+
refund?: number;
|
|
20
|
+
totalAmountBeforeRefund?: number;
|
|
21
|
+
refundIncludingTax?: number;
|
|
22
|
+
bundleVATOverwriteTakeaway?: number;
|
|
23
|
+
bundleVATOverwriteEatin?: number;
|
|
24
|
+
refundTaxAmount?: number;
|
|
25
|
+
refundUUID?: string;
|
|
26
|
+
salesTax?: number;
|
|
27
27
|
totalAmount: number;
|
|
28
28
|
subtotalAmount: number;
|
|
29
29
|
customizations: Order.Item.Customization[];
|
|
@@ -32,13 +32,13 @@ export declare const assignFinalPrices: (order: Order.Order) => {
|
|
|
32
32
|
taxExempt: number;
|
|
33
33
|
vatRateEatIn: number;
|
|
34
34
|
vatRateTakeaway: number;
|
|
35
|
-
promotion?: Order.Promotion
|
|
35
|
+
promotion?: Order.Promotion;
|
|
36
36
|
type: string;
|
|
37
37
|
dealPriceOverrideDiff?: {
|
|
38
|
-
priceEatIn?: number
|
|
39
|
-
price?: number
|
|
40
|
-
}
|
|
41
|
-
allergens: string
|
|
38
|
+
priceEatIn?: number;
|
|
39
|
+
price?: number;
|
|
40
|
+
};
|
|
41
|
+
allergens: Array<string>;
|
|
42
42
|
}[];
|
|
43
43
|
uuid: string;
|
|
44
44
|
isDefault: boolean;
|
|
@@ -50,35 +50,35 @@ export declare const assignFinalPrices: (order: Order.Order) => {
|
|
|
50
50
|
}[];
|
|
51
51
|
finalPrice: number;
|
|
52
52
|
uuid: string;
|
|
53
|
-
menuUUID?: string
|
|
54
|
-
upsellCategories?: string[]
|
|
55
|
-
isReorder?: boolean
|
|
53
|
+
menuUUID?: string;
|
|
54
|
+
upsellCategories?: string[];
|
|
55
|
+
isReorder?: boolean;
|
|
56
56
|
basketUUID: string;
|
|
57
57
|
hasModifiers: boolean;
|
|
58
|
-
extMediaUUID?: string
|
|
58
|
+
extMediaUUID?: string;
|
|
59
59
|
name: string;
|
|
60
60
|
kitchenTicketName: string;
|
|
61
|
-
slug?: string
|
|
61
|
+
slug?: string;
|
|
62
62
|
description: string | null;
|
|
63
|
-
dealCategoryOrder?: number
|
|
63
|
+
dealCategoryOrder?: number;
|
|
64
64
|
isGrouped: boolean;
|
|
65
65
|
isPrintable: boolean;
|
|
66
|
-
isAccessory?: boolean
|
|
66
|
+
isAccessory?: boolean;
|
|
67
67
|
straightToPickup: boolean;
|
|
68
68
|
appStraightToPickup: Order.Bundle.AppStraightToPickup;
|
|
69
69
|
type: string;
|
|
70
|
-
items?: Order.Item.Item[]
|
|
70
|
+
items?: Order.Item.Item[];
|
|
71
71
|
price: number;
|
|
72
72
|
priceEatIn: number;
|
|
73
73
|
hasEatInPrice: boolean;
|
|
74
|
-
refund?: number
|
|
75
|
-
excludeFromServiceCharge?: boolean
|
|
76
|
-
refundIncludingTax?: number
|
|
77
|
-
refundTaxAmount?: number
|
|
78
|
-
refundUUID?: string
|
|
74
|
+
refund?: number;
|
|
75
|
+
excludeFromServiceCharge?: boolean;
|
|
76
|
+
refundIncludingTax?: number;
|
|
77
|
+
refundTaxAmount?: number;
|
|
78
|
+
refundUUID?: string;
|
|
79
79
|
subtotalAmountIncludingTax: number;
|
|
80
80
|
totalAmount: number;
|
|
81
|
-
totalAmountBeforeRefund?: number
|
|
81
|
+
totalAmountBeforeRefund?: number;
|
|
82
82
|
subtotalAmount: number;
|
|
83
83
|
vatAmount: number;
|
|
84
84
|
discount: number;
|
|
@@ -88,24 +88,24 @@ export declare const assignFinalPrices: (order: Order.Order) => {
|
|
|
88
88
|
rootCategory?: {
|
|
89
89
|
name: string;
|
|
90
90
|
uuid: string;
|
|
91
|
-
}
|
|
92
|
-
category?: object
|
|
93
|
-
note?: string | null
|
|
94
|
-
defaultItems?: Order.Bundle.DefaultItem[]
|
|
95
|
-
promotion?: Order.Promotion | null
|
|
96
|
-
promotions?: Order.BundlePromotion[] | null
|
|
91
|
+
};
|
|
92
|
+
category?: object;
|
|
93
|
+
note?: string | null;
|
|
94
|
+
defaultItems?: Order.Bundle.DefaultItem[];
|
|
95
|
+
promotion?: Order.Promotion | null;
|
|
96
|
+
promotions?: Order.BundlePromotion[] | null;
|
|
97
97
|
meta: object;
|
|
98
|
-
baseTotalAmount?: number
|
|
99
|
-
baseVatAmount?: number
|
|
100
|
-
deal?: Order.Bundle.Deal
|
|
98
|
+
baseTotalAmount?: number;
|
|
99
|
+
baseVatAmount?: number;
|
|
100
|
+
deal?: Order.Bundle.Deal;
|
|
101
101
|
kitchenStation: Order.Bundle.KitchenStation | null;
|
|
102
|
-
status?: string
|
|
102
|
+
status?: string;
|
|
103
103
|
allergens: string[];
|
|
104
|
-
isRecommendation?: boolean
|
|
105
|
-
parentID?: string
|
|
106
|
-
quantity?: number
|
|
107
|
-
basketEntries?: Record<string, Partial<Order.Bundle.Bundle
|
|
108
|
-
adjustment?: Order.Bundle.Adjustment
|
|
104
|
+
isRecommendation?: boolean;
|
|
105
|
+
parentID?: string;
|
|
106
|
+
quantity?: number;
|
|
107
|
+
basketEntries?: Record<string, Partial<Order.Bundle.Bundle>>;
|
|
108
|
+
adjustment?: Order.Bundle.Adjustment;
|
|
109
109
|
tags: Order.Bundle.Tag[];
|
|
110
110
|
}[];
|
|
111
111
|
};
|
package/src/lib/final-price.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assignFinalPrices = exports.bundleFinalPrice = exports.itemFinalPrice = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const R = tslib_1.__importStar(require("ramda"));
|
|
6
4
|
const number_wrapper_1 = require("../number-wrapper");
|
|
7
5
|
const utils_1 = require("../utils");
|
|
8
6
|
const selectCheckGroupVariations = (cust) => {
|
|
@@ -16,7 +14,7 @@ const selectCheckGroupVariations = (cust) => {
|
|
|
16
14
|
};
|
|
17
15
|
const selectVariations = (customization) => {
|
|
18
16
|
const { current, variations } = customization;
|
|
19
|
-
if (
|
|
17
|
+
if (current === null || current === undefined)
|
|
20
18
|
return [];
|
|
21
19
|
const checkedVariations = selectCheckGroupVariations(customization);
|
|
22
20
|
if (checkedVariations.length) {
|
|
@@ -35,9 +33,12 @@ const variationPrice = (variation, isTakeaway) => {
|
|
|
35
33
|
: variation.price;
|
|
36
34
|
};
|
|
37
35
|
const itemFinalPrice = (item, isTakeAway) => {
|
|
36
|
+
var _a;
|
|
38
37
|
const Number = (0, number_wrapper_1.getNumber)();
|
|
39
|
-
const customizations = (
|
|
40
|
-
const variations =
|
|
38
|
+
const customizations = (((_a = item === null || item === void 0 ? void 0 : item.customizations) !== null && _a !== void 0 ? _a : []));
|
|
39
|
+
const variations = customizations
|
|
40
|
+
.map(selectVariations)
|
|
41
|
+
.flat();
|
|
41
42
|
const customizationsPrice = variations
|
|
42
43
|
.reduce((total, variation) => total.add(variationPrice(variation, isTakeAway)), new Number(0))
|
|
43
44
|
.value();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"final-price.js","sourceRoot":"","sources":["../../../../../packages/amounts/src/lib/final-price.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"final-price.js","sourceRoot":"","sources":["../../../../../packages/amounts/src/lib/final-price.ts"],"names":[],"mappings":";;;AAEA,sDAA8C;AAC9C,oCAAoC;AAEpC,MAAM,0BAA0B,GAAG,CACjC,IAA8B,EACN,EAAE;IAC1B,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,iBAAiB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAChB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAEjB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACvB,aAAuC,EAC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AU,CAAC,CAAC,CAAC,KAAK,CAAC;IAEtE,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,CAAC;AAC9D,CAAC,CAAC;AAhBW,QAAA,gBAAgB,oBAgB3B;AAEK,MAAM,iBAAiB,GAAG,CAAC,KAAkB,EAAE,EAAE;;IACtD,MAAM,cAAc,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,mCAAI,KAAK,CAAC;IAE5C,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC5C,MAAM,UAAU,GAAG,IAAA,wBAAgB,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACxD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iCAChD,QAAQ,KACX,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iCAC/B,IAAI,KACP,UAAU,EAAE,IAAA,sBAAc,EAAC,IAAI,EAAE,UAAU,CAAC,IAC5C,CAAC,IACH,CAAC,CAAC;QAEJ,uCACK,MAAM,KACT,SAAS;YACT,UAAU,IACV;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC,CAAC;AAtBW,QAAA,iBAAiB,qBAsB5B"}
|
package/src/lib/subtotals.d.ts
CHANGED
|
@@ -8,22 +8,22 @@ export declare const calculateSubtotals: (order: Order.Order) => {
|
|
|
8
8
|
subtotalAmount: number;
|
|
9
9
|
name: string;
|
|
10
10
|
uuid: string;
|
|
11
|
-
kitchenTicketName?: string | null
|
|
12
|
-
kitchenZone?: Order.Item.KitchenZone | null
|
|
11
|
+
kitchenTicketName?: string | null;
|
|
12
|
+
kitchenZone?: Order.Item.KitchenZone | null;
|
|
13
13
|
itemUUID: string;
|
|
14
14
|
straightToPickup: boolean;
|
|
15
15
|
price: number;
|
|
16
16
|
priceEatIn: number;
|
|
17
17
|
hasEatInPrice: boolean;
|
|
18
18
|
appStraightToPickup: Order.Item.AppStraightToPickup;
|
|
19
|
-
refund?: number
|
|
20
|
-
totalAmountBeforeRefund?: number
|
|
21
|
-
refundIncludingTax?: number
|
|
22
|
-
bundleVATOverwriteTakeaway?: number
|
|
23
|
-
bundleVATOverwriteEatin?: number
|
|
24
|
-
refundTaxAmount?: number
|
|
25
|
-
refundUUID?: string
|
|
26
|
-
salesTax?: number
|
|
19
|
+
refund?: number;
|
|
20
|
+
totalAmountBeforeRefund?: number;
|
|
21
|
+
refundIncludingTax?: number;
|
|
22
|
+
bundleVATOverwriteTakeaway?: number;
|
|
23
|
+
bundleVATOverwriteEatin?: number;
|
|
24
|
+
refundTaxAmount?: number;
|
|
25
|
+
refundUUID?: string;
|
|
26
|
+
salesTax?: number;
|
|
27
27
|
finalPrice: number;
|
|
28
28
|
totalAmount: number;
|
|
29
29
|
customizations: Order.Item.Customization[];
|
|
@@ -32,13 +32,13 @@ export declare const calculateSubtotals: (order: Order.Order) => {
|
|
|
32
32
|
taxExempt: number;
|
|
33
33
|
vatRateEatIn: number;
|
|
34
34
|
vatRateTakeaway: number;
|
|
35
|
-
promotion?: Order.Promotion
|
|
35
|
+
promotion?: Order.Promotion;
|
|
36
36
|
type: string;
|
|
37
37
|
dealPriceOverrideDiff?: {
|
|
38
|
-
priceEatIn?: number
|
|
39
|
-
price?: number
|
|
40
|
-
}
|
|
41
|
-
allergens: string
|
|
38
|
+
priceEatIn?: number;
|
|
39
|
+
price?: number;
|
|
40
|
+
};
|
|
41
|
+
allergens: Array<string>;
|
|
42
42
|
}[];
|
|
43
43
|
uuid: string;
|
|
44
44
|
isDefault: boolean;
|
|
@@ -50,36 +50,36 @@ export declare const calculateSubtotals: (order: Order.Order) => {
|
|
|
50
50
|
}[];
|
|
51
51
|
subtotalAmount: number;
|
|
52
52
|
uuid: string;
|
|
53
|
-
menuUUID?: string
|
|
54
|
-
upsellCategories?: string[]
|
|
55
|
-
isReorder?: boolean
|
|
53
|
+
menuUUID?: string;
|
|
54
|
+
upsellCategories?: string[];
|
|
55
|
+
isReorder?: boolean;
|
|
56
56
|
basketUUID: string;
|
|
57
57
|
hasModifiers: boolean;
|
|
58
|
-
extMediaUUID?: string
|
|
58
|
+
extMediaUUID?: string;
|
|
59
59
|
name: string;
|
|
60
60
|
kitchenTicketName: string;
|
|
61
|
-
slug?: string
|
|
61
|
+
slug?: string;
|
|
62
62
|
description: string | null;
|
|
63
|
-
dealCategoryOrder?: number
|
|
63
|
+
dealCategoryOrder?: number;
|
|
64
64
|
isGrouped: boolean;
|
|
65
65
|
isPrintable: boolean;
|
|
66
|
-
isAccessory?: boolean
|
|
66
|
+
isAccessory?: boolean;
|
|
67
67
|
straightToPickup: boolean;
|
|
68
68
|
appStraightToPickup: Order.Bundle.AppStraightToPickup;
|
|
69
69
|
type: string;
|
|
70
|
-
items?: Order.Item.Item[]
|
|
70
|
+
items?: Order.Item.Item[];
|
|
71
71
|
price: number;
|
|
72
72
|
priceEatIn: number;
|
|
73
73
|
hasEatInPrice: boolean;
|
|
74
|
-
refund?: number
|
|
75
|
-
excludeFromServiceCharge?: boolean
|
|
76
|
-
refundIncludingTax?: number
|
|
77
|
-
refundTaxAmount?: number
|
|
78
|
-
refundUUID?: string
|
|
74
|
+
refund?: number;
|
|
75
|
+
excludeFromServiceCharge?: boolean;
|
|
76
|
+
refundIncludingTax?: number;
|
|
77
|
+
refundTaxAmount?: number;
|
|
78
|
+
refundUUID?: string;
|
|
79
79
|
finalPrice: number;
|
|
80
80
|
subtotalAmountIncludingTax: number;
|
|
81
81
|
totalAmount: number;
|
|
82
|
-
totalAmountBeforeRefund?: number
|
|
82
|
+
totalAmountBeforeRefund?: number;
|
|
83
83
|
vatAmount: number;
|
|
84
84
|
discount: number;
|
|
85
85
|
taxExempt: number;
|
|
@@ -88,24 +88,24 @@ export declare const calculateSubtotals: (order: Order.Order) => {
|
|
|
88
88
|
rootCategory?: {
|
|
89
89
|
name: string;
|
|
90
90
|
uuid: string;
|
|
91
|
-
}
|
|
92
|
-
category?: object
|
|
93
|
-
note?: string | null
|
|
94
|
-
defaultItems?: Order.Bundle.DefaultItem[]
|
|
95
|
-
promotion?: Order.Promotion | null
|
|
96
|
-
promotions?: Order.BundlePromotion[] | null
|
|
91
|
+
};
|
|
92
|
+
category?: object;
|
|
93
|
+
note?: string | null;
|
|
94
|
+
defaultItems?: Order.Bundle.DefaultItem[];
|
|
95
|
+
promotion?: Order.Promotion | null;
|
|
96
|
+
promotions?: Order.BundlePromotion[] | null;
|
|
97
97
|
meta: object;
|
|
98
|
-
baseTotalAmount?: number
|
|
99
|
-
baseVatAmount?: number
|
|
100
|
-
deal?: Order.Bundle.Deal
|
|
98
|
+
baseTotalAmount?: number;
|
|
99
|
+
baseVatAmount?: number;
|
|
100
|
+
deal?: Order.Bundle.Deal;
|
|
101
101
|
kitchenStation: Order.Bundle.KitchenStation | null;
|
|
102
|
-
status?: string
|
|
102
|
+
status?: string;
|
|
103
103
|
allergens: string[];
|
|
104
|
-
isRecommendation?: boolean
|
|
105
|
-
parentID?: string
|
|
106
|
-
quantity?: number
|
|
107
|
-
basketEntries?: Record<string, Partial<Order.Bundle.Bundle
|
|
108
|
-
adjustment?: Order.Bundle.Adjustment
|
|
104
|
+
isRecommendation?: boolean;
|
|
105
|
+
parentID?: string;
|
|
106
|
+
quantity?: number;
|
|
107
|
+
basketEntries?: Record<string, Partial<Order.Bundle.Bundle>>;
|
|
108
|
+
adjustment?: Order.Bundle.Adjustment;
|
|
109
109
|
tags: Order.Bundle.Tag[];
|
|
110
110
|
}[];
|
|
111
111
|
payment: {
|
|
@@ -113,5 +113,34 @@ export declare const calculateSubtotals: (order: Order.Order) => {
|
|
|
113
113
|
subtotalAmountBeforeRefund: number;
|
|
114
114
|
serviceCharge: number;
|
|
115
115
|
deliveryFee: number;
|
|
116
|
+
totalAmount: number;
|
|
117
|
+
vatAmount?: number;
|
|
118
|
+
vatAmountBeforeRefund?: number;
|
|
119
|
+
price: number;
|
|
120
|
+
discount?: number;
|
|
121
|
+
provider?: string;
|
|
122
|
+
currency?: string;
|
|
123
|
+
status?: string;
|
|
124
|
+
meta?: string;
|
|
125
|
+
name?: string;
|
|
126
|
+
deliveryVatRate?: number | null;
|
|
127
|
+
type?: string;
|
|
128
|
+
refundSumUp?: number;
|
|
129
|
+
salesTaxRate?: number | null;
|
|
130
|
+
serviceChargeBeforeRefund?: number;
|
|
131
|
+
serviceChargePercentage?: number | null;
|
|
132
|
+
deliveryFeeBeforeRefund?: number;
|
|
133
|
+
transactions?: Order.Payment.Transaction[];
|
|
134
|
+
refundAmountExcludingTax?: number;
|
|
135
|
+
serviceChargeRefund?: number;
|
|
136
|
+
deliveryFeeRefund?: number;
|
|
137
|
+
isTaxExclusive?: boolean;
|
|
138
|
+
refundAmount?: number;
|
|
139
|
+
discountedDeliveryFee?: number;
|
|
140
|
+
discountedServiceCharge?: number;
|
|
141
|
+
deliveryFeeTaxAmount?: number;
|
|
142
|
+
totalDeliveryFee?: number;
|
|
143
|
+
deliveryFeeRefundTaxAmount?: number;
|
|
144
|
+
requireExternalPayment?: boolean;
|
|
116
145
|
};
|
|
117
146
|
};
|