b2m-utils 0.0.269 → 0.0.271
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/enums/FeeEnum.d.ts +4 -1
- package/build/index.esm.js +64 -10
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +64 -10
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -186,6 +186,9 @@ exports.FeeEnum = void 0;
|
|
|
186
186
|
FeeEnum[FeeEnum["COLLECT"] = 151] = "COLLECT";
|
|
187
187
|
FeeEnum[FeeEnum["COLLECT_PERCENTAGE_TOTAL"] = 152] = "COLLECT_PERCENTAGE_TOTAL";
|
|
188
188
|
FeeEnum[FeeEnum["COLLECT_REVERSE_PERCENTAGE_TOTAL"] = 153] = "COLLECT_REVERSE_PERCENTAGE_TOTAL";
|
|
189
|
+
FeeEnum[FeeEnum["TRT_PERCENTAGE_TOTAL"] = 169] = "TRT_PERCENTAGE_TOTAL";
|
|
190
|
+
FeeEnum[FeeEnum["TDA_PERCENTAGE_TOTAL"] = 170] = "TDA_PERCENTAGE_TOTAL";
|
|
191
|
+
FeeEnum[FeeEnum["TDE_PERCENTAGE_TOTAL"] = 171] = "TDE_PERCENTAGE_TOTAL";
|
|
189
192
|
})(exports.FeeEnum || (exports.FeeEnum = {}));
|
|
190
193
|
|
|
191
194
|
exports.FreightRegionEnum = void 0;
|
|
@@ -1045,10 +1048,13 @@ var getFilteredFeesToAudit = function (_a) {
|
|
|
1045
1048
|
exports.FeeEnum.SUFRAMA,
|
|
1046
1049
|
exports.FeeEnum.TDA_FREIGHT,
|
|
1047
1050
|
exports.FeeEnum.TDA_MIN,
|
|
1051
|
+
exports.FeeEnum.TDA_PERCENTAGE_TOTAL,
|
|
1048
1052
|
exports.FeeEnum.TDE_FREIGHT,
|
|
1049
1053
|
exports.FeeEnum.TDE_MIN,
|
|
1054
|
+
exports.FeeEnum.TDE_PERCENTAGE_TOTAL,
|
|
1050
1055
|
exports.FeeEnum.TRT_FREIGHT,
|
|
1051
1056
|
exports.FeeEnum.TRT_MIN,
|
|
1057
|
+
exports.FeeEnum.TRT_PERCENTAGE_TOTAL,
|
|
1052
1058
|
exports.FeeEnum.RIVER_INSURANCE_COMMODITY_VALUE,
|
|
1053
1059
|
exports.FeeEnum.RIVER_INSURANCE_MIN_VALUE,
|
|
1054
1060
|
exports.FeeEnum.RIVER_REDISPATCH_COMMODITY_VALUE,
|
|
@@ -1270,13 +1276,18 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1270
1276
|
};
|
|
1271
1277
|
|
|
1272
1278
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1273
|
-
var _a, _b, _c;
|
|
1279
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1274
1280
|
var results = [];
|
|
1275
|
-
// Separar ICMS das outras fees
|
|
1281
|
+
// Separar ICMS e TOTAL_PERCENTAGE das outras fees
|
|
1276
1282
|
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === exports.FeeEnum.ICMS; });
|
|
1277
|
-
var
|
|
1283
|
+
var totalPercentageFees = feesToCalc.filter(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) === exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE; });
|
|
1284
|
+
var regularFees = feesToCalc.filter(function (f) {
|
|
1285
|
+
var _a, _b;
|
|
1286
|
+
return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) !== exports.FeeEnum.ICMS &&
|
|
1287
|
+
((_b = f.fee) === null || _b === void 0 ? void 0 : _b.feeCalculationTypeId) !== exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
|
|
1288
|
+
});
|
|
1278
1289
|
var _loop_1 = function (item) {
|
|
1279
|
-
var feeTotal = calculateFee(item, cte,
|
|
1290
|
+
var feeTotal = calculateFee(item, cte, regularFees, false, allFeesForCalc);
|
|
1280
1291
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1281
1292
|
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1282
1293
|
var totalToPush = totalFee;
|
|
@@ -1285,8 +1296,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1285
1296
|
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; });
|
|
1286
1297
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1287
1298
|
var siblingFeesResults = [];
|
|
1288
|
-
for (var
|
|
1289
|
-
var item_1 = siblingFees_1[
|
|
1299
|
+
for (var _h = 0, siblingFees_1 = siblingFees; _h < siblingFees_1.length; _h++) {
|
|
1300
|
+
var item_1 = siblingFees_1[_h];
|
|
1290
1301
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1291
1302
|
siblingFeesResults.push(result);
|
|
1292
1303
|
}
|
|
@@ -1313,12 +1324,55 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1313
1324
|
}
|
|
1314
1325
|
}
|
|
1315
1326
|
};
|
|
1316
|
-
// PRIMEIRA PASSADA: Calcular
|
|
1317
|
-
for (var _i = 0,
|
|
1318
|
-
var item =
|
|
1327
|
+
// PRIMEIRA PASSADA: Calcular fees regulares (exceto ICMS e TOTAL_PERCENTAGE)
|
|
1328
|
+
for (var _i = 0, regularFees_1 = regularFees; _i < regularFees_1.length; _i++) {
|
|
1329
|
+
var item = regularFees_1[_i];
|
|
1319
1330
|
_loop_1(item);
|
|
1320
1331
|
}
|
|
1321
|
-
|
|
1332
|
+
var _loop_2 = function (item) {
|
|
1333
|
+
var feeTotal = calculateFee(item, cte, regularFees, false, allFeesForCalc);
|
|
1334
|
+
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1335
|
+
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1336
|
+
var totalToPush = totalFee;
|
|
1337
|
+
if ((_d = item.fee) === null || _d === void 0 ? void 0 : _d.parentId) {
|
|
1338
|
+
var fee_2 = item.fee;
|
|
1339
|
+
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; });
|
|
1340
|
+
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1341
|
+
var siblingFeesResults = [];
|
|
1342
|
+
for (var _j = 0, siblingFees_2 = siblingFees; _j < siblingFees_2.length; _j++) {
|
|
1343
|
+
var siblingItem = siblingFees_2[_j];
|
|
1344
|
+
var result = calculateFee(siblingItem, cte, regularFees, false, allFeesForCalc);
|
|
1345
|
+
siblingFeesResults.push(result);
|
|
1346
|
+
}
|
|
1347
|
+
siblingFeesResults.sort(function (a, b) {
|
|
1348
|
+
if ((b === null || b === void 0 ? void 0 : b.totalFee) && (a === null || a === void 0 ? void 0 : a.totalFee)) {
|
|
1349
|
+
return +(b === null || b === void 0 ? void 0 : b.totalFee) - +(a === null || a === void 0 ? void 0 : a.totalFee);
|
|
1350
|
+
}
|
|
1351
|
+
return 0;
|
|
1352
|
+
});
|
|
1353
|
+
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
1354
|
+
if (((_e = siblingFeesResults[0]) === null || _e === void 0 ? void 0 : _e.totalFee) && ((_f = siblingFeesResults[0]) === null || _f === void 0 ? void 0 : _f.totalFee) > totalFee) {
|
|
1355
|
+
totalToPush = 0;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
if (!isNaN(+totalToPush)) {
|
|
1361
|
+
results.push({
|
|
1362
|
+
total: +(totalToPush).toFixed(2),
|
|
1363
|
+
resultFee: resultFee,
|
|
1364
|
+
feeValue: feeValue,
|
|
1365
|
+
feeId: item.feeId,
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
// SEGUNDA PASSADA: Calcular fees TOTAL_PERCENTAGE com base nas fees regulares já calculadas
|
|
1371
|
+
for (var _g = 0, totalPercentageFees_1 = totalPercentageFees; _g < totalPercentageFees_1.length; _g++) {
|
|
1372
|
+
var item = totalPercentageFees_1[_g];
|
|
1373
|
+
_loop_2(item);
|
|
1374
|
+
}
|
|
1375
|
+
// TERCEIRA PASSADA: Calcular ICMS com base nos resultados já filtrados
|
|
1322
1376
|
if (icmsFee) {
|
|
1323
1377
|
// Coletar apenas os valores das fees que realmente contam (total > 0)
|
|
1324
1378
|
var valuesForIcms = results
|
package/build/index.js.gz
CHANGED
|
Binary file
|