b2m-utils 0.0.280 → 0.0.281
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 +16 -8
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +16 -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
|
@@ -1277,28 +1277,36 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1277
1277
|
};
|
|
1278
1278
|
|
|
1279
1279
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1280
|
-
var _a, _b, _c;
|
|
1280
|
+
var _a, _b, _c, _d;
|
|
1281
1281
|
var results = [];
|
|
1282
1282
|
// Separar fees por tipo: normais, TOTAL_PERCENTAGE e ICMS
|
|
1283
|
-
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === FeeEnum.ICMS; });
|
|
1283
|
+
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; });
|
|
1284
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
1285
|
var normalFees = feesToCalc.filter(function (f) {
|
|
1286
1286
|
var _a, _b;
|
|
1287
1287
|
return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) !== FeeEnum.ICMS &&
|
|
1288
|
+
f.feeId !== FeeEnum.ICMS &&
|
|
1288
1289
|
((_b = f.fee) === null || _b === void 0 ? void 0 : _b.feeCalculationTypeId) !== FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
|
|
1289
1290
|
});
|
|
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
|
+
});
|
|
1290
1298
|
var _loop_1 = function (item) {
|
|
1291
1299
|
var feeTotal = calculateFee(item, cte, feesToCalc, false, allFeesForCalc);
|
|
1292
1300
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1293
1301
|
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1294
1302
|
var totalToPush = totalFee;
|
|
1295
|
-
if ((
|
|
1303
|
+
if ((_b = item.fee) === null || _b === void 0 ? void 0 : _b.parentId) {
|
|
1296
1304
|
var fee_1 = item.fee;
|
|
1297
1305
|
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; });
|
|
1298
1306
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1299
1307
|
var siblingFeesResults = [];
|
|
1300
|
-
for (var
|
|
1301
|
-
var item_1 = siblingFees_1[
|
|
1308
|
+
for (var _f = 0, siblingFees_1 = siblingFees; _f < siblingFees_1.length; _f++) {
|
|
1309
|
+
var item_1 = siblingFees_1[_f];
|
|
1302
1310
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1303
1311
|
siblingFeesResults.push(result);
|
|
1304
1312
|
}
|
|
@@ -1309,7 +1317,7 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1309
1317
|
return 0;
|
|
1310
1318
|
});
|
|
1311
1319
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
1312
|
-
if (((
|
|
1320
|
+
if (((_c = siblingFeesResults[0]) === null || _c === void 0 ? void 0 : _c.totalFee) && ((_d = siblingFeesResults[0]) === null || _d === void 0 ? void 0 : _d.totalFee) > totalFee) {
|
|
1313
1321
|
totalToPush = 0;
|
|
1314
1322
|
}
|
|
1315
1323
|
}
|
|
@@ -1331,8 +1339,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1331
1339
|
_loop_1(item);
|
|
1332
1340
|
}
|
|
1333
1341
|
// PASSADA 2: Calcular fees TOTAL_PERCENTAGE usando a soma das fees normais já calculadas
|
|
1334
|
-
for (var
|
|
1335
|
-
var item = totalPercentageFees_1[
|
|
1342
|
+
for (var _e = 0, totalPercentageFees_1 = totalPercentageFees; _e < totalPercentageFees_1.length; _e++) {
|
|
1343
|
+
var item = totalPercentageFees_1[_e];
|
|
1336
1344
|
// Calcular soma das fees normais (excluindo TOTAL_PERCENTAGE e ICMS)
|
|
1337
1345
|
var totalWithoutPercentageFees = results
|
|
1338
1346
|
.filter(function (r) { return r.total > 0; })
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|