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.
- package/build/enums/FeeCalculationTypeEnum.d.ts +2 -1
- package/build/index.esm.js +26 -10
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +26 -10
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -148,6 +148,7 @@ exports.FeeCalculationTypeEnum = void 0;
|
|
|
148
148
|
FeeCalculationTypeEnum[FeeCalculationTypeEnum["TOTAL_PERCENTAGE"] = 9] = "TOTAL_PERCENTAGE";
|
|
149
149
|
FeeCalculationTypeEnum[FeeCalculationTypeEnum["MIN_VALUE"] = 10] = "MIN_VALUE";
|
|
150
150
|
FeeCalculationTypeEnum[FeeCalculationTypeEnum["SUM_CONTAINERS"] = 11] = "SUM_CONTAINERS";
|
|
151
|
+
FeeCalculationTypeEnum[FeeCalculationTypeEnum["VOLUMES_QUANTITY"] = 12] = "VOLUMES_QUANTITY";
|
|
151
152
|
})(exports.FeeCalculationTypeEnum || (exports.FeeCalculationTypeEnum = {}));
|
|
152
153
|
|
|
153
154
|
exports.FeeCategoryEnum = void 0;
|
|
@@ -524,7 +525,7 @@ var filterSiblingFees = function (fees) {
|
|
|
524
525
|
};
|
|
525
526
|
|
|
526
527
|
var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCalc) {
|
|
527
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
528
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
528
529
|
if (debug === void 0) { debug = false; }
|
|
529
530
|
if (ratecardLaneFee.fee) {
|
|
530
531
|
// Buscar o ratecard correto do CTE usando getRatecardFromCte
|
|
@@ -600,7 +601,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
600
601
|
if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
|
|
601
602
|
var valueToMultiply = (+value / 100);
|
|
602
603
|
var total_1 = +totalValueFromAllFees * valueToMultiply;
|
|
603
|
-
var
|
|
604
|
+
var _j = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _j.adjustedTotal, redeliveryInfo_1 = _j.redeliveryInfo;
|
|
604
605
|
total_1 = adjustedTotal_1;
|
|
605
606
|
var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
|
|
606
607
|
var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
|
|
@@ -623,7 +624,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
623
624
|
var shouldApplyFraction = +cte.taxedWeight > minWeightForFraction;
|
|
624
625
|
var fractions = shouldApplyFraction ? Math.ceil(+cte.taxedWeight / 100) : 1;
|
|
625
626
|
var total_2 = fractions * value;
|
|
626
|
-
var
|
|
627
|
+
var _k = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _k.adjustedTotal, redeliveryInfo_2 = _k.redeliveryInfo;
|
|
627
628
|
total_2 = adjustedTotal_2;
|
|
628
629
|
var valueCurrency_1 = (+value).toLocaleString('pt-br', {
|
|
629
630
|
style: 'currency',
|
|
@@ -644,7 +645,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
644
645
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.freightValue)) {
|
|
645
646
|
if (!isNaN(+value) && !isNaN(+cte.freightValue)) {
|
|
646
647
|
var total_3 = +cte.freightValue * (+value / 100);
|
|
647
|
-
var
|
|
648
|
+
var _l = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _l.adjustedTotal, redeliveryInfo_3 = _l.redeliveryInfo;
|
|
648
649
|
total_3 = adjustedTotal_3;
|
|
649
650
|
var freightValueCurrency = (+cte.freightValue).toLocaleString('pt-br', {
|
|
650
651
|
style: 'currency',
|
|
@@ -679,7 +680,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
679
680
|
case exports.FeeCalculationTypeEnum.MIN_VALUE:
|
|
680
681
|
case exports.FeeCalculationTypeEnum.FIXED:
|
|
681
682
|
var total = +value;
|
|
682
|
-
var
|
|
683
|
+
var _m = applyRedeliveryMultiplier(total, cte), adjustedTotal = _m.adjustedTotal, redeliveryInfo = _m.redeliveryInfo;
|
|
683
684
|
total = adjustedTotal;
|
|
684
685
|
var valueCurrency = (+value).toLocaleString('pt-br', {
|
|
685
686
|
style: 'currency',
|
|
@@ -731,7 +732,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
731
732
|
// Somar ao total
|
|
732
733
|
total_4 += additionalValue;
|
|
733
734
|
// Aplicar multiplicador de redelivery ao valor final
|
|
734
|
-
var
|
|
735
|
+
var _o = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _o.adjustedTotal, redeliveryInfo_4 = _o.redeliveryInfo;
|
|
735
736
|
total_4 = adjustedTotal_4;
|
|
736
737
|
var valueCurrency_2 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
737
738
|
style: 'currency',
|
|
@@ -773,7 +774,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
773
774
|
// Somar ao total
|
|
774
775
|
total_5 += additionalValue;
|
|
775
776
|
// Aplicar multiplicador de redelivery ao valor final
|
|
776
|
-
var
|
|
777
|
+
var _p = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _p.adjustedTotal, redeliveryInfo_5 = _p.redeliveryInfo;
|
|
777
778
|
total_5 = adjustedTotal_5;
|
|
778
779
|
var valueCurrency_3 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
779
780
|
style: 'currency',
|
|
@@ -793,7 +794,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
793
794
|
if (value) {
|
|
794
795
|
var commodityValue = (_d = cte === null || cte === void 0 ? void 0 : cte.commodityValue) !== null && _d !== void 0 ? _d : 0;
|
|
795
796
|
var total_6 = +commodityValue * (+value / 100);
|
|
796
|
-
var
|
|
797
|
+
var _q = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _q.adjustedTotal, redeliveryInfo_6 = _q.redeliveryInfo;
|
|
797
798
|
total_6 = adjustedTotal_6;
|
|
798
799
|
var resultCurrency_6 = (+total_6).toLocaleString('pt-br', {
|
|
799
800
|
style: 'currency',
|
|
@@ -808,7 +809,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
808
809
|
if (value) {
|
|
809
810
|
var taxedWeight = (_e = cte === null || cte === void 0 ? void 0 : cte.taxedWeight) !== null && _e !== void 0 ? _e : 0;
|
|
810
811
|
var total_7 = +taxedWeight * +value;
|
|
811
|
-
var
|
|
812
|
+
var _r = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _r.adjustedTotal, redeliveryInfo_7 = _r.redeliveryInfo;
|
|
812
813
|
total_7 = adjustedTotal_7;
|
|
813
814
|
var resultCurrency_7 = (+total_7).toLocaleString('pt-br', {
|
|
814
815
|
style: 'currency',
|
|
@@ -821,6 +822,21 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
821
822
|
resultFee = result_7;
|
|
822
823
|
}
|
|
823
824
|
break;
|
|
825
|
+
case exports.FeeCalculationTypeEnum.VOLUMES_QUANTITY:
|
|
826
|
+
if (value && (cte === null || cte === void 0 ? void 0 : cte.commodityVolumes)) {
|
|
827
|
+
var commodityVolumes = (_f = cte.commodityVolumes) !== null && _f !== void 0 ? _f : 0;
|
|
828
|
+
var total_8 = +commodityVolumes * +value;
|
|
829
|
+
var _s = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _s.adjustedTotal, redeliveryInfo_8 = _s.redeliveryInfo;
|
|
830
|
+
total_8 = adjustedTotal_8;
|
|
831
|
+
var resultCurrency_8 = (+total_8).toLocaleString('pt-br', {
|
|
832
|
+
style: 'currency',
|
|
833
|
+
currency: 'BRL',
|
|
834
|
+
});
|
|
835
|
+
var result_8 = "".concat(commodityVolumes, " ").concat(commodityVolumes === 1 ? 'volume' : 'volumes', " x ").concat(convertNumberToCurrency(+value, 'pt-br')).concat(redeliveryInfo_8, " = ").concat(resultCurrency_8);
|
|
836
|
+
totalFee = total_8;
|
|
837
|
+
resultFee = result_8;
|
|
838
|
+
}
|
|
839
|
+
break;
|
|
824
840
|
/*if (ratecardLaneFee.minWeight && cte?.taxedWeight) {
|
|
825
841
|
|
|
826
842
|
if (+ratecardLaneFee.minWeight <= +cte.taxedWeight) {
|
|
@@ -923,7 +939,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
923
939
|
return 0;
|
|
924
940
|
});
|
|
925
941
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
926
|
-
if (((
|
|
942
|
+
if (((_g = siblingFeesResults[0]) === null || _g === void 0 ? void 0 : _g.totalFee) && ((_h = siblingFeesResults[0]) === null || _h === void 0 ? void 0 : _h.totalFee) > totalFee) {
|
|
927
943
|
totalToCalc = 0;
|
|
928
944
|
}
|
|
929
945
|
}
|
package/build/index.js.gz
CHANGED
|
Binary file
|