b2m-utils 0.0.243 → 0.0.245

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.
@@ -883,7 +883,7 @@ var getFilteredFeesToAudit = function (_a) {
883
883
  var _b;
884
884
  var lane = _a.lane, ratecard = _a.ratecard, cte = _a.cte;
885
885
  var filteredFees = (_b = lane === null || lane === void 0 ? void 0 : lane.RatecardLaneFee) === null || _b === void 0 ? void 0 : _b.filter(function (i) {
886
- var _a, _b, _c, _d, _e, _f, _g;
886
+ var _a, _b, _c, _d, _e, _f, _g, _h;
887
887
  var defaultConditionalFees = [
888
888
  FeeEnum.SUFRAMA,
889
889
  FeeEnum.TDA_FREIGHT,
@@ -953,13 +953,32 @@ var getFilteredFeesToAudit = function (_a) {
953
953
  }
954
954
  else if (i.minWeight) {
955
955
  if (cte === null || cte === void 0 ? void 0 : cte.taxedWeight) {
956
- if (Math.ceil(+cte.taxedWeight) >= +i.minWeight) {
957
- if (Math.ceil(+cte.taxedWeight) <= +i.maxWeight) {
956
+ var ceiledWeight = Math.ceil(+cte.taxedWeight);
957
+ console.log('[getFilteredFeesToAudit] Verificando fee por peso:', {
958
+ feeName: (_h = i.fee) === null || _h === void 0 ? void 0 : _h.name,
959
+ feeId: i.feeId,
960
+ minWeight: i.minWeight,
961
+ maxWeight: i.maxWeight,
962
+ cteTaxedWeight: cte.taxedWeight,
963
+ ceiledWeight: ceiledWeight,
964
+ passedMinCheck: ceiledWeight >= +i.minWeight,
965
+ passedMaxCheck: i.maxWeight ? ceiledWeight <= +i.maxWeight : 'sem maxWeight',
966
+ });
967
+ if (ceiledWeight >= +i.minWeight) {
968
+ if (ceiledWeight <= +i.maxWeight) {
969
+ console.log('[getFilteredFeesToAudit] ✅ Fee aprovada (dentro do intervalo)');
958
970
  return true;
959
971
  }
960
972
  else if (!i.maxWeight) {
973
+ console.log('[getFilteredFeesToAudit] ✅ Fee aprovada (excedente)');
961
974
  return true;
962
975
  }
976
+ else {
977
+ console.log('[getFilteredFeesToAudit] ❌ Fee rejeitada (peso excede maxWeight)');
978
+ }
979
+ }
980
+ else {
981
+ console.log('[getFilteredFeesToAudit] ❌ Fee rejeitada (peso menor que minWeight)');
963
982
  }
964
983
  }
965
984
  }
@@ -968,10 +987,18 @@ var getFilteredFeesToAudit = function (_a) {
968
987
  }
969
988
  return false;
970
989
  });
990
+ console.log('[getFilteredFeesToAudit] Fees após filtro inicial:', filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.length);
971
991
  // Remover fees duplicadas, mantendo apenas uma ocorrência de cada feeId
972
992
  var seenFeeIds = new Set();
973
993
  var uniqueFees = filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.filter(function (fee) {
994
+ var _a;
974
995
  if (fee.feeId && seenFeeIds.has(fee.feeId)) {
996
+ console.log('[getFilteredFeesToAudit] ⚠️ Fee duplicada removida:', {
997
+ feeName: (_a = fee.fee) === null || _a === void 0 ? void 0 : _a.name,
998
+ feeId: fee.feeId,
999
+ minWeight: fee.minWeight,
1000
+ maxWeight: fee.maxWeight,
1001
+ });
975
1002
  return false;
976
1003
  }
977
1004
  if (fee.feeId) {
@@ -979,6 +1006,7 @@ var getFilteredFeesToAudit = function (_a) {
979
1006
  }
980
1007
  return true;
981
1008
  });
1009
+ console.log('[getFilteredFeesToAudit] Fees após remoção de duplicatas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
982
1010
  // Garantir que ICMS sempre esteja presente
983
1011
  var hasIcms = uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.some(function (fee) { return fee.feeId === FeeEnum.ICMS; });
984
1012
  if (!hasIcms) {
@@ -1001,6 +1029,7 @@ var getFilteredFeesToAudit = function (_a) {
1001
1029
  },
1002
1030
  });
1003
1031
  }
1032
+ console.log('[getFilteredFeesToAudit] Fees finais retornadas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
1004
1033
  return uniqueFees;
1005
1034
  };
1006
1035
 
Binary file