b2m-utils 0.0.271 → 0.0.273
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 +15 -57
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +15 -57
- 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
|
@@ -582,6 +582,9 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
582
582
|
var filteredFeesResults = filterSiblingFees(filteredFees.map(function (it) {
|
|
583
583
|
return calculateFee(it, cte, allFees, debug, allFeesForCalc);
|
|
584
584
|
}));
|
|
585
|
+
console.log({
|
|
586
|
+
filteredFeesResults: filteredFeesResults,
|
|
587
|
+
});
|
|
585
588
|
var totalFromAllFees = filteredFeesResults.map(function (result) {
|
|
586
589
|
if (result === null || result === void 0 ? void 0 : result.totalToCalc) {
|
|
587
590
|
return result.totalToCalc;
|
|
@@ -1272,18 +1275,16 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1272
1275
|
};
|
|
1273
1276
|
|
|
1274
1277
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1275
|
-
var _a, _b, _c
|
|
1278
|
+
var _a, _b, _c;
|
|
1276
1279
|
var results = [];
|
|
1277
|
-
// Separar ICMS
|
|
1280
|
+
// Separar ICMS das outras fees
|
|
1278
1281
|
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === FeeEnum.ICMS; });
|
|
1279
|
-
var
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) !== FeeEnum.ICMS &&
|
|
1283
|
-
((_b = f.fee) === null || _b === void 0 ? void 0 : _b.feeCalculationTypeId) !== FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
|
|
1282
|
+
var nonIcmsFees = feesToCalc.filter(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) !== FeeEnum.ICMS; });
|
|
1283
|
+
console.log({
|
|
1284
|
+
nonIcmsFees: nonIcmsFees,
|
|
1284
1285
|
});
|
|
1285
1286
|
var _loop_1 = function (item) {
|
|
1286
|
-
var feeTotal = calculateFee(item, cte,
|
|
1287
|
+
var feeTotal = calculateFee(item, cte, feesToCalc, false, allFeesForCalc);
|
|
1287
1288
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1288
1289
|
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1289
1290
|
var totalToPush = totalFee;
|
|
@@ -1292,8 +1293,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1292
1293
|
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
1294
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1294
1295
|
var siblingFeesResults = [];
|
|
1295
|
-
for (var
|
|
1296
|
-
var item_1 = siblingFees_1[
|
|
1296
|
+
for (var _d = 0, siblingFees_1 = siblingFees; _d < siblingFees_1.length; _d++) {
|
|
1297
|
+
var item_1 = siblingFees_1[_d];
|
|
1297
1298
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1298
1299
|
siblingFeesResults.push(result);
|
|
1299
1300
|
}
|
|
@@ -1320,55 +1321,12 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1320
1321
|
}
|
|
1321
1322
|
}
|
|
1322
1323
|
};
|
|
1323
|
-
// PRIMEIRA PASSADA: Calcular fees
|
|
1324
|
-
for (var _i = 0,
|
|
1325
|
-
var item =
|
|
1324
|
+
// PRIMEIRA PASSADA: Calcular todas as fees exceto ICMS
|
|
1325
|
+
for (var _i = 0, nonIcmsFees_1 = nonIcmsFees; _i < nonIcmsFees_1.length; _i++) {
|
|
1326
|
+
var item = nonIcmsFees_1[_i];
|
|
1326
1327
|
_loop_1(item);
|
|
1327
1328
|
}
|
|
1328
|
-
|
|
1329
|
-
var feeTotal = calculateFee(item, cte, regularFees, false, allFeesForCalc);
|
|
1330
|
-
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1331
|
-
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1332
|
-
var totalToPush = totalFee;
|
|
1333
|
-
if ((_d = item.fee) === null || _d === void 0 ? void 0 : _d.parentId) {
|
|
1334
|
-
var fee_2 = item.fee;
|
|
1335
|
-
var siblingFees = totalPercentageFees === null || totalPercentageFees === void 0 ? void 0 : totalPercentageFees.filter(function (i) { var _a, _b; return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.parentId) === fee_2.parentId && ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== fee_2.id; });
|
|
1336
|
-
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1337
|
-
var siblingFeesResults = [];
|
|
1338
|
-
for (var _j = 0, siblingFees_2 = siblingFees; _j < siblingFees_2.length; _j++) {
|
|
1339
|
-
var siblingItem = siblingFees_2[_j];
|
|
1340
|
-
var result = calculateFee(siblingItem, cte, regularFees, false, allFeesForCalc);
|
|
1341
|
-
siblingFeesResults.push(result);
|
|
1342
|
-
}
|
|
1343
|
-
siblingFeesResults.sort(function (a, b) {
|
|
1344
|
-
if ((b === null || b === void 0 ? void 0 : b.totalFee) && (a === null || a === void 0 ? void 0 : a.totalFee)) {
|
|
1345
|
-
return +(b === null || b === void 0 ? void 0 : b.totalFee) - +(a === null || a === void 0 ? void 0 : a.totalFee);
|
|
1346
|
-
}
|
|
1347
|
-
return 0;
|
|
1348
|
-
});
|
|
1349
|
-
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
1350
|
-
if (((_e = siblingFeesResults[0]) === null || _e === void 0 ? void 0 : _e.totalFee) && ((_f = siblingFeesResults[0]) === null || _f === void 0 ? void 0 : _f.totalFee) > totalFee) {
|
|
1351
|
-
totalToPush = 0;
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
if (!isNaN(+totalToPush)) {
|
|
1357
|
-
results.push({
|
|
1358
|
-
total: +(totalToPush).toFixed(2),
|
|
1359
|
-
resultFee: resultFee,
|
|
1360
|
-
feeValue: feeValue,
|
|
1361
|
-
feeId: item.feeId,
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
// SEGUNDA PASSADA: Calcular fees TOTAL_PERCENTAGE com base nas fees regulares já calculadas
|
|
1367
|
-
for (var _g = 0, totalPercentageFees_1 = totalPercentageFees; _g < totalPercentageFees_1.length; _g++) {
|
|
1368
|
-
var item = totalPercentageFees_1[_g];
|
|
1369
|
-
_loop_2(item);
|
|
1370
|
-
}
|
|
1371
|
-
// TERCEIRA PASSADA: Calcular ICMS com base nos resultados já filtrados
|
|
1329
|
+
// SEGUNDA PASSADA: Calcular ICMS com base nos resultados já filtrados
|
|
1372
1330
|
if (icmsFee) {
|
|
1373
1331
|
// Coletar apenas os valores das fees que realmente contam (total > 0)
|
|
1374
1332
|
var valuesForIcms = results
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|