b2m-utils 0.0.268 → 0.0.269

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.
@@ -9,5 +9,6 @@ export declare enum FeeCalculationTypeEnum {
9
9
  FREIGHT = 8,
10
10
  TOTAL_PERCENTAGE = 9,
11
11
  MIN_VALUE = 10,
12
- SUM_CONTAINERS = 11
12
+ SUM_CONTAINERS = 11,
13
+ VOLUMES_QUANTITY = 12
13
14
  }
@@ -144,6 +144,7 @@ var FeeCalculationTypeEnum;
144
144
  FeeCalculationTypeEnum[FeeCalculationTypeEnum["TOTAL_PERCENTAGE"] = 9] = "TOTAL_PERCENTAGE";
145
145
  FeeCalculationTypeEnum[FeeCalculationTypeEnum["MIN_VALUE"] = 10] = "MIN_VALUE";
146
146
  FeeCalculationTypeEnum[FeeCalculationTypeEnum["SUM_CONTAINERS"] = 11] = "SUM_CONTAINERS";
147
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["VOLUMES_QUANTITY"] = 12] = "VOLUMES_QUANTITY";
147
148
  })(FeeCalculationTypeEnum || (FeeCalculationTypeEnum = {}));
148
149
 
149
150
  var FeeCategoryEnum;
@@ -520,7 +521,7 @@ var filterSiblingFees = function (fees) {
520
521
  };
521
522
 
522
523
  var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCalc) {
523
- var _a, _b, _c, _d, _e, _f, _g;
524
+ var _a, _b, _c, _d, _e, _f, _g, _h;
524
525
  if (debug === void 0) { debug = false; }
525
526
  if (ratecardLaneFee.fee) {
526
527
  // Buscar o ratecard correto do CTE usando getRatecardFromCte
@@ -596,7 +597,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
596
597
  if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
597
598
  var valueToMultiply = (+value / 100);
598
599
  var total_1 = +totalValueFromAllFees * valueToMultiply;
599
- var _h = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _h.adjustedTotal, redeliveryInfo_1 = _h.redeliveryInfo;
600
+ var _j = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _j.adjustedTotal, redeliveryInfo_1 = _j.redeliveryInfo;
600
601
  total_1 = adjustedTotal_1;
601
602
  var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
602
603
  var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
@@ -619,7 +620,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
619
620
  var shouldApplyFraction = +cte.taxedWeight > minWeightForFraction;
620
621
  var fractions = shouldApplyFraction ? Math.ceil(+cte.taxedWeight / 100) : 1;
621
622
  var total_2 = fractions * value;
622
- var _j = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _j.adjustedTotal, redeliveryInfo_2 = _j.redeliveryInfo;
623
+ var _k = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _k.adjustedTotal, redeliveryInfo_2 = _k.redeliveryInfo;
623
624
  total_2 = adjustedTotal_2;
624
625
  var valueCurrency_1 = (+value).toLocaleString('pt-br', {
625
626
  style: 'currency',
@@ -640,7 +641,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
640
641
  if (value && (cte === null || cte === void 0 ? void 0 : cte.freightValue)) {
641
642
  if (!isNaN(+value) && !isNaN(+cte.freightValue)) {
642
643
  var total_3 = +cte.freightValue * (+value / 100);
643
- var _k = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _k.adjustedTotal, redeliveryInfo_3 = _k.redeliveryInfo;
644
+ var _l = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _l.adjustedTotal, redeliveryInfo_3 = _l.redeliveryInfo;
644
645
  total_3 = adjustedTotal_3;
645
646
  var freightValueCurrency = (+cte.freightValue).toLocaleString('pt-br', {
646
647
  style: 'currency',
@@ -675,7 +676,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
675
676
  case FeeCalculationTypeEnum.MIN_VALUE:
676
677
  case FeeCalculationTypeEnum.FIXED:
677
678
  var total = +value;
678
- var _l = applyRedeliveryMultiplier(total, cte), adjustedTotal = _l.adjustedTotal, redeliveryInfo = _l.redeliveryInfo;
679
+ var _m = applyRedeliveryMultiplier(total, cte), adjustedTotal = _m.adjustedTotal, redeliveryInfo = _m.redeliveryInfo;
679
680
  total = adjustedTotal;
680
681
  var valueCurrency = (+value).toLocaleString('pt-br', {
681
682
  style: 'currency',
@@ -727,7 +728,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
727
728
  // Somar ao total
728
729
  total_4 += additionalValue;
729
730
  // Aplicar multiplicador de redelivery ao valor final
730
- var _m = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _m.adjustedTotal, redeliveryInfo_4 = _m.redeliveryInfo;
731
+ var _o = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _o.adjustedTotal, redeliveryInfo_4 = _o.redeliveryInfo;
731
732
  total_4 = adjustedTotal_4;
732
733
  var valueCurrency_2 = (+highestIntervalFee.value).toLocaleString('pt-br', {
733
734
  style: 'currency',
@@ -769,7 +770,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
769
770
  // Somar ao total
770
771
  total_5 += additionalValue;
771
772
  // Aplicar multiplicador de redelivery ao valor final
772
- var _o = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _o.adjustedTotal, redeliveryInfo_5 = _o.redeliveryInfo;
773
+ var _p = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _p.adjustedTotal, redeliveryInfo_5 = _p.redeliveryInfo;
773
774
  total_5 = adjustedTotal_5;
774
775
  var valueCurrency_3 = (+highestIntervalFee.value).toLocaleString('pt-br', {
775
776
  style: 'currency',
@@ -789,7 +790,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
789
790
  if (value) {
790
791
  var commodityValue = (_d = cte === null || cte === void 0 ? void 0 : cte.commodityValue) !== null && _d !== void 0 ? _d : 0;
791
792
  var total_6 = +commodityValue * (+value / 100);
792
- var _p = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _p.adjustedTotal, redeliveryInfo_6 = _p.redeliveryInfo;
793
+ var _q = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _q.adjustedTotal, redeliveryInfo_6 = _q.redeliveryInfo;
793
794
  total_6 = adjustedTotal_6;
794
795
  var resultCurrency_6 = (+total_6).toLocaleString('pt-br', {
795
796
  style: 'currency',
@@ -804,7 +805,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
804
805
  if (value) {
805
806
  var taxedWeight = (_e = cte === null || cte === void 0 ? void 0 : cte.taxedWeight) !== null && _e !== void 0 ? _e : 0;
806
807
  var total_7 = +taxedWeight * +value;
807
- var _q = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _q.adjustedTotal, redeliveryInfo_7 = _q.redeliveryInfo;
808
+ var _r = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _r.adjustedTotal, redeliveryInfo_7 = _r.redeliveryInfo;
808
809
  total_7 = adjustedTotal_7;
809
810
  var resultCurrency_7 = (+total_7).toLocaleString('pt-br', {
810
811
  style: 'currency',
@@ -817,6 +818,21 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
817
818
  resultFee = result_7;
818
819
  }
819
820
  break;
821
+ case FeeCalculationTypeEnum.VOLUMES_QUANTITY:
822
+ if (value && (cte === null || cte === void 0 ? void 0 : cte.commodityVolumes)) {
823
+ var commodityVolumes = (_f = cte.commodityVolumes) !== null && _f !== void 0 ? _f : 0;
824
+ var total_8 = +commodityVolumes * +value;
825
+ var _s = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _s.adjustedTotal, redeliveryInfo_8 = _s.redeliveryInfo;
826
+ total_8 = adjustedTotal_8;
827
+ var resultCurrency_8 = (+total_8).toLocaleString('pt-br', {
828
+ style: 'currency',
829
+ currency: 'BRL',
830
+ });
831
+ var result_8 = "".concat(commodityVolumes, " ").concat(commodityVolumes === 1 ? 'volume' : 'volumes', " x ").concat(convertNumberToCurrency(+value, 'pt-br')).concat(redeliveryInfo_8, " = ").concat(resultCurrency_8);
832
+ totalFee = total_8;
833
+ resultFee = result_8;
834
+ }
835
+ break;
820
836
  /*if (ratecardLaneFee.minWeight && cte?.taxedWeight) {
821
837
 
822
838
  if (+ratecardLaneFee.minWeight <= +cte.taxedWeight) {
@@ -919,7 +935,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
919
935
  return 0;
920
936
  });
921
937
  if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
922
- if (((_f = siblingFeesResults[0]) === null || _f === void 0 ? void 0 : _f.totalFee) && ((_g = siblingFeesResults[0]) === null || _g === void 0 ? void 0 : _g.totalFee) > totalFee) {
938
+ if (((_g = siblingFeesResults[0]) === null || _g === void 0 ? void 0 : _g.totalFee) && ((_h = siblingFeesResults[0]) === null || _h === void 0 ? void 0 : _h.totalFee) > totalFee) {
923
939
  totalToCalc = 0;
924
940
  }
925
941
  }
Binary file