b2m-utils 0.0.218 → 0.0.220

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
@@ -129,6 +129,7 @@ exports.FeeEnum = void 0;
129
129
  FeeEnum[FeeEnum["COLLECT_COMMODITY_VALUE"] = 136] = "COLLECT_COMMODITY_VALUE";
130
130
  FeeEnum[FeeEnum["TDA_MIN"] = 141] = "TDA_MIN";
131
131
  FeeEnum[FeeEnum["TDA_FREIGHT"] = 142] = "TDA_FREIGHT";
132
+ FeeEnum[FeeEnum["FREIGHT_RODO_FIXED_VALUE"] = 143] = "FREIGHT_RODO_FIXED_VALUE";
132
133
  FeeEnum[FeeEnum["COLLECT"] = 151] = "COLLECT";
133
134
  FeeEnum[FeeEnum["COLLECT_PERCENTAGE_TOTAL"] = 152] = "COLLECT_PERCENTAGE_TOTAL";
134
135
  FeeEnum[FeeEnum["COLLECT_REVERSE_PERCENTAGE_TOTAL"] = 153] = "COLLECT_REVERSE_PERCENTAGE_TOTAL";
@@ -7094,7 +7095,7 @@ var getCteDateRange = function (ctes) {
7094
7095
  var getFilteredFeesToAudit = function (_a) {
7095
7096
  var _b;
7096
7097
  var lane = _a.lane, ratecard = _a.ratecard, cte = _a.cte;
7097
- return (_b = lane === null || lane === void 0 ? void 0 : lane.RatecardLaneFee) === null || _b === void 0 ? void 0 : _b.filter(function (i) {
7098
+ var filteredFees = (_b = lane === null || lane === void 0 ? void 0 : lane.RatecardLaneFee) === null || _b === void 0 ? void 0 : _b.filter(function (i) {
7098
7099
  var _a, _b, _c, _d, _e;
7099
7100
  var defaultConditionalFees = [
7100
7101
  exports.FeeEnum.SUFRAMA,
@@ -7139,7 +7140,16 @@ var getFilteredFeesToAudit = function (_a) {
7139
7140
  return state_1.value;
7140
7141
  }
7141
7142
  }
7142
- if (i.minWeight) {
7143
+ if (i.minKm !== null && i.minKm !== undefined) {
7144
+ if (cte === null || cte === void 0 ? void 0 : cte.distance) {
7145
+ var distanceInRange = +cte.distance >= +i.minKm && (!i.maxKm || +cte.distance <= +i.maxKm);
7146
+ var vehicleTypeMatches = !i.vehicleTypeId || cte.vehicleTypeId === i.vehicleTypeId;
7147
+ if (distanceInRange && vehicleTypeMatches) {
7148
+ return true;
7149
+ }
7150
+ }
7151
+ }
7152
+ else if (i.minWeight) {
7143
7153
  if (cte === null || cte === void 0 ? void 0 : cte.taxedWeight) {
7144
7154
  if (Math.ceil(+cte.taxedWeight) >= +i.minWeight) {
7145
7155
  if (Math.ceil(+cte.taxedWeight) <= +i.maxWeight) {
@@ -7156,6 +7166,18 @@ var getFilteredFeesToAudit = function (_a) {
7156
7166
  }
7157
7167
  return false;
7158
7168
  });
7169
+ // Remover fees duplicadas, mantendo apenas uma ocorrência de cada feeId
7170
+ var seenFeeIds = new Set();
7171
+ var uniqueFees = filteredFees === null || filteredFees === void 0 ? void 0 : filteredFees.filter(function (fee) {
7172
+ if (fee.feeId && seenFeeIds.has(fee.feeId)) {
7173
+ return false;
7174
+ }
7175
+ if (fee.feeId) {
7176
+ seenFeeIds.add(fee.feeId);
7177
+ }
7178
+ return true;
7179
+ });
7180
+ return uniqueFees;
7159
7181
  };
7160
7182
 
7161
7183
  var getLaneFromRatecard = function (cte) {
package/build/index.js.gz CHANGED
Binary file