b2m-utils 0.0.196 → 0.0.198

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
@@ -393,41 +393,14 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
393
393
  switch (fee_1.feeCalculationTypeId) {
394
394
  case exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE:
395
395
  if (allFees && Array.isArray(allFees) && (allFees === null || allFees === void 0 ? void 0 : allFees.length) > 0) {
396
- console.log('🔍 TOTAL_PERCENTAGE - Início:', {
397
- feeId: fee_1.id,
398
- feeName: fee_1.name,
399
- value: value,
400
- allFeesCount: allFees.length,
401
- cteId: cte.id
402
- });
403
396
  var filteredFees = allFees.filter(function (i) { var _a; return ((_a = i.fee) === null || _a === void 0 ? void 0 : _a.feeCalculationTypeId) !== exports.FeeCalculationTypeEnum.TOTAL_PERCENTAGE; });
404
- console.log('📋 TOTAL_PERCENTAGE - Taxas filtradas (sem TOTAL_PERCENTAGE):', {
405
- originalCount: allFees.length,
406
- filteredCount: filteredFees.length,
407
- filteredFeeIds: filteredFees.map(function (f) { var _a, _b, _c; return ({ id: (_a = f.fee) === null || _a === void 0 ? void 0 : _a.id, name: (_b = f.fee) === null || _b === void 0 ? void 0 : _b.name, type: (_c = f.fee) === null || _c === void 0 ? void 0 : _c.feeCalculationTypeId }); })
408
- });
409
397
  var totalFromAllFees = filteredFees.map(function (it) {
410
- var _a, _b, _c, _d;
411
- console.log('🔄 TOTAL_PERCENTAGE - Calculando taxa:', {
412
- feeId: (_a = it.fee) === null || _a === void 0 ? void 0 : _a.id,
413
- feeName: (_b = it.fee) === null || _b === void 0 ? void 0 : _b.name,
414
- calcType: (_c = it.fee) === null || _c === void 0 ? void 0 : _c.feeCalculationTypeId
415
- });
416
398
  var result = calculateFee(it, cte, allFees, debug, allFeesForCalc);
417
- console.log('✅ TOTAL_PERCENTAGE - Resultado da taxa:', {
418
- feeId: (_d = it.fee) === null || _d === void 0 ? void 0 : _d.id,
419
- totalToCalc: result === null || result === void 0 ? void 0 : result.totalToCalc,
420
- totalFee: result === null || result === void 0 ? void 0 : result.totalFee
421
- });
422
399
  if (result === null || result === void 0 ? void 0 : result.totalToCalc) {
423
400
  return result.totalToCalc;
424
401
  }
425
402
  return 0;
426
403
  });
427
- console.log('📊 TOTAL_PERCENTAGE - Array de valores:', {
428
- values: totalFromAllFees,
429
- nonZeroValues: totalFromAllFees.filter(function (v) { return v > 0; })
430
- });
431
404
  if (totalFromAllFees && (totalFromAllFees === null || totalFromAllFees === void 0 ? void 0 : totalFromAllFees.length) > 0) {
432
405
  var totalValueFromAllFees = totalFromAllFees.filter(function (i) { return !isNaN(+i) && +i > 0; }).reduce(function (previous, current) {
433
406
  if (!isNaN(+previous) && !isNaN(+current)) {
@@ -437,26 +410,11 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
437
410
  return previous;
438
411
  }
439
412
  }, 0);
440
- console.log('💰 TOTAL_PERCENTAGE - Valor total calculado:', {
441
- totalValueFromAllFees: totalValueFromAllFees,
442
- validValues: totalFromAllFees.filter(function (i) { return !isNaN(+i) && +i > 0; })
443
- });
444
413
  if (totalValueFromAllFees && !isNaN(+totalValueFromAllFees)) {
445
414
  var valueToMultiply = (+value / 100);
446
415
  var total_1 = +totalValueFromAllFees * valueToMultiply;
447
- console.log('🧮 TOTAL_PERCENTAGE - Cálculo final:', {
448
- totalValueFromAllFees: totalValueFromAllFees,
449
- valueToMultiply: valueToMultiply,
450
- percentage: value,
451
- totalBeforeMultiplier: total_1
452
- });
453
416
  var _e = applyRedeliveryMultiplier(total_1, cte), adjustedTotal_1 = _e.adjustedTotal, redeliveryInfo_1 = _e.redeliveryInfo;
454
417
  total_1 = adjustedTotal_1;
455
- console.log('🔄 TOTAL_PERCENTAGE - Após redelivery:', {
456
- adjustedTotal: adjustedTotal_1,
457
- redeliveryInfo: redeliveryInfo_1,
458
- finalTotal: total_1
459
- });
460
418
  var totalValueFromAllFeesCurrency = convertNumberToCurrency(+totalValueFromAllFees, 'pt-br');
461
419
  var resultCurrency_1 = (+total_1).toLocaleString('pt-BR', {
462
420
  style: 'currency',
@@ -483,7 +441,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
483
441
  style: 'currency',
484
442
  currency: 'BRL',
485
443
  });
486
- var result_2 = "".concat(fractions, " fra\u00E7\u00F5es x ").concat(valueCurrency_1).concat(redeliveryInfo_2, " = ").concat(resultCurrency_2);
444
+ var result_2 = "".concat(cte.taxedWeight, " kg = ").concat(fractions, " fra\u00E7\u00F5es x ").concat(valueCurrency_1).concat(redeliveryInfo_2, " = ").concat(resultCurrency_2);
487
445
  totalFee = total_2;
488
446
  resultFee = result_2;
489
447
  }
@@ -558,7 +516,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
558
516
  // Calcula baseado na taxa do intervalo mais alto que tem maxWeight
559
517
  var total_4 = +highestIntervalFee.value;
560
518
  // Calcular diferença de peso
561
- var weightDifference = Math.ceil(((cte === null || cte === void 0 ? void 0 : cte.taxedWeight) || 0) - (highestIntervalFee.maxWeight || 0));
519
+ var weightDifference = Number((((cte === null || cte === void 0 ? void 0 : cte.taxedWeight) || 0) - (highestIntervalFee.maxWeight || 0)).toFixed(2));
562
520
  // Calcular valor adicional pela diferença de peso
563
521
  var additionalValue = weightDifference * +ratecardLaneFee.value;
564
522
  // Somar ao total
@@ -574,7 +532,7 @@ var calculateFee = function (ratecardLaneFee, cte, allFees, debug, allFeesForCal
574
532
  style: 'currency',
575
533
  currency: 'BRL',
576
534
  });
577
- var result_4 = "".concat(valueCurrency_2, " + ").concat(weightDifference, " kg x ").concat(convertNumberToCurrency(+ratecardLaneFee.value, 'pt-br')).concat(redeliveryInfo_4, " = ").concat(resultCurrency_4);
535
+ var result_4 = "".concat(cte.taxedWeight, " kg = ").concat(valueCurrency_2, " + ").concat(weightDifference, " kg x ").concat(convertNumberToCurrency(+ratecardLaneFee.value, 'pt-br')).concat(redeliveryInfo_4, " = ").concat(resultCurrency_4);
578
536
  totalFee = total_4;
579
537
  resultFee = result_4;
580
538
  }
package/build/index.js.gz CHANGED
Binary file