b2m-utils 0.0.280 → 0.0.282
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 +23 -9
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +23 -9
- 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,42 @@ 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
|
-
var siblingFees = feesToCalc === null || feesToCalc === void 0 ? void 0 : feesToCalc.filter(function (i) {
|
|
1305
|
+
var siblingFees = feesToCalc === null || feesToCalc === void 0 ? void 0 : feesToCalc.filter(function (i) {
|
|
1306
|
+
var _a, _b, _c;
|
|
1307
|
+
return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.parentId) === fee_1.parentId &&
|
|
1308
|
+
((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== fee_1.id &&
|
|
1309
|
+
((_c = i.fee) === null || _c === void 0 ? void 0 : _c.id) !== FeeEnum.ICMS &&
|
|
1310
|
+
i.feeId !== FeeEnum.ICMS;
|
|
1311
|
+
});
|
|
1298
1312
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1299
1313
|
var siblingFeesResults = [];
|
|
1300
|
-
for (var
|
|
1301
|
-
var item_1 = siblingFees_1[
|
|
1314
|
+
for (var _f = 0, siblingFees_1 = siblingFees; _f < siblingFees_1.length; _f++) {
|
|
1315
|
+
var item_1 = siblingFees_1[_f];
|
|
1302
1316
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1303
1317
|
siblingFeesResults.push(result);
|
|
1304
1318
|
}
|
|
@@ -1309,7 +1323,7 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1309
1323
|
return 0;
|
|
1310
1324
|
});
|
|
1311
1325
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
1312
|
-
if (((
|
|
1326
|
+
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
1327
|
totalToPush = 0;
|
|
1314
1328
|
}
|
|
1315
1329
|
}
|
|
@@ -1331,8 +1345,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1331
1345
|
_loop_1(item);
|
|
1332
1346
|
}
|
|
1333
1347
|
// PASSADA 2: Calcular fees TOTAL_PERCENTAGE usando a soma das fees normais já calculadas
|
|
1334
|
-
for (var
|
|
1335
|
-
var item = totalPercentageFees_1[
|
|
1348
|
+
for (var _e = 0, totalPercentageFees_1 = totalPercentageFees; _e < totalPercentageFees_1.length; _e++) {
|
|
1349
|
+
var item = totalPercentageFees_1[_e];
|
|
1336
1350
|
// Calcular soma das fees normais (excluindo TOTAL_PERCENTAGE e ICMS)
|
|
1337
1351
|
var totalWithoutPercentageFees = results
|
|
1338
1352
|
.filter(function (r) { return r.total > 0; })
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|