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.
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,
@@ -957,13 +957,32 @@ var getFilteredFeesToAudit = function (_a) {
957
957
  }
958
958
  else if (i.minWeight) {
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,10 +991,18 @@ var getFilteredFeesToAudit = function (_a) {
972
991
  }
973
992
  return false;
974
993
  });
994
+ console.log('[getFilteredFeesToAudit] Fees após filtro inicial:', filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.length);
975
995
  // Remover fees duplicadas, mantendo apenas uma ocorrência de cada feeId
976
996
  var seenFeeIds = new Set();
977
997
  var uniqueFees = filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.filter(function (fee) {
998
+ var _a;
978
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
+ });
979
1006
  return false;
980
1007
  }
981
1008
  if (fee.feeId) {
@@ -983,6 +1010,7 @@ var getFilteredFeesToAudit = function (_a) {
983
1010
  }
984
1011
  return true;
985
1012
  });
1013
+ console.log('[getFilteredFeesToAudit] Fees após remoção de duplicatas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
986
1014
  // Garantir que ICMS sempre esteja presente
987
1015
  var hasIcms = uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.some(function (fee) { return fee.feeId === exports.FeeEnum.ICMS; });
988
1016
  if (!hasIcms) {
@@ -1005,6 +1033,7 @@ var getFilteredFeesToAudit = function (_a) {
1005
1033
  },
1006
1034
  });
1007
1035
  }
1036
+ console.log('[getFilteredFeesToAudit] Fees finais retornadas:', uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.length);
1008
1037
  return uniqueFees;
1009
1038
  };
1010
1039
 
package/build/index.js.gz CHANGED
Binary file