b2m-utils 0.0.309 → 0.0.310

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
@@ -149,6 +149,7 @@ exports.FeeCalculationTypeEnum = void 0;
149
149
  FeeCalculationTypeEnum[FeeCalculationTypeEnum["MIN_VALUE"] = 10] = "MIN_VALUE";
150
150
  FeeCalculationTypeEnum[FeeCalculationTypeEnum["SUM_CONTAINERS"] = 11] = "SUM_CONTAINERS";
151
151
  FeeCalculationTypeEnum[FeeCalculationTypeEnum["VOLUMES_QUANTITY"] = 12] = "VOLUMES_QUANTITY";
152
+ FeeCalculationTypeEnum[FeeCalculationTypeEnum["INVOICE_QUANTITY"] = 13] = "INVOICE_QUANTITY";
152
153
  })(exports.FeeCalculationTypeEnum || (exports.FeeCalculationTypeEnum = {}));
153
154
 
154
155
  exports.FeeCategoryEnum = void 0;
@@ -534,7 +535,7 @@ var filterSiblingFees = function (fees) {
534
535
  };
535
536
 
536
537
  var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCalc) {
537
- var _a, _b, _c, _d, _e, _f, _g, _h;
538
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
538
539
  if (debug === void 0) { debug = false; }
539
540
  if (ratecardLaneFee.fee) {
540
541
  // Buscar o ratecard correto do CTE usando getRatecardFromCte
@@ -618,7 +619,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
618
619
  if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
619
620
  var valueToMultiply = (+value / 100);
620
621
  var total_1 = +totalValueFromAllFees * valueToMultiply;
621
- var _j = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _j.adjustedTotal, redeliveryInfo_1 = _j.redeliveryInfo;
622
+ var _l = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _l.adjustedTotal, redeliveryInfo_1 = _l.redeliveryInfo;
622
623
  total_1 = adjustedTotal_1;
623
624
  var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
624
625
  var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
@@ -641,7 +642,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
641
642
  var shouldApplyFraction = +cte.taxedWeight > minWeightForFraction;
642
643
  var fractions = shouldApplyFraction ? Math.ceil(+cte.taxedWeight / 100) : 1;
643
644
  var total_2 = fractions * value;
644
- var _k = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _k.adjustedTotal, redeliveryInfo_2 = _k.redeliveryInfo;
645
+ var _m = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _m.adjustedTotal, redeliveryInfo_2 = _m.redeliveryInfo;
645
646
  total_2 = adjustedTotal_2;
646
647
  var valueCurrency_1 = (+value).toLocaleString('pt-br', {
647
648
  style: 'currency',
@@ -662,7 +663,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
662
663
  if (value && (cte === null || cte === void 0 ? void 0 : cte.freightValue)) {
663
664
  if (!isNaN(+value) && !isNaN(+cte.freightValue)) {
664
665
  var total_3 = +cte.freightValue * (+value / 100);
665
- var _l = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _l.adjustedTotal, redeliveryInfo_3 = _l.redeliveryInfo;
666
+ var _o = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _o.adjustedTotal, redeliveryInfo_3 = _o.redeliveryInfo;
666
667
  total_3 = adjustedTotal_3;
667
668
  var freightValueCurrency = (+cte.freightValue).toLocaleString('pt-br', {
668
669
  style: 'currency',
@@ -697,7 +698,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
697
698
  case exports.FeeCalculationTypeEnum.MIN_VALUE:
698
699
  case exports.FeeCalculationTypeEnum.FIXED:
699
700
  var total = +value;
700
- var _m = applyRedeliveryMultiplier(total, cte), adjustedTotal = _m.adjustedTotal, redeliveryInfo = _m.redeliveryInfo;
701
+ var _p = applyRedeliveryMultiplier(total, cte), adjustedTotal = _p.adjustedTotal, redeliveryInfo = _p.redeliveryInfo;
701
702
  total = adjustedTotal;
702
703
  var valueCurrency = (+value).toLocaleString('pt-br', {
703
704
  style: 'currency',
@@ -749,7 +750,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
749
750
  // Somar ao total
750
751
  total_4 += additionalValue;
751
752
  // Aplicar multiplicador de redelivery ao valor final
752
- var _o = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _o.adjustedTotal, redeliveryInfo_4 = _o.redeliveryInfo;
753
+ var _q = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _q.adjustedTotal, redeliveryInfo_4 = _q.redeliveryInfo;
753
754
  total_4 = adjustedTotal_4;
754
755
  var valueCurrency_2 = (+highestIntervalFee.value).toLocaleString('pt-br', {
755
756
  style: 'currency',
@@ -791,7 +792,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
791
792
  // Somar ao total
792
793
  total_5 += additionalValue;
793
794
  // Aplicar multiplicador de redelivery ao valor final
794
- var _p = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _p.adjustedTotal, redeliveryInfo_5 = _p.redeliveryInfo;
795
+ var _r = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _r.adjustedTotal, redeliveryInfo_5 = _r.redeliveryInfo;
795
796
  total_5 = adjustedTotal_5;
796
797
  var valueCurrency_3 = (+highestIntervalFee.value).toLocaleString('pt-br', {
797
798
  style: 'currency',
@@ -811,7 +812,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
811
812
  if (value) {
812
813
  var commodityValue = (_d = cte === null || cte === void 0 ? void 0 : cte.commodityValue) !== null && _d !== void 0 ? _d : 0;
813
814
  var total_6 = +commodityValue * (+value / 100);
814
- var _q = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _q.adjustedTotal, redeliveryInfo_6 = _q.redeliveryInfo;
815
+ var _s = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _s.adjustedTotal, redeliveryInfo_6 = _s.redeliveryInfo;
815
816
  total_6 = adjustedTotal_6;
816
817
  var resultCurrency_6 = (+total_6).toLocaleString('pt-br', {
817
818
  style: 'currency',
@@ -826,7 +827,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
826
827
  if (value) {
827
828
  var taxedWeight = (_e = cte === null || cte === void 0 ? void 0 : cte.taxedWeight) !== null && _e !== void 0 ? _e : 0;
828
829
  var total_7 = +taxedWeight * +value;
829
- var _r = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _r.adjustedTotal, redeliveryInfo_7 = _r.redeliveryInfo;
830
+ var _t = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _t.adjustedTotal, redeliveryInfo_7 = _t.redeliveryInfo;
830
831
  total_7 = adjustedTotal_7;
831
832
  var resultCurrency_7 = (+total_7).toLocaleString('pt-br', {
832
833
  style: 'currency',
@@ -843,7 +844,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
843
844
  if (value && (cte === null || cte === void 0 ? void 0 : cte.commodityVolumes)) {
844
845
  var commodityVolumes = (_f = cte.commodityVolumes) !== null && _f !== void 0 ? _f : 0;
845
846
  var total_8 = +commodityVolumes * +value;
846
- var _s = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _s.adjustedTotal, redeliveryInfo_8 = _s.redeliveryInfo;
847
+ var _u = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _u.adjustedTotal, redeliveryInfo_8 = _u.redeliveryInfo;
847
848
  total_8 = adjustedTotal_8;
848
849
  var resultCurrency_8 = (+total_8).toLocaleString('pt-br', {
849
850
  style: 'currency',
@@ -854,6 +855,21 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
854
855
  resultFee = result_8;
855
856
  }
856
857
  break;
858
+ case exports.FeeCalculationTypeEnum.INVOICE_QUANTITY:
859
+ if (value && (cte === null || cte === void 0 ? void 0 : cte.cte_invoices)) {
860
+ var invoiceCount = (_h = (_g = cte.cte_invoices) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0;
861
+ var total_9 = +invoiceCount * +value;
862
+ var _v = applyRedeliveryMultiplier(total_9, cte), adjustedTotal_9 = _v.adjustedTotal, redeliveryInfo_9 = _v.redeliveryInfo;
863
+ total_9 = adjustedTotal_9;
864
+ var resultCurrency_9 = (+total_9).toLocaleString('pt-br', {
865
+ style: 'currency',
866
+ currency: 'BRL',
867
+ });
868
+ var result_9 = "".concat(invoiceCount, " ").concat(invoiceCount === 1 ? 'nota fiscal' : 'notas fiscais', " x ").concat(convertNumberToCurrency(+value, 'pt-br')).concat(redeliveryInfo_9, " = ").concat(resultCurrency_9);
869
+ totalFee = total_9;
870
+ resultFee = result_9;
871
+ }
872
+ break;
857
873
  /*if (ratecardLaneFee.minWeight && cte?.taxedWeight) {
858
874
 
859
875
  if (+ratecardLaneFee.minWeight <= +cte.taxedWeight) {
@@ -956,7 +972,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
956
972
  return 0;
957
973
  });
958
974
  if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
959
- if (((_g = siblingFeesResults[0]) === null || _g === void 0 ? void 0 : _g.totalFee) && ((_h = siblingFeesResults[0]) === null || _h === void 0 ? void 0 : _h.totalFee) > totalFee) {
975
+ if (((_j = siblingFeesResults[0]) === null || _j === void 0 ? void 0 : _j.totalFee) && ((_k = siblingFeesResults[0]) === null || _k === void 0 ? void 0 : _k.totalFee) > totalFee) {
960
976
  totalToCalc = 0;
961
977
  }
962
978
  }
package/build/index.js.gz CHANGED
Binary file