@unchainedshop/plugins 4.3.1 → 4.3.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-round.d.ts","sourceRoot":"","sources":["../../src/pricing/order-round.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAErB,MAAM,qBAAqB,CAAC;AAE7B,UAAU,kBAAkB;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7E;
|
|
1
|
+
{"version":3,"file":"order-round.d.ts","sourceRoot":"","sources":["../../src/pricing/order-round.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAErB,MAAM,qBAAqB,CAAC;AAE7B,UAAU,kBAAkB;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7E;AAWD,eAAO,MAAM,eAAe,EAAE,oBAAoB,GAAG;IACnD,SAAS,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAChD,QAAQ,EAAE,kBAAkB,CAAC;CAoJ9B,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { OrderPricingAdapter, OrderPricingDirector, OrderPricingRowCategory, } from '@unchainedshop/core';
|
|
2
|
+
const calculateDifference = (amount, currencyCode) => {
|
|
3
|
+
const roundedAmount = OrderPriceRound.settings.roundTo(amount, OrderPriceRound.settings.defaultPrecision, currencyCode);
|
|
4
|
+
return roundedAmount - amount;
|
|
5
|
+
};
|
|
2
6
|
export const OrderPriceRound = {
|
|
3
7
|
...OrderPricingAdapter,
|
|
4
|
-
key: 'shop.unchained.pricing.order-round',
|
|
8
|
+
key: 'shop.unchained.pricing.order-round-fixed',
|
|
5
9
|
version: '1.0.0',
|
|
6
10
|
label: 'Round order price to the next precision number',
|
|
7
11
|
orderIndex: 90,
|
|
@@ -20,10 +24,6 @@ export const OrderPriceRound = {
|
|
|
20
24
|
},
|
|
21
25
|
actions: (params) => {
|
|
22
26
|
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
23
|
-
const calculateDifference = (amount, currencyCode) => {
|
|
24
|
-
const roundedAmount = OrderPriceRound.settings.roundTo(amount, OrderPriceRound.settings.defaultPrecision, currencyCode);
|
|
25
|
-
return roundedAmount - amount;
|
|
26
|
-
};
|
|
27
27
|
return {
|
|
28
28
|
...pricingAdapter,
|
|
29
29
|
calculate: async () => {
|
|
@@ -35,9 +35,14 @@ export const OrderPriceRound = {
|
|
|
35
35
|
useNetPrice: true,
|
|
36
36
|
});
|
|
37
37
|
if (deliveryAmount) {
|
|
38
|
+
const taxes = params.calculationSheet.taxSum({
|
|
39
|
+
baseCategory: OrderPricingRowCategory.Delivery,
|
|
40
|
+
});
|
|
41
|
+
const deliveryTaxRate = taxes / deliveryAmount;
|
|
42
|
+
const deliveryDifference = calculateDifference(deliveryAmount, currencyCode);
|
|
38
43
|
pricingAdapter.resultSheet().addDelivery({
|
|
39
|
-
amount:
|
|
40
|
-
taxAmount:
|
|
44
|
+
amount: deliveryDifference,
|
|
45
|
+
taxAmount: deliveryTaxRate * deliveryDifference,
|
|
41
46
|
meta: {
|
|
42
47
|
adapter: OrderPriceRound.key,
|
|
43
48
|
},
|
|
@@ -48,12 +53,19 @@ export const OrderPriceRound = {
|
|
|
48
53
|
useNetPrice: true,
|
|
49
54
|
});
|
|
50
55
|
if (discountAmount) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
const taxes = params.calculationSheet.taxSum({
|
|
57
|
+
baseCategory: OrderPricingRowCategory.Discounts,
|
|
58
|
+
});
|
|
59
|
+
const discountTaxRate = taxes / discountAmount;
|
|
60
|
+
const discountsDifference = calculateDifference(discountAmount, currencyCode);
|
|
61
|
+
pricingAdapter.resultSheet().addDiscount({
|
|
62
|
+
amount: discountsDifference,
|
|
63
|
+
taxAmount: discountsDifference * discountTaxRate,
|
|
54
64
|
meta: {
|
|
55
65
|
adapter: OrderPriceRound.key,
|
|
56
66
|
},
|
|
67
|
+
// @ts-expect-error discountId has to miss
|
|
68
|
+
discountId: null,
|
|
57
69
|
});
|
|
58
70
|
}
|
|
59
71
|
const { amount: itemsAmount } = params.calculationSheet.total({
|
|
@@ -61,9 +73,14 @@ export const OrderPriceRound = {
|
|
|
61
73
|
useNetPrice: true,
|
|
62
74
|
});
|
|
63
75
|
if (itemsAmount) {
|
|
76
|
+
const taxes = params.calculationSheet.taxSum({
|
|
77
|
+
baseCategory: OrderPricingRowCategory.Items,
|
|
78
|
+
});
|
|
79
|
+
const itemTaxRate = taxes / itemsAmount;
|
|
80
|
+
const itemsDifference = calculateDifference(itemsAmount, currencyCode);
|
|
64
81
|
pricingAdapter.resultSheet().addItems({
|
|
65
|
-
amount:
|
|
66
|
-
taxAmount:
|
|
82
|
+
amount: itemsDifference,
|
|
83
|
+
taxAmount: itemsDifference * itemTaxRate,
|
|
67
84
|
meta: {
|
|
68
85
|
adapter: OrderPriceRound.key,
|
|
69
86
|
},
|
|
@@ -74,17 +91,28 @@ export const OrderPriceRound = {
|
|
|
74
91
|
useNetPrice: true,
|
|
75
92
|
});
|
|
76
93
|
if (paymentAmount) {
|
|
94
|
+
const taxes = params.calculationSheet.taxSum({
|
|
95
|
+
baseCategory: OrderPricingRowCategory.Payment,
|
|
96
|
+
});
|
|
97
|
+
const paymentTaxRate = taxes / paymentAmount;
|
|
98
|
+
const paymentsDifference = calculateDifference(paymentAmount, currencyCode);
|
|
77
99
|
pricingAdapter.resultSheet().addPayment({
|
|
78
|
-
amount:
|
|
79
|
-
taxAmount:
|
|
100
|
+
amount: paymentsDifference,
|
|
101
|
+
taxAmount: paymentsDifference * paymentTaxRate,
|
|
80
102
|
meta: {
|
|
81
103
|
adapter: OrderPriceRound.key,
|
|
82
104
|
},
|
|
83
105
|
});
|
|
84
106
|
}
|
|
85
|
-
|
|
107
|
+
// We need to consider added taxes from above calculations
|
|
108
|
+
// plus the prior taxes that are already on record
|
|
109
|
+
const priorTaxesAmount = params.calculationSheet.taxSum({
|
|
110
|
+
category: OrderPricingRowCategory.Taxes,
|
|
111
|
+
});
|
|
112
|
+
const additionalRoundedTaxes = pricingAdapter.resultSheet().taxSum({
|
|
86
113
|
category: OrderPricingRowCategory.Taxes,
|
|
87
114
|
});
|
|
115
|
+
const taxesAmount = priorTaxesAmount + additionalRoundedTaxes;
|
|
88
116
|
if (taxesAmount) {
|
|
89
117
|
const taxDifference = calculateDifference(taxesAmount, currencyCode);
|
|
90
118
|
pricingAdapter.resultSheet().calculation.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-round.js","sourceRoot":"","sources":["../../src/pricing/order-round.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EAEpB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAO7B,MAAM,CAAC,MAAM,eAAe,GAGxB;IACF,GAAG,mBAAmB;IAEtB,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"order-round.js","sourceRoot":"","sources":["../../src/pricing/order-round.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EAEpB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAO7B,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,YAAoB,EAAE,EAAE;IACnE,MAAM,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC,OAAO,CACpD,MAAM,EACN,eAAe,CAAC,QAAQ,CAAC,gBAAgB,EACzC,YAAY,CACb,CAAC;IACF,OAAO,aAAa,GAAG,MAAM,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,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,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC;oBACtD,QAAQ,EAAE,uBAAuB,CAAC,KAAK;iBACxC,CAAC,CAAC;gBACH,MAAM,sBAAsB,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;oBACjE,QAAQ,EAAE,uBAAuB,CAAC,KAAK;iBACxC,CAAC,CAAC;gBACH,MAAM,WAAW,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;gBAC9D,IAAI,WAAW,EAAE,CAAC;oBAChB,MAAM,aAAa,GAAG,mBAAmB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;oBACrE,cAAc,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;wBAC5C,QAAQ,EAAE,uBAAuB,CAAC,KAAK;wBACvC,MAAM,EAAE,aAAa;wBACrB,IAAI,EAAE;4BACJ,OAAO,EAAE,eAAe,CAAC,GAAG;yBAC7B;qBACF,CAAC,CAAC;oBACH,iGAAiG;oBACjG,yBAAyB;oBACzB,cAAc,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;wBAC5C,QAAQ,EAAE,IAAqB;wBAC/B,MAAM,EAAE,aAAa;wBACrB,IAAI,EAAE;4BACJ,OAAO,EAAE,eAAe,CAAC,GAAG;yBAC7B;qBACF,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,cAAc,CAAC,SAAS,EAAE,CAAC;YACpC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,oBAAoB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -10,13 +10,22 @@ interface PriceRoundSettings {
|
|
|
10
10
|
roundTo: (value: number, precision: number, currencyCode: string) => number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const calculateDifference = (amount: number, currencyCode: string) => {
|
|
14
|
+
const roundedAmount = OrderPriceRound.settings.roundTo(
|
|
15
|
+
amount,
|
|
16
|
+
OrderPriceRound.settings.defaultPrecision,
|
|
17
|
+
currencyCode,
|
|
18
|
+
);
|
|
19
|
+
return roundedAmount - amount;
|
|
20
|
+
};
|
|
21
|
+
|
|
13
22
|
export const OrderPriceRound: IOrderPricingAdapter & {
|
|
14
23
|
configure: (params: PriceRoundSettings) => void;
|
|
15
24
|
settings: PriceRoundSettings;
|
|
16
25
|
} = {
|
|
17
26
|
...OrderPricingAdapter,
|
|
18
27
|
|
|
19
|
-
key: 'shop.unchained.pricing.order-round',
|
|
28
|
+
key: 'shop.unchained.pricing.order-round-fixed',
|
|
20
29
|
version: '1.0.0',
|
|
21
30
|
label: 'Round order price to the next precision number',
|
|
22
31
|
orderIndex: 90,
|
|
@@ -39,15 +48,6 @@ export const OrderPriceRound: IOrderPricingAdapter & {
|
|
|
39
48
|
actions: (params) => {
|
|
40
49
|
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
41
50
|
|
|
42
|
-
const calculateDifference = (amount: number, currencyCode: string) => {
|
|
43
|
-
const roundedAmount = OrderPriceRound.settings.roundTo(
|
|
44
|
-
amount,
|
|
45
|
-
OrderPriceRound.settings.defaultPrecision,
|
|
46
|
-
currencyCode,
|
|
47
|
-
);
|
|
48
|
-
return roundedAmount - amount;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
51
|
return {
|
|
52
52
|
...pricingAdapter,
|
|
53
53
|
|
|
@@ -61,9 +61,14 @@ export const OrderPriceRound: IOrderPricingAdapter & {
|
|
|
61
61
|
useNetPrice: true,
|
|
62
62
|
});
|
|
63
63
|
if (deliveryAmount) {
|
|
64
|
+
const taxes = params.calculationSheet.taxSum({
|
|
65
|
+
baseCategory: OrderPricingRowCategory.Delivery,
|
|
66
|
+
});
|
|
67
|
+
const deliveryTaxRate = taxes / deliveryAmount;
|
|
68
|
+
const deliveryDifference = calculateDifference(deliveryAmount, currencyCode);
|
|
64
69
|
pricingAdapter.resultSheet().addDelivery({
|
|
65
|
-
amount:
|
|
66
|
-
taxAmount:
|
|
70
|
+
amount: deliveryDifference,
|
|
71
|
+
taxAmount: deliveryTaxRate * deliveryDifference,
|
|
67
72
|
meta: {
|
|
68
73
|
adapter: OrderPriceRound.key,
|
|
69
74
|
},
|
|
@@ -75,12 +80,20 @@ export const OrderPriceRound: IOrderPricingAdapter & {
|
|
|
75
80
|
useNetPrice: true,
|
|
76
81
|
});
|
|
77
82
|
if (discountAmount) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
const taxes = params.calculationSheet.taxSum({
|
|
84
|
+
baseCategory: OrderPricingRowCategory.Discounts,
|
|
85
|
+
});
|
|
86
|
+
const discountTaxRate = taxes / discountAmount;
|
|
87
|
+
const discountsDifference = calculateDifference(discountAmount, currencyCode);
|
|
88
|
+
|
|
89
|
+
pricingAdapter.resultSheet().addDiscount({
|
|
90
|
+
amount: discountsDifference,
|
|
91
|
+
taxAmount: discountsDifference * discountTaxRate,
|
|
81
92
|
meta: {
|
|
82
93
|
adapter: OrderPriceRound.key,
|
|
83
94
|
},
|
|
95
|
+
// @ts-expect-error discountId has to miss
|
|
96
|
+
discountId: null,
|
|
84
97
|
});
|
|
85
98
|
}
|
|
86
99
|
|
|
@@ -89,9 +102,14 @@ export const OrderPriceRound: IOrderPricingAdapter & {
|
|
|
89
102
|
useNetPrice: true,
|
|
90
103
|
});
|
|
91
104
|
if (itemsAmount) {
|
|
105
|
+
const taxes = params.calculationSheet.taxSum({
|
|
106
|
+
baseCategory: OrderPricingRowCategory.Items,
|
|
107
|
+
});
|
|
108
|
+
const itemTaxRate = taxes / itemsAmount;
|
|
109
|
+
const itemsDifference = calculateDifference(itemsAmount, currencyCode);
|
|
92
110
|
pricingAdapter.resultSheet().addItems({
|
|
93
|
-
amount:
|
|
94
|
-
taxAmount:
|
|
111
|
+
amount: itemsDifference,
|
|
112
|
+
taxAmount: itemsDifference * itemTaxRate,
|
|
95
113
|
meta: {
|
|
96
114
|
adapter: OrderPriceRound.key,
|
|
97
115
|
},
|
|
@@ -103,18 +121,30 @@ export const OrderPriceRound: IOrderPricingAdapter & {
|
|
|
103
121
|
useNetPrice: true,
|
|
104
122
|
});
|
|
105
123
|
if (paymentAmount) {
|
|
124
|
+
const taxes = params.calculationSheet.taxSum({
|
|
125
|
+
baseCategory: OrderPricingRowCategory.Payment,
|
|
126
|
+
});
|
|
127
|
+
const paymentTaxRate = taxes / paymentAmount;
|
|
128
|
+
const paymentsDifference = calculateDifference(paymentAmount, currencyCode);
|
|
129
|
+
|
|
106
130
|
pricingAdapter.resultSheet().addPayment({
|
|
107
|
-
amount:
|
|
108
|
-
taxAmount:
|
|
131
|
+
amount: paymentsDifference,
|
|
132
|
+
taxAmount: paymentsDifference * paymentTaxRate,
|
|
109
133
|
meta: {
|
|
110
134
|
adapter: OrderPriceRound.key,
|
|
111
135
|
},
|
|
112
136
|
});
|
|
113
137
|
}
|
|
114
138
|
|
|
115
|
-
|
|
139
|
+
// We need to consider added taxes from above calculations
|
|
140
|
+
// plus the prior taxes that are already on record
|
|
141
|
+
const priorTaxesAmount = params.calculationSheet.taxSum({
|
|
142
|
+
category: OrderPricingRowCategory.Taxes,
|
|
143
|
+
});
|
|
144
|
+
const additionalRoundedTaxes = pricingAdapter.resultSheet().taxSum({
|
|
116
145
|
category: OrderPricingRowCategory.Taxes,
|
|
117
146
|
});
|
|
147
|
+
const taxesAmount = priorTaxesAmount + additionalRoundedTaxes;
|
|
118
148
|
if (taxesAmount) {
|
|
119
149
|
const taxDifference = calculateDifference(taxesAmount, currencyCode);
|
|
120
150
|
pricingAdapter.resultSheet().calculation.push({
|