@zauru-sdk/utils 6.9.1 → 6.9.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.
|
@@ -74,8 +74,12 @@ export const priceAdjustmentRuleMatches = (rule, ctx) => {
|
|
|
74
74
|
matchesFilter(filtros.tipoMode, filtros.tipos, ctx.tipo) &&
|
|
75
75
|
matchesFilter(filtros.programaMode, filtros.providerCategoryIds, ctx.providerCategoryId));
|
|
76
76
|
};
|
|
77
|
-
const roundMoney = (value
|
|
77
|
+
const roundMoney = (value, digits = 4) => {
|
|
78
|
+
const factor = 10 ** digits;
|
|
79
|
+
return Math.round((value + Number.EPSILON) * factor) / factor;
|
|
80
|
+
};
|
|
78
81
|
const formatMoney = (value) => Number.isInteger(value) ? String(value) : String(roundMoney(value));
|
|
82
|
+
const formatFinalPrice = (value) => roundMoney(value, 2).toFixed(2);
|
|
79
83
|
const formatSignedAmount = (value) => {
|
|
80
84
|
const abs = formatMoney(Math.abs(value));
|
|
81
85
|
return value < 0 ? `- ${abs}` : `+ ${abs}`;
|
|
@@ -92,7 +96,7 @@ export const formatPriceAdjustmentDescription = (result, baseLabel = "base") =>
|
|
|
92
96
|
if (result.steps.length === 0) {
|
|
93
97
|
return base;
|
|
94
98
|
}
|
|
95
|
-
return `${base} ${result.steps.map(formatRuleEffect).join(" ")} = ${
|
|
99
|
+
return `${base} ${result.steps.map(formatRuleEffect).join(" ")} = ${formatFinalPrice(result.finalPrice)}`;
|
|
96
100
|
};
|
|
97
101
|
export const applyPriceAdjustmentRules = (basePrice, rules, ctx) => {
|
|
98
102
|
const start = Number(basePrice);
|
|
@@ -131,7 +135,7 @@ export const applyPriceAdjustmentRules = (basePrice, rules, ctx) => {
|
|
|
131
135
|
}
|
|
132
136
|
const result = {
|
|
133
137
|
basePrice: roundMoney(safeBase),
|
|
134
|
-
finalPrice: roundMoney(runningTotal),
|
|
138
|
+
finalPrice: roundMoney(runningTotal, 2),
|
|
135
139
|
description: "",
|
|
136
140
|
steps,
|
|
137
141
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.2",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@zauru-sdk/types": "^6.14.0",
|
|
33
33
|
"moment": "^2.30.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "e779da25a020897d79e667a4f30f747b69fb807f"
|
|
36
36
|
}
|