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/enums/FeeEnum.d.ts
CHANGED
|
@@ -18,5 +18,8 @@ export declare enum FeeEnum {
|
|
|
18
18
|
FREIGHT_RODO_FIXED_VALUE = 143,
|
|
19
19
|
COLLECT = 151,
|
|
20
20
|
COLLECT_PERCENTAGE_TOTAL = 152,
|
|
21
|
-
COLLECT_REVERSE_PERCENTAGE_TOTAL = 153
|
|
21
|
+
COLLECT_REVERSE_PERCENTAGE_TOTAL = 153,
|
|
22
|
+
TRT_PERCENTAGE_TOTAL = 169,
|
|
23
|
+
TDA_PERCENTAGE_TOTAL = 170,
|
|
24
|
+
TDE_PERCENTAGE_TOTAL = 171
|
|
22
25
|
}
|
package/build/index.esm.js
CHANGED
|
@@ -182,6 +182,9 @@ var FeeEnum;
|
|
|
182
182
|
FeeEnum[FeeEnum["COLLECT"] = 151] = "COLLECT";
|
|
183
183
|
FeeEnum[FeeEnum["COLLECT_PERCENTAGE_TOTAL"] = 152] = "COLLECT_PERCENTAGE_TOTAL";
|
|
184
184
|
FeeEnum[FeeEnum["COLLECT_REVERSE_PERCENTAGE_TOTAL"] = 153] = "COLLECT_REVERSE_PERCENTAGE_TOTAL";
|
|
185
|
+
FeeEnum[FeeEnum["TRT_PERCENTAGE_TOTAL"] = 169] = "TRT_PERCENTAGE_TOTAL";
|
|
186
|
+
FeeEnum[FeeEnum["TDA_PERCENTAGE_TOTAL"] = 170] = "TDA_PERCENTAGE_TOTAL";
|
|
187
|
+
FeeEnum[FeeEnum["TDE_PERCENTAGE_TOTAL"] = 171] = "TDE_PERCENTAGE_TOTAL";
|
|
185
188
|
})(FeeEnum || (FeeEnum = {}));
|
|
186
189
|
|
|
187
190
|
var FreightRegionEnum;
|
|
@@ -1041,10 +1044,13 @@ var getFilteredFeesToAudit = function (_a) {
|
|
|
1041
1044
|
FeeEnum.SUFRAMA,
|
|
1042
1045
|
FeeEnum.TDA_FREIGHT,
|
|
1043
1046
|
FeeEnum.TDA_MIN,
|
|
1047
|
+
FeeEnum.TDA_PERCENTAGE_TOTAL,
|
|
1044
1048
|
FeeEnum.TDE_FREIGHT,
|
|
1045
1049
|
FeeEnum.TDE_MIN,
|
|
1050
|
+
FeeEnum.TDE_PERCENTAGE_TOTAL,
|
|
1046
1051
|
FeeEnum.TRT_FREIGHT,
|
|
1047
1052
|
FeeEnum.TRT_MIN,
|
|
1053
|
+
FeeEnum.TRT_PERCENTAGE_TOTAL,
|
|
1048
1054
|
FeeEnum.RIVER_INSURANCE_COMMODITY_VALUE,
|
|
1049
1055
|
FeeEnum.RIVER_INSURANCE_MIN_VALUE,
|
|
1050
1056
|
FeeEnum.RIVER_REDISPATCH_COMMODITY_VALUE,
|
|
@@ -1266,13 +1272,18 @@ var getLaneFromRatecard = function (cte) {
|
|
|
1266
1272
|
};
|
|
1267
1273
|
|
|
1268
1274
|
var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
1269
|
-
var _a, _b, _c;
|
|
1275
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1270
1276
|
var results = [];
|
|
1271
|
-
// Separar ICMS das outras fees
|
|
1277
|
+
// Separar ICMS e TOTAL_PERCENTAGE das outras fees
|
|
1272
1278
|
var icmsFee = feesToCalc.find(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.id) === FeeEnum.ICMS; });
|
|
1273
|
-
var
|
|
1279
|
+
var totalPercentageFees = feesToCalc.filter(function (f) { var _a; return ((_a = f.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) === FeeCalculationTypeEnum.TOTAL_PERCENTAGE; });
|
|
1280
|
+
var regularFees = feesToCalc.filter(function (f) {
|
|
1281
|
+
var _a, _b;
|
|
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;
|
|
1284
|
+
});
|
|
1274
1285
|
var _loop_1 = function (item) {
|
|
1275
|
-
var feeTotal = calculateFee(item, cte,
|
|
1286
|
+
var feeTotal = calculateFee(item, cte, regularFees, false, allFeesForCalc);
|
|
1276
1287
|
if (feeTotal === null || feeTotal === void 0 ? void 0 : feeTotal.totalFee) {
|
|
1277
1288
|
var totalFee = feeTotal.totalFee, resultFee = feeTotal.resultFee, feeValue = feeTotal.feeValue;
|
|
1278
1289
|
var totalToPush = totalFee;
|
|
@@ -1281,8 +1292,8 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1281
1292
|
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; });
|
|
1282
1293
|
if (siblingFees && (siblingFees === null || siblingFees === void 0 ? void 0 : siblingFees.length) > 0) {
|
|
1283
1294
|
var siblingFeesResults = [];
|
|
1284
|
-
for (var
|
|
1285
|
-
var item_1 = siblingFees_1[
|
|
1295
|
+
for (var _h = 0, siblingFees_1 = siblingFees; _h < siblingFees_1.length; _h++) {
|
|
1296
|
+
var item_1 = siblingFees_1[_h];
|
|
1286
1297
|
var result = calculateFee(item_1, cte, feesToCalc, false, allFeesForCalc);
|
|
1287
1298
|
siblingFeesResults.push(result);
|
|
1288
1299
|
}
|
|
@@ -1309,12 +1320,55 @@ var getCtesFeesResult = function (feesToCalc, cte, allFeesForCalc) {
|
|
|
1309
1320
|
}
|
|
1310
1321
|
}
|
|
1311
1322
|
};
|
|
1312
|
-
// PRIMEIRA PASSADA: Calcular
|
|
1313
|
-
for (var _i = 0,
|
|
1314
|
-
var item =
|
|
1323
|
+
// PRIMEIRA PASSADA: Calcular fees regulares (exceto ICMS e TOTAL_PERCENTAGE)
|
|
1324
|
+
for (var _i = 0, regularFees_1 = regularFees; _i < regularFees_1.length; _i++) {
|
|
1325
|
+
var item = regularFees_1[_i];
|
|
1315
1326
|
_loop_1(item);
|
|
1316
1327
|
}
|
|
1317
|
-
|
|
1328
|
+
var _loop_2 = function (item) {
|
|
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
|
|
1318
1372
|
if (icmsFee) {
|
|
1319
1373
|
// Coletar apenas os valores das fees que realmente contam (total > 0)
|
|
1320
1374
|
var valuesForIcms = results
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|