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.esm.js
CHANGED
|
@@ -588,11 +588,6 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
588
588
|
}
|
|
589
589
|
return 0;
|
|
590
590
|
});
|
|
591
|
-
console.log({
|
|
592
|
-
filteredFees: filteredFees_1,
|
|
593
|
-
filteredFeesResults: filteredFeesResults,
|
|
594
|
-
totalFromAllFees: totalFromAllFees,
|
|
595
|
-
});
|
|
596
591
|
if (totalFromAllFees && (totalFromAllFees === null || totalFromAllFees === void 0 ? void 0 : totalFromAllFees.length) > 0) {
|
|
597
592
|
var totalValueFromAllFees = totalFromAllFees.filter(function (i) { return !isNaN(+i) && +i > 0; }).reduce(function (previous, current) {
|
|
598
593
|
if (!isNaN(+previous) && !isNaN(+current)) {
|
|
@@ -1277,7 +1272,7 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1277
1272
|
};
|
|
1278
1273
|
|
|
1279
1274
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1280
|
-
var _a, _b, _c
|
|
1275
|
+
var _a, _b, _c;
|
|
1281
1276
|
var results = [];
|
|
1282
1277
|
// Separar fees por tipo: normais, TOTAL_PERCENTAGE e ICMS
|
|
1283
1278
|
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === FeeEnum.ICMS || f.feeId === FeeEnum.ICMS; });
|
|
@@ -1288,19 +1283,12 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1288
1283
|
f.feeId !== FeeEnum.ICMS &&
|
|
1289
1284
|
((_b = f.fee) === null || _b === void 0 ? void 0 : _b.feeCalculationTypeId) !== FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
|
|
1290
1285
|
});
|
|
1291
|
-
console.log('DEBUG getCtesFeesResult - Separação de fees:', {
|
|
1292
|
-
totalFees: feesToCalc.length,
|
|
1293
|
-
icmsFee: icmsFee ? { feeId: icmsFee.feeId, 'fee.id': (_a = icmsFee.fee) === null || _a === void 0 ? void 0 : _a.id } : null,
|
|
1294
|
-
totalPercentageCount: totalPercentageFees.length,
|
|
1295
|
-
normalFeesCount: normalFees.length,
|
|
1296
|
-
normalFeeIds: normalFees.map(function (f) { var _a; return ({ feeId: f.feeId, 'fee.id': (_a = f.fee) === null || _a === void 0 ? void 0 : _a.id }); })
|
|
1297
|
-
});
|
|
1298
1286
|
var _loop_1 = function (item) {
|
|
1299
1287
|
var feeTotal = calculateFee(item, cte, feesToCalc, false, allFeesForCalc);
|
|
1300
1288
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1301
1289
|
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1302
1290
|
var totalToPush = totalFee;
|
|
1303
|
-
if ((
|
|
1291
|
+
if ((_a = item.fee) === null || _a === void 0 ? void 0 : _a.parentId) {
|
|
1304
1292
|
var fee_1 = item.fee;
|
|
1305
1293
|
var siblingFees = feesToCalc === null || feesToCalc === void 0 ? void 0 : feesToCalc.filter(function (i) {
|
|
1306
1294
|
var _a, _b, _c;
|
|
@@ -1311,8 +1299,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1311
1299
|
});
|
|
1312
1300
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1313
1301
|
var siblingFeesResults = [];
|
|
1314
|
-
for (var
|
|
1315
|
-
var item_1 = siblingFees_1[
|
|
1302
|
+
for (var _e = 0, siblingFees_1 = siblingFees; _e < siblingFees_1.length; _e++) {
|
|
1303
|
+
var item_1 = siblingFees_1[_e];
|
|
1316
1304
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1317
1305
|
siblingFeesResults.push(result);
|
|
1318
1306
|
}
|
|
@@ -1323,7 +1311,7 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1323
1311
|
return 0;
|
|
1324
1312
|
});
|
|
1325
1313
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
1326
|
-
if (((
|
|
1314
|
+
if (((_b = siblingFeesResults[0]) === null || _b === void 0 ? void 0 : _b.totalFee) && ((_c = siblingFeesResults[0]) === null || _c === void 0 ? void 0 : _c.totalFee) > totalFee) {
|
|
1327
1315
|
totalToPush = 0;
|
|
1328
1316
|
}
|
|
1329
1317
|
}
|
|
@@ -1345,8 +1333,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1345
1333
|
_loop_1(item);
|
|
1346
1334
|
}
|
|
1347
1335
|
// PASSADA 2: Calcular fees TOTAL_PERCENTAGE usando a soma das fees normais já calculadas
|
|
1348
|
-
for (var
|
|
1349
|
-
var item = totalPercentageFees_1[
|
|
1336
|
+
for (var _d = 0, totalPercentageFees_1 = totalPercentageFees; _d < totalPercentageFees_1.length; _d++) {
|
|
1337
|
+
var item = totalPercentageFees_1[_d];
|
|
1350
1338
|
// Calcular soma das fees normais (excluindo TOTAL_PERCENTAGE e ICMS)
|
|
1351
1339
|
var totalWithoutPercentageFees = results
|
|
1352
1340
|
.filter(function (r) { return r.total > 0; })
|
|
@@ -1371,12 +1359,6 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1371
1359
|
var icmsRate = (cte.icmsIncidence !== undefined && cte.icmsIncidence !== null && !isNaN(+cte.icmsIncidence))
|
|
1372
1360
|
? +(cte.icmsIncidence) / 100
|
|
1373
1361
|
: icmsFee.value || 0;
|
|
1374
|
-
console.log('DEBUG ICMS getCtesFeesResult:', {
|
|
1375
|
-
valuesForIcms: valuesForIcms,
|
|
1376
|
-
icmsRate: icmsRate,
|
|
1377
|
-
totalBeforeIcms: valuesForIcms.reduce(function (sum, val) { return sum + val; }, 0),
|
|
1378
|
-
results: results.map(function (r) { return ({ feeId: r.feeId, total: r.total }); })
|
|
1379
|
-
});
|
|
1380
1362
|
// Usar calculateIcms diretamente
|
|
1381
1363
|
var icmsCalculation = calculateIcms(valuesForIcms, icmsRate);
|
|
1382
1364
|
if (icmsCalculation.isValid && !isNaN(+icmsCalculation.total)) {
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|