b2m-utils 0.0.283 → 0.0.284
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 +7 -25
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +7 -25
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -592,11 +592,6 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
592
592
|
}
|
|
593
593
|
return 0;
|
|
594
594
|
});
|
|
595
|
-
console.log({
|
|
596
|
-
filteredFees: filteredFees_1,
|
|
597
|
-
filteredFeesResults: filteredFeesResults,
|
|
598
|
-
totalFromAllFees: totalFromAllFees,
|
|
599
|
-
});
|
|
600
595
|
if (totalFromAllFees && (totalFromAllFees === null || totalFromAllFees === void 0 ? void 0 : totalFromAllFees.length) > 0) {
|
|
601
596
|
var totalValueFromAllFees = totalFromAllFees.filter(function (i) { return !isNaN(+i) && +i > 0; }).reduce(function (previous, current) {
|
|
602
597
|
if (!isNaN(+previous) && !isNaN(+current)) {
|
|
@@ -1281,7 +1276,7 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1281
1276
|
};
|
|
1282
1277
|
|
|
1283
1278
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1284
|
-
var _a, _b, _c
|
|
1279
|
+
var _a, _b, _c;
|
|
1285
1280
|
var results = [];
|
|
1286
1281
|
// Separar fees por tipo: normais, TOTAL_PERCENTAGE e ICMS
|
|
1287
1282
|
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === exports.FeeEnum.ICMS || f.feeId === exports.FeeEnum.ICMS; });
|
|
@@ -1292,19 +1287,12 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1292
1287
|
f.feeId !== exports.FeeEnum.ICMS &&
|
|
1293
1288
|
((_b = f.fee) === null || _b === void 0 ? void 0 : _b.feeCalculationTypeId) !== exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
|
|
1294
1289
|
});
|
|
1295
|
-
console.log('DEBUG getCtesFeesResult - Separação de fees:', {
|
|
1296
|
-
totalFees: feesToCalc.length,
|
|
1297
|
-
icmsFee: icmsFee ? { feeId: icmsFee.feeId, 'fee.id': (_a = icmsFee.fee) === null || _a === void 0 ? void 0 : _a.id } : null,
|
|
1298
|
-
totalPercentageCount: totalPercentageFees.length,
|
|
1299
|
-
normalFeesCount: normalFees.length,
|
|
1300
|
-
normalFeeIds: normalFees.map(function (f) { var _a; return ({ feeId: f.feeId, 'fee.id': (_a = f.fee) === null || _a === void 0 ? void 0 : _a.id }); })
|
|
1301
|
-
});
|
|
1302
1290
|
var _loop_1 = function (item) {
|
|
1303
1291
|
var feeTotal = calculateFee(item, cte, feesToCalc, false, allFeesForCalc);
|
|
1304
1292
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1305
1293
|
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1306
1294
|
var totalToPush = totalFee;
|
|
1307
|
-
if ((
|
|
1295
|
+
if ((_a = item.fee) === null || _a === void 0 ? void 0 : _a.parentId) {
|
|
1308
1296
|
var fee_1 = item.fee;
|
|
1309
1297
|
var siblingFees = feesToCalc === null || feesToCalc === void 0 ? void 0 : feesToCalc.filter(function (i) {
|
|
1310
1298
|
var _a, _b, _c;
|
|
@@ -1315,8 +1303,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1315
1303
|
});
|
|
1316
1304
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1317
1305
|
var siblingFeesResults = [];
|
|
1318
|
-
for (var
|
|
1319
|
-
var item_1 = siblingFees_1[
|
|
1306
|
+
for (var _e = 0, siblingFees_1 = siblingFees; _e < siblingFees_1.length; _e++) {
|
|
1307
|
+
var item_1 = siblingFees_1[_e];
|
|
1320
1308
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1321
1309
|
siblingFeesResults.push(result);
|
|
1322
1310
|
}
|
|
@@ -1327,7 +1315,7 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1327
1315
|
return 0;
|
|
1328
1316
|
});
|
|
1329
1317
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
1330
|
-
if (((
|
|
1318
|
+
if (((_b = siblingFeesResults[0]) === null || _b === void 0 ? void 0 : _b.totalFee) && ((_c = siblingFeesResults[0]) === null || _c === void 0 ? void 0 : _c.totalFee) > totalFee) {
|
|
1331
1319
|
totalToPush = 0;
|
|
1332
1320
|
}
|
|
1333
1321
|
}
|
|
@@ -1349,8 +1337,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1349
1337
|
_loop_1(item);
|
|
1350
1338
|
}
|
|
1351
1339
|
// PASSADA 2: Calcular fees TOTAL_PERCENTAGE usando a soma das fees normais já calculadas
|
|
1352
|
-
for (var
|
|
1353
|
-
var item = totalPercentageFees_1[
|
|
1340
|
+
for (var _d = 0, totalPercentageFees_1 = totalPercentageFees; _d < totalPercentageFees_1.length; _d++) {
|
|
1341
|
+
var item = totalPercentageFees_1[_d];
|
|
1354
1342
|
// Calcular soma das fees normais (excluindo TOTAL_PERCENTAGE e ICMS)
|
|
1355
1343
|
var totalWithoutPercentageFees = results
|
|
1356
1344
|
.filter(function (r) { return r.total > 0; })
|
|
@@ -1375,12 +1363,6 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1375
1363
|
var icmsRate = (cte.icmsIncidence !== undefined && cte.icmsIncidence !== null && !isNaN(+cte.icmsIncidence))
|
|
1376
1364
|
? +(cte.icmsIncidence) / 100
|
|
1377
1365
|
: icmsFee.value || 0;
|
|
1378
|
-
console.log('DEBUG ICMS getCtesFeesResult:', {
|
|
1379
|
-
valuesForIcms: valuesForIcms,
|
|
1380
|
-
icmsRate: icmsRate,
|
|
1381
|
-
totalBeforeIcms: valuesForIcms.reduce(function (sum, val) { return sum + val; }, 0),
|
|
1382
|
-
results: results.map(function (r) { return ({ feeId: r.feeId, total: r.total }); })
|
|
1383
|
-
});
|
|
1384
1366
|
// Usar calculateIcms diretamente
|
|
1385
1367
|
var icmsCalculation = calculateIcms(valuesForIcms, icmsRate);
|
|
1386
1368
|
if (icmsCalculation.isValid && !isNaN(+icmsCalculation.total)) {
|
package/build/index.js.gz
CHANGED
|
Binary file
|