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/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;
|
|
@@ -186,6 +187,7 @@ exports.FeeEnum = void 0;
|
|
|
186
187
|
FeeEnum[FeeEnum["COLLECT"] = 151] = "COLLECT";
|
|
187
188
|
FeeEnum[FeeEnum["COLLECT_PERCENTAGE_TOTAL"] = 152] = "COLLECT_PERCENTAGE_TOTAL";
|
|
188
189
|
FeeEnum[FeeEnum["COLLECT_REVERSE_PERCENTAGE_TOTAL"] = 153] = "COLLECT_REVERSE_PERCENTAGE_TOTAL";
|
|
190
|
+
FeeEnum[FeeEnum["APPOINTMENT_MIN_VALUE"] = 167] = "APPOINTMENT_MIN_VALUE";
|
|
189
191
|
FeeEnum[FeeEnum["TRT_PERCENTAGE_TOTAL"] = 169] = "TRT_PERCENTAGE_TOTAL";
|
|
190
192
|
FeeEnum[FeeEnum["TDA_PERCENTAGE_TOTAL"] = 170] = "TDA_PERCENTAGE_TOTAL";
|
|
191
193
|
FeeEnum[FeeEnum["TDE_PERCENTAGE_TOTAL"] = 171] = "TDE_PERCENTAGE_TOTAL";
|
|
@@ -533,7 +535,7 @@ var filterSiblingFees = function (fees) {
|
|
|
533
535
|
};
|
|
534
536
|
|
|
535
537
|
var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCalc) {
|
|
536
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
538
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
537
539
|
if (debug === void 0) { debug = false; }
|
|
538
540
|
if (ratecardLaneFee.fee) {
|
|
539
541
|
// Buscar o ratecard correto do CTE usando getRatecardFromCte
|
|
@@ -617,7 +619,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
617
619
|
if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
|
|
618
620
|
var valueToMultiply = (+value / 100);
|
|
619
621
|
var total_1 = +totalValueFromAllFees * valueToMultiply;
|
|
620
|
-
var
|
|
622
|
+
var _l = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _l.adjustedTotal, redeliveryInfo_1 = _l.redeliveryInfo;
|
|
621
623
|
total_1 = adjustedTotal_1;
|
|
622
624
|
var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
|
|
623
625
|
var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
|
|
@@ -640,7 +642,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
640
642
|
var shouldApplyFraction = +cte.taxedWeight > minWeightForFraction;
|
|
641
643
|
var fractions = shouldApplyFraction ? Math.ceil(+cte.taxedWeight / 100) : 1;
|
|
642
644
|
var total_2 = fractions * value;
|
|
643
|
-
var
|
|
645
|
+
var _m = applyRedeliveryMultiplier(total_2, cte), adjustedTotal_2 = _m.adjustedTotal, redeliveryInfo_2 = _m.redeliveryInfo;
|
|
644
646
|
total_2 = adjustedTotal_2;
|
|
645
647
|
var valueCurrency_1 = (+value).toLocaleString('pt-br', {
|
|
646
648
|
style: 'currency',
|
|
@@ -661,7 +663,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
661
663
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.freightValue)) {
|
|
662
664
|
if (!isNaN(+value) && !isNaN(+cte.freightValue)) {
|
|
663
665
|
var total_3 = +cte.freightValue * (+value / 100);
|
|
664
|
-
var
|
|
666
|
+
var _o = applyRedeliveryMultiplier(total_3, cte), adjustedTotal_3 = _o.adjustedTotal, redeliveryInfo_3 = _o.redeliveryInfo;
|
|
665
667
|
total_3 = adjustedTotal_3;
|
|
666
668
|
var freightValueCurrency = (+cte.freightValue).toLocaleString('pt-br', {
|
|
667
669
|
style: 'currency',
|
|
@@ -696,7 +698,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
696
698
|
case exports.FeeCalculationTypeEnum.MIN_VALUE:
|
|
697
699
|
case exports.FeeCalculationTypeEnum.FIXED:
|
|
698
700
|
var total = +value;
|
|
699
|
-
var
|
|
701
|
+
var _p = applyRedeliveryMultiplier(total, cte), adjustedTotal = _p.adjustedTotal, redeliveryInfo = _p.redeliveryInfo;
|
|
700
702
|
total = adjustedTotal;
|
|
701
703
|
var valueCurrency = (+value).toLocaleString('pt-br', {
|
|
702
704
|
style: 'currency',
|
|
@@ -748,7 +750,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
748
750
|
// Somar ao total
|
|
749
751
|
total_4 += additionalValue;
|
|
750
752
|
// Aplicar multiplicador de redelivery ao valor final
|
|
751
|
-
var
|
|
753
|
+
var _q = applyRedeliveryMultiplier(total_4, cte), adjustedTotal_4 = _q.adjustedTotal, redeliveryInfo_4 = _q.redeliveryInfo;
|
|
752
754
|
total_4 = adjustedTotal_4;
|
|
753
755
|
var valueCurrency_2 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
754
756
|
style: 'currency',
|
|
@@ -790,7 +792,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
790
792
|
// Somar ao total
|
|
791
793
|
total_5 += additionalValue;
|
|
792
794
|
// Aplicar multiplicador de redelivery ao valor final
|
|
793
|
-
var
|
|
795
|
+
var _r = applyRedeliveryMultiplier(total_5, cte), adjustedTotal_5 = _r.adjustedTotal, redeliveryInfo_5 = _r.redeliveryInfo;
|
|
794
796
|
total_5 = adjustedTotal_5;
|
|
795
797
|
var valueCurrency_3 = (+highestIntervalFee.value).toLocaleString('pt-br', {
|
|
796
798
|
style: 'currency',
|
|
@@ -810,7 +812,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
810
812
|
if (value) {
|
|
811
813
|
var commodityValue = (_d = cte === null || cte === void 0 ? void 0 : cte.commodityValue) !== null && _d !== void 0 ? _d : 0;
|
|
812
814
|
var total_6 = +commodityValue * (+value / 100);
|
|
813
|
-
var
|
|
815
|
+
var _s = applyRedeliveryMultiplier(total_6, cte), adjustedTotal_6 = _s.adjustedTotal, redeliveryInfo_6 = _s.redeliveryInfo;
|
|
814
816
|
total_6 = adjustedTotal_6;
|
|
815
817
|
var resultCurrency_6 = (+total_6).toLocaleString('pt-br', {
|
|
816
818
|
style: 'currency',
|
|
@@ -825,7 +827,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
825
827
|
if (value) {
|
|
826
828
|
var taxedWeight = (_e = cte === null || cte === void 0 ? void 0 : cte.taxedWeight) !== null && _e !== void 0 ? _e : 0;
|
|
827
829
|
var total_7 = +taxedWeight * +value;
|
|
828
|
-
var
|
|
830
|
+
var _t = applyRedeliveryMultiplier(total_7, cte), adjustedTotal_7 = _t.adjustedTotal, redeliveryInfo_7 = _t.redeliveryInfo;
|
|
829
831
|
total_7 = adjustedTotal_7;
|
|
830
832
|
var resultCurrency_7 = (+total_7).toLocaleString('pt-br', {
|
|
831
833
|
style: 'currency',
|
|
@@ -842,7 +844,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
842
844
|
if (value && (cte === null || cte === void 0 ? void 0 : cte.commodityVolumes)) {
|
|
843
845
|
var commodityVolumes = (_f = cte.commodityVolumes) !== null && _f !== void 0 ? _f : 0;
|
|
844
846
|
var total_8 = +commodityVolumes * +value;
|
|
845
|
-
var
|
|
847
|
+
var _u = applyRedeliveryMultiplier(total_8, cte), adjustedTotal_8 = _u.adjustedTotal, redeliveryInfo_8 = _u.redeliveryInfo;
|
|
846
848
|
total_8 = adjustedTotal_8;
|
|
847
849
|
var resultCurrency_8 = (+total_8).toLocaleString('pt-br', {
|
|
848
850
|
style: 'currency',
|
|
@@ -853,6 +855,21 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
853
855
|
resultFee = result_8;
|
|
854
856
|
}
|
|
855
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;
|
|
856
873
|
/*if (ratecardLaneFee.minWeight && cte?.taxedWeight) {
|
|
857
874
|
|
|
858
875
|
if (+ratecardLaneFee.minWeight <= +cte.taxedWeight) {
|
|
@@ -955,7 +972,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
|
|
|
955
972
|
return 0;
|
|
956
973
|
});
|
|
957
974
|
if ((siblingFeesResults === null || siblingFeesResults === void 0 ? void 0 : siblingFeesResults.length) > 0) {
|
|
958
|
-
if (((
|
|
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) {
|
|
959
976
|
totalToCalc = 0;
|
|
960
977
|
}
|
|
961
978
|
}
|
|
@@ -1252,16 +1269,19 @@ var getFilteredFeesToAudit = function (_a) {
|
|
|
1252
1269
|
exports.FeeEnum.SCHEDULING_TAX,
|
|
1253
1270
|
94,
|
|
1254
1271
|
];
|
|
1255
|
-
var
|
|
1272
|
+
var collectAndAppointmentFees = [
|
|
1256
1273
|
exports.FeeEnum.COLLECT_PERCENTAGE_TOTAL,
|
|
1257
1274
|
exports.FeeEnum.COLLECT_REVERSE_PERCENTAGE_TOTAL,
|
|
1275
|
+
exports.FeeEnum.APPOINTMENT_MIN_VALUE,
|
|
1258
1276
|
];
|
|
1259
|
-
if (
|
|
1277
|
+
if (collectAndAppointmentFees.includes((_a = i.fee) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1260
1278
|
switch ((_b = i.fee) === null || _b === void 0 ? void 0 : _b.id) {
|
|
1261
1279
|
case exports.FeeEnum.COLLECT_PERCENTAGE_TOTAL:
|
|
1262
1280
|
return cte.isCollect;
|
|
1263
1281
|
case exports.FeeEnum.COLLECT_REVERSE_PERCENTAGE_TOTAL:
|
|
1264
1282
|
return cte.isCollectReverse;
|
|
1283
|
+
case exports.FeeEnum.APPOINTMENT_MIN_VALUE:
|
|
1284
|
+
return cte.isAppointment;
|
|
1265
1285
|
}
|
|
1266
1286
|
}
|
|
1267
1287
|
var conditionalFeeToVerify;
|
package/build/index.js.gz
CHANGED
|
Binary file
|