@reactionary/ucp 0.10.36 → 0.10.38
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.
|
@@ -52,22 +52,26 @@ function toUcpCostTotals(price, items = []) {
|
|
|
52
52
|
const subtotal = items.length > 0 ? items.reduce((sum, item) => sum + getLineSubtotal(item), 0) : getMoneyValue(price.totalProductPrice);
|
|
53
53
|
const itemsDiscount = items.reduce((sum, item) => sum + getLineDiscount(item), 0);
|
|
54
54
|
const orderDiscount = Math.max(Math.abs(getMoneyValue(price.totalDiscount)) - itemsDiscount, 0);
|
|
55
|
+
const shipping = getMoneyValue(price.totalShipping);
|
|
56
|
+
const fee = getMoneyValue(price.totalSurcharge);
|
|
57
|
+
const grandTotal = getMoneyValue(price.grandTotal);
|
|
58
|
+
const taxIncluded = subtotal - itemsDiscount - orderDiscount + shipping + fee === grandTotal;
|
|
55
59
|
const totals = [
|
|
56
60
|
{ type: "subtotal", amount: subtotal }
|
|
57
61
|
];
|
|
58
62
|
const optionalTotals = [
|
|
59
63
|
["items_discount", -itemsDiscount],
|
|
60
64
|
["discount", -orderDiscount],
|
|
61
|
-
["fulfillment",
|
|
62
|
-
["tax", getMoneyValue(price.totalTax)],
|
|
63
|
-
["fee",
|
|
65
|
+
["fulfillment", shipping],
|
|
66
|
+
["tax", taxIncluded ? 0 : getMoneyValue(price.totalTax)],
|
|
67
|
+
["fee", fee]
|
|
64
68
|
];
|
|
65
69
|
for (const [type, amount] of optionalTotals) {
|
|
66
70
|
if (amount !== 0) {
|
|
67
71
|
totals.push({ type, amount });
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
|
-
totals.push({ type: "total", amount:
|
|
74
|
+
totals.push({ type: "total", amount: grandTotal });
|
|
71
75
|
return totals;
|
|
72
76
|
}
|
|
73
77
|
function toUcpTotals(amount) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/ucp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Solteq/reactionary.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@reactionary/core": "0.10.
|
|
12
|
+
"@reactionary/core": "0.10.38",
|
|
13
13
|
"zod": "4.1.9"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|