b2m-utils 0.0.242 → 0.0.244

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.
@@ -1,6 +1,6 @@
1
- import { Cte, Ratecard, RatecardLane } from "../../types";
1
+ import { Cte, Ratecard, RatecardLane, RatecardLaneFee } from "../../types";
2
2
  export declare const getFilteredFeesToAudit: ({ lane, ratecard, cte, }: {
3
3
  lane: RatecardLane;
4
4
  ratecard: Ratecard;
5
5
  cte: Cte;
6
- }) => import("../../types").RatecardLaneFee[] | undefined;
6
+ }) => RatecardLaneFee[] | undefined;
@@ -968,17 +968,40 @@ var getFilteredFeesToAudit = function (_a) {
968
968
  }
969
969
  return false;
970
970
  });
971
- // Remover fees duplicadas, mantendo apenas uma ocorrência de cada feeId
972
- var seenFeeIds = new Set();
971
+ // Remover fees duplicadas, considerando feeId + intervalos de peso/km
972
+ var seenFees = new Set();
973
973
  var uniqueFees = filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.filter(function (fee) {
974
- if (fee.feeId && seenFeeIds.has(fee.feeId)) {
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)) {
975
978
  return false;
976
979
  }
977
- if (fee.feeId) {
978
- seenFeeIds.add(fee.feeId);
979
- }
980
+ seenFees.add(key);
980
981
  return true;
981
982
  });
983
+ // Garantir que ICMS sempre esteja presente
984
+ var hasIcms = uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.some(function (fee) { return fee.feeId === FeeEnum.ICMS; });
985
+ if (!hasIcms) {
986
+ // Adicionar ICMS com valor 0 se não existir
987
+ uniqueFees === null || uniqueFees === void 0 ? void 0 : uniqueFees.push({
988
+ id: 0,
989
+ laneId: lane.id,
990
+ feeId: FeeEnum.ICMS,
991
+ value: 0,
992
+ currencyId: null,
993
+ minKm: null,
994
+ maxKm: null,
995
+ minWeight: null,
996
+ maxWeight: null,
997
+ vehicleTypeId: null,
998
+ fee: {
999
+ id: FeeEnum.ICMS,
1000
+ name: 'ICMS',
1001
+ parentId: null,
1002
+ },
1003
+ });
1004
+ }
982
1005
  return uniqueFees;
983
1006
  };
984
1007
 
Binary file