b2m-utils 0.0.244 → 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,18 +987,26 @@ var getFilteredFeesToAudit = function (_a) {
968
987
  }
969
988
  return false;
970
989
  });
971
- // Remover fees duplicadas, considerando feeId + intervalos de peso/km
972
- var seenFees = new Set();
990
+ console.log('[getFilteredFeesToAudit] Fees após filtro inicial:', filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.length);
991
+ // Remover fees duplicadas, mantendo apenas uma ocorrência de cada feeId
992
+ var seenFeeIds = new Set();
973
993
  var uniqueFees = filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.filter(function (fee) {
974
- var _a, _b, _c, _d, _e;
975
- // Criar chave única considerando feeId + intervalos + vehicleTypeId
976
- var key = "".concat(fee.feeId, "_").concat((_a = fee.minWeight) !== null && _a !== void 0 ? _a : 'null', "_").concat((_b = fee.maxWeight) !== null && _b !== void 0 ? _b : 'null', "_").concat((_c = fee.minKm) !== null && _c !== void 0 ? _c : 'null', "_").concat((_d = fee.maxKm) !== null && _d !== void 0 ? _d : 'null', "_").concat((_e = fee.vehicleTypeId) !== null && _e !== void 0 ? _e : 'null');
977
- if (seenFees.has(key)) {
994
+ var _a;
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
+ });
978
1002
  return false;
979
1003
  }
980
- seenFees.add(key);
1004
+ if (fee.feeId) {
1005
+ seenFeeIds.add(fee.feeId);
1006
+ }
981
1007
  return true;
982
1008
  });
1009
+ console.log('[getFilteredFeesToAudit] Fees após remoção de duplicatas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
983
1010
  // Garantir que ICMS sempre esteja presente
984
1011
  var hasIcms = uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.some(function (fee) { return fee.feeId === FeeEnum.ICMS; });
985
1012
  if (!hasIcms) {
@@ -1002,6 +1029,7 @@ var getFilteredFeesToAudit = function (_a) {
1002
1029
  },
1003
1030
  });
1004
1031
  }
1032
+ console.log('[getFilteredFeesToAudit] Fees finais retornadas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
1005
1033
  return uniqueFees;
1006
1034
  };
1007
1035
 
Binary file