b2m-utils 0.0.308 → 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/enums/FeeEnum.d.ts +1 -0
- package/build/index.esm.js +33 -13
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +33 -13
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/enums/FeeEnum.d.ts
CHANGED
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;
|
|
@@ -182,6 +183,7 @@ var FeeEnum;
|
|
|
182
183
|
FeeEnum[FeeEnum["COLLECT"] = 151] = "COLLECT";
|
|
183
184
|
FeeEnum[FeeEnum["COLLECT_PERCENTAGE_TOTAL"] = 152] = "COLLECT_PERCENTAGE_TOTAL";
|
|
184
185
|
FeeEnum[FeeEnum["COLLECT_REVERSE_PERCENTAGE_TOTAL"] = 153] = "COLLECT_REVERSE_PERCENTAGE_TOTAL";
|
|
186
|
+
FeeEnum[FeeEnum["APPOINTMENT_MIN_VALUE"] = 167] = "APPOINTMENT_MIN_VALUE";
|
|
185
187
|
FeeEnum[FeeEnum["TRT_PERCENTAGE_TOTAL"] = 169] = "TRT_PERCENTAGE_TOTAL";
|
|
186
188
|
FeeEnum[FeeEnum["TDA_PERCENTAGE_TOTAL"] = 170] = "TDA_PERCENTAGE_TOTAL";
|
|
187
189
|
FeeEnum[FeeEnum["TDE_PERCENTAGE_TOTAL"] = 171] = "TDE_PERCENTAGE_TOTAL";
|
|
@@ -529,7 +531,7 @@ var filterSiblingFees = function (fees) {
|
|
|
529
531
|
};
|
|
530
532
|
|
|
531
533
|
var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCalc) {
|
|
532
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
534
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
533
535
|
if (debug === void 0) { debug = false; }
|
|
534
536
|
if (ratecardLaneFee.fee) {
|
|
535
537
|
// Buscar o ratecard correto do CTE usando getRatecardFromCte
|
|
@@ -613,7 +615,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
613
615
|
if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
|
|
614
616
|
var valueToMultiply = (+value / 100);
|
|
615
617
|
var total_1 = +totalValueFromAllFees * valueToMultiply;
|
|
616
|
-
var
|
|
618
|
+
var _l = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _l.adjustedTotal, redeliveryInfo_1 = _l.redeliveryInfo;
|
|
617
619
|
total_1 = adjustedTotal_1;
|
|
618
620
|
var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
|
|
619
621
|
var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
|
|
@@ -636,7 +638,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
636
638
|
var shouldApplyFraction = +cte.taxedWeight > minWeightForFraction;
|
|
637
639
|
var fractions = shouldApplyFraction ? Math.ceil(+cte.taxedWeight / 100) : 1;
|
|
638
640
|
var total_2 = fractions * value;
|
|
639
|
-
var
|
|
641
|
+
var _m = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _m.adjustedTotal, redeliveryInfo_2 = _m.redeliveryInfo;
|
|
640
642
|
total_2 = adjustedTotal_2;
|
|
641
643
|
var valueCurrency_1 = (+value).toLocaleString('pt-br', {
|
|
642
644
|
style: 'currency',
|
|
@@ -657,7 +659,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
657
659
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.freightValue)) {
|
|
658
660
|
if (!isNaN(+value) && !isNaN(+cte.freightValue)) {
|
|
659
661
|
var total_3 = +cte.freightValue * (+value / 100);
|
|
660
|
-
var
|
|
662
|
+
var _o = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _o.adjustedTotal, redeliveryInfo_3 = _o.redeliveryInfo;
|
|
661
663
|
total_3 = adjustedTotal_3;
|
|
662
664
|
var freightValueCurrency = (+cte.freightValue).toLocaleString('pt-br', {
|
|
663
665
|
style: 'currency',
|
|
@@ -692,7 +694,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
692
694
|
case FeeCalculationTypeEnum.MIN_VALUE:
|
|
693
695
|
case FeeCalculationTypeEnum.FIXED:
|
|
694
696
|
var total = +value;
|
|
695
|
-
var
|
|
697
|
+
var _p = applyRedeliveryMultiplier(total, cte), adjustedTotal = _p.adjustedTotal, redeliveryInfo = _p.redeliveryInfo;
|
|
696
698
|
total = adjustedTotal;
|
|
697
699
|
var valueCurrency = (+value).toLocaleString('pt-br', {
|
|
698
700
|
style: 'currency',
|
|
@@ -744,7 +746,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
744
746
|
// Somar ao total
|
|
745
747
|
total_4 += additionalValue;
|
|
746
748
|
// Aplicar multiplicador de redelivery ao valor final
|
|
747
|
-
var
|
|
749
|
+
var _q = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _q.adjustedTotal, redeliveryInfo_4 = _q.redeliveryInfo;
|
|
748
750
|
total_4 = adjustedTotal_4;
|
|
749
751
|
var valueCurrency_2 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
750
752
|
style: 'currency',
|
|
@@ -786,7 +788,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
786
788
|
// Somar ao total
|
|
787
789
|
total_5 += additionalValue;
|
|
788
790
|
// Aplicar multiplicador de redelivery ao valor final
|
|
789
|
-
var
|
|
791
|
+
var _r = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _r.adjustedTotal, redeliveryInfo_5 = _r.redeliveryInfo;
|
|
790
792
|
total_5 = adjustedTotal_5;
|
|
791
793
|
var valueCurrency_3 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
792
794
|
style: 'currency',
|
|
@@ -806,7 +808,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
806
808
|
if (value) {
|
|
807
809
|
var commodityValue = (_d = cte === null || cte === void 0 ? void 0 : cte.commodityValue) !== null && _d !== void 0 ? _d : 0;
|
|
808
810
|
var total_6 = +commodityValue * (+value / 100);
|
|
809
|
-
var
|
|
811
|
+
var _s = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _s.adjustedTotal, redeliveryInfo_6 = _s.redeliveryInfo;
|
|
810
812
|
total_6 = adjustedTotal_6;
|
|
811
813
|
var resultCurrency_6 = (+total_6).toLocaleString('pt-br', {
|
|
812
814
|
style: 'currency',
|
|
@@ -821,7 +823,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
821
823
|
if (value) {
|
|
822
824
|
var taxedWeight = (_e = cte === null || cte === void 0 ? void 0 : cte.taxedWeight) !== null && _e !== void 0 ? _e : 0;
|
|
823
825
|
var total_7 = +taxedWeight * +value;
|
|
824
|
-
var
|
|
826
|
+
var _t = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _t.adjustedTotal, redeliveryInfo_7 = _t.redeliveryInfo;
|
|
825
827
|
total_7 = adjustedTotal_7;
|
|
826
828
|
var resultCurrency_7 = (+total_7).toLocaleString('pt-br', {
|
|
827
829
|
style: 'currency',
|
|
@@ -838,7 +840,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
838
840
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.commodityVolumes)) {
|
|
839
841
|
var commodityVolumes = (_f = cte.commodityVolumes) !== null && _f !== void 0 ? _f : 0;
|
|
840
842
|
var total_8 = +commodityVolumes * +value;
|
|
841
|
-
var
|
|
843
|
+
var _u = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _u.adjustedTotal, redeliveryInfo_8 = _u.redeliveryInfo;
|
|
842
844
|
total_8 = adjustedTotal_8;
|
|
843
845
|
var resultCurrency_8 = (+total_8).toLocaleString('pt-br', {
|
|
844
846
|
style: 'currency',
|
|
@@ -849,6 +851,21 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
849
851
|
resultFee = result_8;
|
|
850
852
|
}
|
|
851
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;
|
|
852
869
|
/*if (ratecardLaneFee.minWeight && cte?.taxedWeight) {
|
|
853
870
|
|
|
854
871
|
if (+ratecardLaneFee.minWeight <= +cte.taxedWeight) {
|
|
@@ -951,7 +968,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
951
968
|
return 0;
|
|
952
969
|
});
|
|
953
970
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
954
|
-
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) {
|
|
955
972
|
totalToCalc = 0;
|
|
956
973
|
}
|
|
957
974
|
}
|
|
@@ -1248,16 +1265,19 @@ var getFilteredFeesToAudit = function (_a) {
|
|
|
1248
1265
|
FeeEnum.SCHEDULING_TAX,
|
|
1249
1266
|
94,
|
|
1250
1267
|
];
|
|
1251
|
-
var
|
|
1268
|
+
var collectAndAppointmentFees = [
|
|
1252
1269
|
FeeEnum.COLLECT_PERCENTAGE_TOTAL,
|
|
1253
1270
|
FeeEnum.COLLECT_REVERSE_PERCENTAGE_TOTAL,
|
|
1271
|
+
FeeEnum.APPOINTMENT_MIN_VALUE,
|
|
1254
1272
|
];
|
|
1255
|
-
if (
|
|
1273
|
+
if (collectAndAppointmentFees.includes((_a = i.fee) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1256
1274
|
switch ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) {
|
|
1257
1275
|
case FeeEnum.COLLECT_PERCENTAGE_TOTAL:
|
|
1258
1276
|
return cte.isCollect;
|
|
1259
1277
|
case FeeEnum.COLLECT_REVERSE_PERCENTAGE_TOTAL:
|
|
1260
1278
|
return cte.isCollectReverse;
|
|
1279
|
+
case FeeEnum.APPOINTMENT_MIN_VALUE:
|
|
1280
|
+
return cte.isAppointment;
|
|
1261
1281
|
}
|
|
1262
1282
|
}
|
|
1263
1283
|
var conditionalFeeToVerify;
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|