b2m-utils 0.0.277 → 0.0.278
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 +31 -8
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +31 -8
- 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
|
@@ -1279,9 +1279,14 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1279
1279
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1280
1280
|
var _a, _b, _c;
|
|
1281
1281
|
var results = [];
|
|
1282
|
-
// Separar
|
|
1282
|
+
// Separar fees por tipo: normais, TOTAL_PERCENTAGE e ICMS
|
|
1283
1283
|
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === FeeEnum.ICMS; });
|
|
1284
|
-
var
|
|
1284
|
+
var totalPercentageFees = feesToCalc.filter(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) === FeeCalculationTypeEnum.TOTAL_PERCENTAGE; });
|
|
1285
|
+
var normalFees = feesToCalc.filter(function (f) {
|
|
1286
|
+
var _a, _b;
|
|
1287
|
+
return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) !== FeeEnum.ICMS &&
|
|
1288
|
+
((_b = f.fee) === null || _b === void 0 ? void 0 : _b.feeCalculationTypeId) !== FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
|
|
1289
|
+
});
|
|
1285
1290
|
var _loop_1 = function (item) {
|
|
1286
1291
|
var feeTotal = calculateFee(item, cte, feesToCalc, false, allFeesForCalc);
|
|
1287
1292
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
@@ -1292,8 +1297,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1292
1297
|
var siblingFees = feesToCalc === null || feesToCalc === void 0 ? void 0 : feesToCalc.filter(function (i) { var _a, _b; return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.parentId) === fee_1.parentId && ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== fee_1.id; });
|
|
1293
1298
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1294
1299
|
var siblingFeesResults = [];
|
|
1295
|
-
for (var
|
|
1296
|
-
var item_1 = siblingFees_1[
|
|
1300
|
+
for (var _e = 0, siblingFees_1 = siblingFees; _e < siblingFees_1.length; _e++) {
|
|
1301
|
+
var item_1 = siblingFees_1[_e];
|
|
1297
1302
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1298
1303
|
siblingFeesResults.push(result);
|
|
1299
1304
|
}
|
|
@@ -1320,12 +1325,30 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1320
1325
|
}
|
|
1321
1326
|
}
|
|
1322
1327
|
};
|
|
1323
|
-
//
|
|
1324
|
-
for (var _i = 0,
|
|
1325
|
-
var item =
|
|
1328
|
+
// PASSADA 1: Calcular fees normais (não TOTAL_PERCENTAGE, não ICMS)
|
|
1329
|
+
for (var _i = 0, normalFees_1 = normalFees; _i < normalFees_1.length; _i++) {
|
|
1330
|
+
var item = normalFees_1[_i];
|
|
1326
1331
|
_loop_1(item);
|
|
1327
1332
|
}
|
|
1328
|
-
//
|
|
1333
|
+
// PASSADA 2: Calcular fees TOTAL_PERCENTAGE usando a soma das fees normais já calculadas
|
|
1334
|
+
for (var _d = 0, totalPercentageFees_1 = totalPercentageFees; _d < totalPercentageFees_1.length; _d++) {
|
|
1335
|
+
var item = totalPercentageFees_1[_d];
|
|
1336
|
+
// Calcular soma das fees normais (excluindo TOTAL_PERCENTAGE e ICMS)
|
|
1337
|
+
var totalWithoutPercentageFees = results
|
|
1338
|
+
.filter(function (r) { return r.total > 0; })
|
|
1339
|
+
.reduce(function (sum, r) { return sum + r.total; }, 0);
|
|
1340
|
+
var percentage = item.value || 0;
|
|
1341
|
+
var calculatedValue = (totalWithoutPercentageFees * percentage) / 100;
|
|
1342
|
+
if (!isNaN(+calculatedValue) && calculatedValue > 0) {
|
|
1343
|
+
results.push({
|
|
1344
|
+
total: +(calculatedValue).toFixed(2),
|
|
1345
|
+
resultFee: "".concat(convertNumberToCurrency(totalWithoutPercentageFees, 'pt-br'), " x ").concat(percentage, "% = ").concat(convertNumberToCurrency(calculatedValue, 'pt-br')),
|
|
1346
|
+
feeValue: percentage,
|
|
1347
|
+
feeId: item.feeId,
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
// PASSADA 3: Calcular ICMS com base em todas as fees anteriores (normais + TOTAL_PERCENTAGE)
|
|
1329
1352
|
if (icmsFee) {
|
|
1330
1353
|
// Coletar apenas os valores das fees que realmente contam (total > 0)
|
|
1331
1354
|
var valuesForIcms = results
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|