b2m-utils 0.0.290 → 0.0.292

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.js CHANGED
@@ -582,7 +582,15 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
582
582
  switch (fee_1.feeCalculationTypeId) {
583
583
  case exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE:
584
584
  if (allFees && Array.isArray(allFees) && (allFees === null || allFees === void 0 ? void 0 : allFees.length) > 0) {
585
- var filteredFees = allFees.filter(function (i) { var _a, _b, _c; return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.id) !== fee_1.id && ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== exports.FeeEnum.ICMS && ((_c = i.fee) === null || _c === void 0 ? void 0 : _c.parentId) !== fee_1.parentId; });
585
+ // Filtrar fees excluindo a própria fee, ICMS e fees irmãs
586
+ // IMPORTANTE: Também excluir outras fees TOTAL_PERCENTAGE para evitar recursão infinita
587
+ var filteredFees = allFees.filter(function (i) {
588
+ var _a, _b, _c, _d;
589
+ return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.id) !== fee_1.id &&
590
+ ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== exports.FeeEnum.ICMS &&
591
+ ((_c = i.fee) === null || _c === void 0 ? void 0 : _c.parentId) !== fee_1.parentId &&
592
+ ((_d = i.fee) === null || _d === void 0 ? void 0 : _d.feeCalculationTypeId) !== exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE;
593
+ });
586
594
  var filteredFeesResults = filterSiblingFees(filteredFees.map(function (it) {
587
595
  return calculateFee(it, cte, allFees, debug, allFeesForCalc);
588
596
  }));
@@ -1000,8 +1008,17 @@ var calculateIcms = function (totalFromAllFees, icmsRate) {
1000
1008
  var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc) {
1001
1009
  var results = new Map();
1002
1010
  // Separar fees em dois grupos
1003
- var nonPercentageFees = allFees.filter(function (i) { var _a; return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) !== exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE; });
1004
- var percentageFees = allFees.filter(function (i) { var _a; return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) === exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE; });
1011
+ // IMPORTANTE: ICMS não deve ser calculado aqui, ele tem tratamento especial no calculateFee
1012
+ var nonPercentageFees = allFees.filter(function (i) {
1013
+ var _a, _b;
1014
+ return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) !== exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE &&
1015
+ ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== exports.FeeEnum.ICMS;
1016
+ });
1017
+ var percentageFees = allFees.filter(function (i) {
1018
+ var _a, _b;
1019
+ return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) === exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE &&
1020
+ ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) !== exports.FeeEnum.ICMS;
1021
+ });
1005
1022
  // Se não houver fees percentuais, retornar vazio
1006
1023
  if (percentageFees.length === 0) {
1007
1024
  return results;
package/build/index.js.gz CHANGED
Binary file