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