b2m-utils 0.0.312 → 0.0.313

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.
@@ -1071,17 +1071,31 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
1071
1071
  // Calcular base das fees não-percentuais
1072
1072
  // Se temos currentValues, usar eles; senão calcular normalmente
1073
1073
  var baseNonPercentage = 0;
1074
+ var nonPercentageDetails = [];
1074
1075
  if (currentValues) {
1075
1076
  // Usar valores atuais das fees não-percentuais
1076
1077
  baseNonPercentage = nonPercentageFees.reduce(function (sum, fee) {
1077
1078
  var _a;
1078
1079
  var value = ((_a = fee.fee) === null || _a === void 0 ? void 0 : _a.id) ? currentValues.get(fee.fee.id) : undefined;
1079
1080
  if (value !== undefined) {
1081
+ nonPercentageDetails.push({
1082
+ feeId: fee.fee.id,
1083
+ feeName: fee.fee.name || 'Unknown',
1084
+ value: value
1085
+ });
1080
1086
  return sum + value;
1081
1087
  }
1082
1088
  // Se não tem valor atual, calcular
1083
1089
  var calculated = calculateFee(fee, cte, allFees, false, allFeesForCalc);
1084
- return sum + ((calculated === null || calculated === void 0 ? void 0 : calculated.totalToCalc) || 0);
1090
+ var calcValue = (calculated === null || calculated === void 0 ? void 0 : calculated.totalToCalc) || 0;
1091
+ if (calcValue > 0) {
1092
+ nonPercentageDetails.push({
1093
+ feeId: fee.fee.id,
1094
+ feeName: fee.fee.name || 'Unknown',
1095
+ value: calcValue
1096
+ });
1097
+ }
1098
+ return sum + calcValue;
1085
1099
  }, 0);
1086
1100
  }
1087
1101
  else {
@@ -1089,8 +1103,24 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
1089
1103
  var nonPercentageResults = filterSiblingFees(nonPercentageFees.map(function (it) {
1090
1104
  return calculateFee(it, cte, allFees, false, allFeesForCalc);
1091
1105
  }));
1092
- baseNonPercentage = nonPercentageResults.reduce(function (sum, r) { return sum + (r.totalToCalc || 0); }, 0);
1106
+ baseNonPercentage = nonPercentageResults.reduce(function (sum, r) {
1107
+ var _a;
1108
+ var value = r.totalToCalc || 0;
1109
+ if (value > 0 && ((_a = r.fee) === null || _a === void 0 ? void 0 : _a.id)) {
1110
+ nonPercentageDetails.push({
1111
+ feeId: r.fee.id,
1112
+ feeName: r.fee.name || 'Unknown',
1113
+ value: value
1114
+ });
1115
+ }
1116
+ return sum + value;
1117
+ }, 0);
1093
1118
  }
1119
+ console.log('[calculateTotalPercentageFees] Base não-percentual calculada', {
1120
+ baseNonPercentage: baseNonPercentage,
1121
+ nonPercentageFeesCount: nonPercentageFees.length,
1122
+ nonPercentageDetails: nonPercentageDetails
1123
+ });
1094
1124
  // Calcular fees percentuais iterativamente até convergir
1095
1125
  var maxIterations = 10;
1096
1126
  var tolerance = 0.01; // Tolerância de 1 centavo
Binary file