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