b2m-utils 0.0.313 → 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 -53
- package/build/index.esm.js.gz +0 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.js +72 -53
- 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,59 +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
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
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
|
+
};
|
|
1124
1139
|
// Calcular fees percentuais iterativamente até convergir
|
|
1125
1140
|
var maxIterations = 10;
|
|
1126
1141
|
var tolerance = 0.01; // Tolerância de 1 centavo
|
|
@@ -1151,6 +1166,9 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
|
|
|
1151
1166
|
excludedFeeIds: Array.from(excludedFeeIds),
|
|
1152
1167
|
iteration: iteration
|
|
1153
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)
|
|
1154
1172
|
var basePercentage = Array.from(previousValues.entries())
|
|
1155
1173
|
.filter(function (_a) {
|
|
1156
1174
|
var feeId = _a[0];
|
|
@@ -1167,6 +1185,7 @@ var calculateTotalPercentageFees = function (allFees, cte, allFeesForCalc, curre
|
|
|
1167
1185
|
feeId: pf.fee.id,
|
|
1168
1186
|
feeName: pf.fee.name,
|
|
1169
1187
|
baseNonPercentage: baseNonPercentage,
|
|
1188
|
+
nonPercentageDetails: nonPercentageDetails,
|
|
1170
1189
|
basePercentage: basePercentage,
|
|
1171
1190
|
baseValue: baseValue,
|
|
1172
1191
|
percentValue: "".concat(pf.value, "%"),
|
package/build/index.esm.js.gz
CHANGED
|
Binary file
|