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