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/enums/FeeCalculationTypeEnum.d.ts +2 -1
- package/build/index.esm.js +27 -11
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +27 -11
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.esm.js
CHANGED
|
@@ -145,6 +145,7 @@ var FeeCalculationTypeEnum;
|
|
|
145
145
|
FeeCalculationTypeEnum[FeeCalculationTypeEnum["MIN_VALUE"] = 10] = "MIN_VALUE";
|
|
146
146
|
FeeCalculationTypeEnum[FeeCalculationTypeEnum["SUM_CONTAINERS"] = 11] = "SUM_CONTAINERS";
|
|
147
147
|
FeeCalculationTypeEnum[FeeCalculationTypeEnum["VOLUMES_QUANTITY"] = 12] = "VOLUMES_QUANTITY";
|
|
148
|
+
FeeCalculationTypeEnum[FeeCalculationTypeEnum["INVOICE_QUANTITY"] = 13] = "INVOICE_QUANTITY";
|
|
148
149
|
})(FeeCalculationTypeEnum || (FeeCalculationTypeEnum = {}));
|
|
149
150
|
|
|
150
151
|
var FeeCategoryEnum;
|
|
@@ -530,7 +531,7 @@ var filterSiblingFees = function (fees) {
|
|
|
530
531
|
};
|
|
531
532
|
|
|
532
533
|
var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCalc) {
|
|
533
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
534
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
534
535
|
if (debug === void 0) { debug = false; }
|
|
535
536
|
if (ratecardLaneFee.fee) {
|
|
536
537
|
// Buscar o ratecard correto do CTE usando getRatecardFromCte
|
|
@@ -614,7 +615,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
614
615
|
if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
|
|
615
616
|
var valueToMultiply = (+value / 100);
|
|
616
617
|
var total_1 = +totalValueFromAllFees * valueToMultiply;
|
|
617
|
-
var
|
|
618
|
+
var _l = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _l.adjustedTotal, redeliveryInfo_1 = _l.redeliveryInfo;
|
|
618
619
|
total_1 = adjustedTotal_1;
|
|
619
620
|
var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
|
|
620
621
|
var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
|
|
@@ -637,7 +638,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
637
638
|
var shouldApplyFraction = +cte.taxedWeight > minWeightForFraction;
|
|
638
639
|
var fractions = shouldApplyFraction ? Math.ceil(+cte.taxedWeight / 100) : 1;
|
|
639
640
|
var total_2 = fractions * value;
|
|
640
|
-
var
|
|
641
|
+
var _m = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _m.adjustedTotal, redeliveryInfo_2 = _m.redeliveryInfo;
|
|
641
642
|
total_2 = adjustedTotal_2;
|
|
642
643
|
var valueCurrency_1 = (+value).toLocaleString('pt-br', {
|
|
643
644
|
style: 'currency',
|
|
@@ -658,7 +659,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
658
659
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.freightValue)) {
|
|
659
660
|
if (!isNaN(+value) && !isNaN(+cte.freightValue)) {
|
|
660
661
|
var total_3 = +cte.freightValue * (+value / 100);
|
|
661
|
-
var
|
|
662
|
+
var _o = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _o.adjustedTotal, redeliveryInfo_3 = _o.redeliveryInfo;
|
|
662
663
|
total_3 = adjustedTotal_3;
|
|
663
664
|
var freightValueCurrency = (+cte.freightValue).toLocaleString('pt-br', {
|
|
664
665
|
style: 'currency',
|
|
@@ -693,7 +694,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
693
694
|
case FeeCalculationTypeEnum.MIN_VALUE:
|
|
694
695
|
case FeeCalculationTypeEnum.FIXED:
|
|
695
696
|
var total = +value;
|
|
696
|
-
var
|
|
697
|
+
var _p = applyRedeliveryMultiplier(total, cte), adjustedTotal = _p.adjustedTotal, redeliveryInfo = _p.redeliveryInfo;
|
|
697
698
|
total = adjustedTotal;
|
|
698
699
|
var valueCurrency = (+value).toLocaleString('pt-br', {
|
|
699
700
|
style: 'currency',
|
|
@@ -745,7 +746,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
745
746
|
// Somar ao total
|
|
746
747
|
total_4 += additionalValue;
|
|
747
748
|
// Aplicar multiplicador de redelivery ao valor final
|
|
748
|
-
var
|
|
749
|
+
var _q = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _q.adjustedTotal, redeliveryInfo_4 = _q.redeliveryInfo;
|
|
749
750
|
total_4 = adjustedTotal_4;
|
|
750
751
|
var valueCurrency_2 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
751
752
|
style: 'currency',
|
|
@@ -787,7 +788,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
787
788
|
// Somar ao total
|
|
788
789
|
total_5 += additionalValue;
|
|
789
790
|
// Aplicar multiplicador de redelivery ao valor final
|
|
790
|
-
var
|
|
791
|
+
var _r = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _r.adjustedTotal, redeliveryInfo_5 = _r.redeliveryInfo;
|
|
791
792
|
total_5 = adjustedTotal_5;
|
|
792
793
|
var valueCurrency_3 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
793
794
|
style: 'currency',
|
|
@@ -807,7 +808,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
807
808
|
if (value) {
|
|
808
809
|
var commodityValue = (_d = cte === null || cte === void 0 ? void 0 : cte.commodityValue) !== null && _d !== void 0 ? _d : 0;
|
|
809
810
|
var total_6 = +commodityValue * (+value / 100);
|
|
810
|
-
var
|
|
811
|
+
var _s = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _s.adjustedTotal, redeliveryInfo_6 = _s.redeliveryInfo;
|
|
811
812
|
total_6 = adjustedTotal_6;
|
|
812
813
|
var resultCurrency_6 = (+total_6).toLocaleString('pt-br', {
|
|
813
814
|
style: 'currency',
|
|
@@ -822,7 +823,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
822
823
|
if (value) {
|
|
823
824
|
var taxedWeight = (_e = cte === null || cte === void 0 ? void 0 : cte.taxedWeight) !== null && _e !== void 0 ? _e : 0;
|
|
824
825
|
var total_7 = +taxedWeight * +value;
|
|
825
|
-
var
|
|
826
|
+
var _t = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _t.adjustedTotal, redeliveryInfo_7 = _t.redeliveryInfo;
|
|
826
827
|
total_7 = adjustedTotal_7;
|
|
827
828
|
var resultCurrency_7 = (+total_7).toLocaleString('pt-br', {
|
|
828
829
|
style: 'currency',
|
|
@@ -839,7 +840,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
839
840
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.commodityVolumes)) {
|
|
840
841
|
var commodityVolumes = (_f = cte.commodityVolumes) !== null && _f !== void 0 ? _f : 0;
|
|
841
842
|
var total_8 = +commodityVolumes * +value;
|
|
842
|
-
var
|
|
843
|
+
var _u = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _u.adjustedTotal, redeliveryInfo_8 = _u.redeliveryInfo;
|
|
843
844
|
total_8 = adjustedTotal_8;
|
|
844
845
|
var resultCurrency_8 = (+total_8).toLocaleString('pt-br', {
|
|
845
846
|
style: 'currency',
|
|
@@ -850,6 +851,21 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
850
851
|
resultFee = result_8;
|
|
851
852
|
}
|
|
852
853
|
break;
|
|
854
|
+
case FeeCalculationTypeEnum.INVOICE_QUANTITY:
|
|
855
|
+
if (value && (cte === null || cte === void 0 ? void 0 : cte.cte_invoices)) {
|
|
856
|
+
var invoiceCount = (_h = (_g = cte.cte_invoices) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0;
|
|
857
|
+
var total_9 = +invoiceCount * +value;
|
|
858
|
+
var _v = applyRedeliveryMultiplier(total_9, cte), adjustedTotal_9 = _v.adjustedTotal, redeliveryInfo_9 = _v.redeliveryInfo;
|
|
859
|
+
total_9 = adjustedTotal_9;
|
|
860
|
+
var resultCurrency_9 = (+total_9).toLocaleString('pt-br', {
|
|
861
|
+
style: 'currency',
|
|
862
|
+
currency: 'BRL',
|
|
863
|
+
});
|
|
864
|
+
var result_9 = "".concat(invoiceCount, " ").concat(invoiceCount === 1 ? 'nota fiscal' : 'notas fiscais', " x ").concat(convertNumberToCurrency(+value, 'pt-br')).concat(redeliveryInfo_9, " = ").concat(resultCurrency_9);
|
|
865
|
+
totalFee = total_9;
|
|
866
|
+
resultFee = result_9;
|
|
867
|
+
}
|
|
868
|
+
break;
|
|
853
869
|
/*if (ratecardLaneFee.minWeight && cte?.taxedWeight) {
|
|
854
870
|
|
|
855
871
|
if (+ratecardLaneFee.minWeight <= +cte.taxedWeight) {
|
|
@@ -952,7 +968,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
952
968
|
return 0;
|
|
953
969
|
});
|
|
954
970
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
955
|
-
if (((
|
|
971
|
+
if (((_j = siblingFeesResults[0]) === null || _j === void 0 ? void 0 : _j.totalFee) && ((_k = siblingFeesResults[0]) === null || _k === void 0 ? void 0 : _k.totalFee) > totalFee) {
|
|
956
972
|
totalToCalc = 0;
|
|
957
973
|
}
|
|
958
974
|
}
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|