b2m-utils 0.0.183 → 0.0.184

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.
@@ -6955,19 +6955,31 @@ var getFilteredFeesToAudit = function (_a) {
6955
6955
  };
6956
6956
 
6957
6957
  var getLaneFromRatecard = function (cte) {
6958
- var _a, _b;
6958
+ var _a, _b, _c, _d;
6959
6959
  var ratecard = getRatecardFromCte(cte);
6960
6960
  var cityOriginId = cte.cityOriginId, cityDestination = cte.cityDestination;
6961
6961
  var destinationUf = (_a = cityDestination === null || cityDestination === void 0 ? void 0 : cityDestination.state) === null || _a === void 0 ? void 0 : _a.uf;
6962
6962
  if ((ratecard === null || ratecard === void 0 ? void 0 : ratecard.RatecardLane) && ((_b = ratecard === null || ratecard === void 0 ? void 0 : ratecard.RatecardLane) === null || _b === void 0 ? void 0 : _b.length) > 0 && cityOriginId && destinationUf) {
6963
- var lane = ratecard.RatecardLane.find(function (i) {
6964
- if (i.cityOriginId === cte.cityOriginId && i.ufDestination === destinationUf) {
6965
- return true;
6966
- }
6967
- return false;
6963
+ // Primeiro, buscar rota direta (Origem -> Destino)
6964
+ var directLane = ratecard.RatecardLane.find(function (i) {
6965
+ return i.cityOriginId === cityOriginId && i.ufDestination === destinationUf;
6968
6966
  });
6969
- return lane;
6967
+ if (directLane) {
6968
+ return directLane;
6969
+ }
6970
+ // Se não encontrar rota direta, buscar rota inversa (Destino -> Origem)
6971
+ // Para isso, precisamos encontrar a UF da origem
6972
+ var originUf_1 = (_d = (_c = cte.cityOrigin) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.uf;
6973
+ if (originUf_1) {
6974
+ var reverseLane = ratecard.RatecardLane.find(function (i) {
6975
+ return i.cityOriginId === (cityDestination === null || cityDestination === void 0 ? void 0 : cityDestination.id) && i.ufDestination === originUf_1;
6976
+ });
6977
+ if (reverseLane) {
6978
+ return reverseLane;
6979
+ }
6980
+ }
6970
6981
  }
6982
+ return undefined;
6971
6983
  };
6972
6984
 
6973
6985
  var getNormalizedCityName = function (name) {
Binary file