b2m-utils 0.0.244 → 0.0.246

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
@@ -887,7 +887,7 @@ var getFilteredFeesToAudit = function (_a) {
887
887
  var _b;
888
888
  var lane = _a.lane, ratecard = _a.ratecard, cte = _a.cte;
889
889
  var filteredFees = (_b = lane === null || lane === void 0 ? void 0 : lane.RatecardLaneFee) === null || _b === void 0 ? void 0 : _b.filter(function (i) {
890
- var _a, _b, _c, _d, _e, _f, _g;
890
+ var _a, _b, _c, _d, _e, _f, _g, _h;
891
891
  var defaultConditionalFees = [
892
892
  exports.FeeEnum.SUFRAMA,
893
893
  exports.FeeEnum.TDA_FREIGHT,
@@ -955,15 +955,34 @@ var getFilteredFeesToAudit = function (_a) {
955
955
  }
956
956
  }
957
957
  }
958
- else if (i.minWeight) {
958
+ else if (i.minWeight || i.maxWeight) {
959
959
  if (cte === null || cte === void 0 ? void 0 : cte.taxedWeight) {
960
- if (Math.ceil(+cte.taxedWeight) >= +i.minWeight) {
961
- if (Math.ceil(+cte.taxedWeight) <= +i.maxWeight) {
960
+ var ceiledWeight = Math.ceil(+cte.taxedWeight);
961
+ console.log('[getFilteredFeesToAudit] Verificando fee por peso:', {
962
+ feeName: (_h = i.fee) === null || _h === void 0 ? void 0 : _h.name,
963
+ feeId: i.feeId,
964
+ minWeight: i.minWeight,
965
+ maxWeight: i.maxWeight,
966
+ cteTaxedWeight: cte.taxedWeight,
967
+ ceiledWeight: ceiledWeight,
968
+ passedMinCheck: ceiledWeight >= +i.minWeight,
969
+ passedMaxCheck: i.maxWeight ? ceiledWeight <= +i.maxWeight : 'sem maxWeight',
970
+ });
971
+ if (ceiledWeight >= +i.minWeight) {
972
+ if (ceiledWeight <= +i.maxWeight) {
973
+ console.log('[getFilteredFeesToAudit] ✅ Fee aprovada (dentro do intervalo)');
962
974
  return true;
963
975
  }
964
976
  else if (!i.maxWeight) {
977
+ console.log('[getFilteredFeesToAudit] ✅ Fee aprovada (excedente)');
965
978
  return true;
966
979
  }
980
+ else {
981
+ console.log('[getFilteredFeesToAudit] ❌ Fee rejeitada (peso excede maxWeight)');
982
+ }
983
+ }
984
+ else {
985
+ console.log('[getFilteredFeesToAudit] ❌ Fee rejeitada (peso menor que minWeight)');
967
986
  }
968
987
  }
969
988
  }
@@ -972,18 +991,26 @@ var getFilteredFeesToAudit = function (_a) {
972
991
  }
973
992
  return false;
974
993
  });
975
- // Remover fees duplicadas, considerando feeId + intervalos de peso/km
976
- var seenFees = new Set();
994
+ console.log('[getFilteredFeesToAudit] Fees após filtro inicial:', filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.length);
995
+ // Remover fees duplicadas, mantendo apenas uma ocorrência de cada feeId
996
+ var seenFeeIds = new Set();
977
997
  var uniqueFees = filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.filter(function (fee) {
978
- var _a, _b, _c, _d, _e;
979
- // Criar chave única considerando feeId + intervalos + vehicleTypeId
980
- 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');
981
- if (seenFees.has(key)) {
998
+ var _a;
999
+ if (fee.feeId && seenFeeIds.has(fee.feeId)) {
1000
+ console.log('[getFilteredFeesToAudit] ⚠️ Fee duplicada removida:', {
1001
+ feeName: (_a = fee.fee) === null || _a === void 0 ? void 0 : _a.name,
1002
+ feeId: fee.feeId,
1003
+ minWeight: fee.minWeight,
1004
+ maxWeight: fee.maxWeight,
1005
+ });
982
1006
  return false;
983
1007
  }
984
- seenFees.add(key);
1008
+ if (fee.feeId) {
1009
+ seenFeeIds.add(fee.feeId);
1010
+ }
985
1011
  return true;
986
1012
  });
1013
+ console.log('[getFilteredFeesToAudit] Fees após remoção de duplicatas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
987
1014
  // Garantir que ICMS sempre esteja presente
988
1015
  var hasIcms = uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.some(function (fee) { return fee.feeId === exports.FeeEnum.ICMS; });
989
1016
  if (!hasIcms) {
@@ -1006,6 +1033,7 @@ var getFilteredFeesToAudit = function (_a) {
1006
1033
  },
1007
1034
  });
1008
1035
  }
1036
+ console.log('[getFilteredFeesToAudit] Fees finais retornadas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
1009
1037
  return uniqueFees;
1010
1038
  };
1011
1039
 
package/build/index.js.gz CHANGED
Binary file