b2m-utils 0.0.291 → 0.0.293
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/build/index.esm.js +13 -2
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +13 -2
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.esm.js
CHANGED
|
@@ -1004,8 +1004,17 @@ var calculateIcms = function (totalFromAllFees, icmsRate) {
|
|
|
1004
1004
|
var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc) {
|
|
1005
1005
|
var results = new Map();
|
|
1006
1006
|
// Separar fees em dois grupos
|
|
1007
|
-
|
|
1008
|
-
var
|
|
1007
|
+
// IMPORTANTE: ICMS não deve ser calculado aqui, ele tem tratamento especial no calculateFee
|
|
1008
|
+
var nonPercentageFees = allFees.filter(function (i) {
|
|
1009
|
+
var _a, _b;
|
|
1010
|
+
return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) !== FeeCalculationTypeEnum.TOTAL_PERCENTAGE &&
|
|
1011
|
+
((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== FeeEnum.ICMS;
|
|
1012
|
+
});
|
|
1013
|
+
var percentageFees = allFees.filter(function (i) {
|
|
1014
|
+
var _a, _b;
|
|
1015
|
+
return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) === FeeCalculationTypeEnum.TOTAL_PERCENTAGE &&
|
|
1016
|
+
((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== FeeEnum.ICMS;
|
|
1017
|
+
});
|
|
1009
1018
|
// Se não houver fees percentuais, retornar vazio
|
|
1010
1019
|
if (percentageFees.length === 0) {
|
|
1011
1020
|
return results;
|
|
@@ -1013,11 +1022,13 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc) {
|
|
|
1013
1022
|
console.log("\n\uD83D\uDD04 Calculando ".concat(percentageFees.length, " fees TOTAL_PERCENTAGE de forma iterativa"));
|
|
1014
1023
|
console.log("\uD83D\uDCCB Fees: ".concat(percentageFees.map(function (f) { var _a; return "".concat((_a = f.fee) === null || _a === void 0 ? void 0 : _a.name, " (").concat(f.value, "%)"); }).join(', ')));
|
|
1015
1024
|
// Calcular fees não-percentuais (base fixa)
|
|
1025
|
+
console.log("\uD83D\uDCCB Fees n\u00E3o-percentuais: ".concat(nonPercentageFees.map(function (f) { var _a; return "".concat((_a = f.fee) === null || _a === void 0 ? void 0 : _a.name); }).join(', ')));
|
|
1016
1026
|
var nonPercentageResults = filterSiblingFees(nonPercentageFees.map(function (it) {
|
|
1017
1027
|
return calculateFee(it, cte, allFees, false, allFeesForCalc);
|
|
1018
1028
|
}));
|
|
1019
1029
|
var baseNonPercentage = nonPercentageResults.reduce(function (sum, r) { return sum + (r.totalToCalc || 0); }, 0);
|
|
1020
1030
|
console.log("\uD83D\uDCCA Base n\u00E3o-percentual: R$ ".concat(baseNonPercentage.toFixed(2)));
|
|
1031
|
+
console.log("\uD83D\uDCCA Detalhamento: ".concat(nonPercentageResults.map(function (r) { var _a, _b; return "".concat((_a = r.fee) === null || _a === void 0 ? void 0 : _a.name, "=").concat((_b = r.totalToCalc) === null || _b === void 0 ? void 0 : _b.toFixed(2)); }).join(', ')));
|
|
1021
1032
|
// Calcular fees percentuais iterativamente até convergir
|
|
1022
1033
|
var maxIterations = 10;
|
|
1023
1034
|
var tolerance = 0.01; // Tolerância de 1 centavo
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|