b2m-utils 0.0.312 → 0.0.314
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.esm.js +72 -23
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +72 -23
- package/build/index.js.gz +0 -0
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1072,29 +1072,74 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
|
|
|
1072
1072
|
if (percentageFees.length === 0) {
|
|
1073
1073
|
return results;
|
|
1074
1074
|
}
|
|
1075
|
-
// Calcular base das fees não-percentuais
|
|
1076
|
-
//
|
|
1077
|
-
var
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1075
|
+
// Calcular base das fees não-percentuais para cada fee TOTAL_PERCENTAGE
|
|
1076
|
+
// Cada fee TOTAL_PERCENTAGE terá sua própria baseNonPercentage (excluindo suas fees configuradas)
|
|
1077
|
+
var calculateBaseNonPercentageForFee = function (excludedFeeIds) {
|
|
1078
|
+
var base = 0;
|
|
1079
|
+
var details = [];
|
|
1080
|
+
if (currentValues) {
|
|
1081
|
+
// Usar valores atuais das fees não-percentuais
|
|
1082
|
+
nonPercentageFees.forEach(function (fee) {
|
|
1083
|
+
var _a;
|
|
1084
|
+
if (!((_a = fee.fee) === null || _a === void 0 ? void 0 : _a.id))
|
|
1085
|
+
return;
|
|
1086
|
+
var isExcluded = excludedFeeIds.has(fee.fee.id);
|
|
1087
|
+
var value = currentValues.get(fee.fee.id);
|
|
1088
|
+
if (value !== undefined) {
|
|
1089
|
+
details.push({
|
|
1090
|
+
feeId: fee.fee.id,
|
|
1091
|
+
feeName: fee.fee.name || 'Unknown',
|
|
1092
|
+
value: value,
|
|
1093
|
+
excluded: isExcluded
|
|
1094
|
+
});
|
|
1095
|
+
if (!isExcluded) {
|
|
1096
|
+
base += value;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
// Se não tem valor atual, calcular
|
|
1101
|
+
var calculated = calculateFee(fee, cte, allFees, false, allFeesForCalc);
|
|
1102
|
+
var calcValue = (calculated === null || calculated === void 0 ? void 0 : calculated.totalToCalc) || 0;
|
|
1103
|
+
if (calcValue > 0) {
|
|
1104
|
+
details.push({
|
|
1105
|
+
feeId: fee.fee.id,
|
|
1106
|
+
feeName: fee.fee.name || 'Unknown',
|
|
1107
|
+
value: calcValue,
|
|
1108
|
+
excluded: isExcluded
|
|
1109
|
+
});
|
|
1110
|
+
if (!isExcluded) {
|
|
1111
|
+
base += calcValue;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
// Calcular normalmente
|
|
1119
|
+
var nonPercentageResults = filterSiblingFees(nonPercentageFees.map(function (it) {
|
|
1120
|
+
return calculateFee(it, cte, allFees, false, allFeesForCalc);
|
|
1121
|
+
}));
|
|
1122
|
+
nonPercentageResults.forEach(function (r) {
|
|
1123
|
+
var _a;
|
|
1124
|
+
if (!((_a = r.fee) === null || _a === void 0 ? void 0 : _a.id))
|
|
1125
|
+
return;
|
|
1126
|
+
var isExcluded = excludedFeeIds.has(r.fee.id);
|
|
1127
|
+
var value = r.totalToCalc || 0;
|
|
1128
|
+
if (value > 0) {
|
|
1129
|
+
details.push({
|
|
1130
|
+
feeId: r.fee.id,
|
|
1131
|
+
feeName: r.fee.name || 'Unknown',
|
|
1132
|
+
value: value,
|
|
1133
|
+
excluded: isExcluded
|
|
1134
|
+
});
|
|
1135
|
+
if (!isExcluded) {
|
|
1136
|
+
base += value;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
return { base: base, details: details };
|
|
1142
|
+
};
|
|
1098
1143
|
// Calcular fees percentuais iterativamente até convergir
|
|
1099
1144
|
var maxIterations = 10;
|
|
1100
1145
|
var tolerance = 0.01; // Tolerância de 1 centavo
|
|
@@ -1125,6 +1170,9 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
|
|
|
1125
1170
|
excludedFeeIds: Array.from(excludedFeeIds),
|
|
1126
1171
|
iteration: iteration
|
|
1127
1172
|
});
|
|
1173
|
+
// Calcular base não-percentual específica para esta fee (excluindo fees configuradas)
|
|
1174
|
+
var _a = calculateBaseNonPercentageForFee(excludedFeeIds), baseNonPercentage = _a.base, nonPercentageDetails = _a.details;
|
|
1175
|
+
// Calcular base percentual (outras fees TOTAL_PERCENTAGE, exceto ela mesma e excluídas)
|
|
1128
1176
|
var basePercentage = Array.from(previousValues.entries())
|
|
1129
1177
|
.filter(function (_a) {
|
|
1130
1178
|
var feeId = _a[0];
|
|
@@ -1141,6 +1189,7 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
|
|
|
1141
1189
|
feeId: pf.fee.id,
|
|
1142
1190
|
feeName: pf.fee.name,
|
|
1143
1191
|
baseNonPercentage: baseNonPercentage,
|
|
1192
|
+
nonPercentageDetails: nonPercentageDetails,
|
|
1144
1193
|
basePercentage: basePercentage,
|
|
1145
1194
|
baseValue: baseValue,
|
|
1146
1195
|
percentValue: "".concat(pf.value, "%"),
|
package/build/index.js.gz
CHANGED
|
Binary file
|