refactor!: support RUB only (WealthLedger/main#55)

Filter non-RUB data at ingest, collapse per-currency collections into single RUB Money, drop currency from TbankPortfolioValuePoint, remove NON_RUB_ACTIVITY and screener currency filter.

BREAKING CHANGE: per-currency API fields replaced with single RUB Money; stock screener currency param removed.
This commit is contained in:
2026-11-11 08:22:16 +03:00
parent fee61537b6
commit 3b55b611b5
60 changed files with 624 additions and 736 deletions
@@ -156,7 +156,7 @@ export class UpcomingEventsService {
accountId,
calculatedAt: new Date().toISOString(),
events,
incomeTotalsByCurrency: incomeTotals(events),
incomeTotal: incomeTotal(events),
}
: undefined;
return this.forecasts.result({
@@ -286,22 +286,13 @@ function dateWindow(query: UpcomingEventsQueryDto) {
return { from, to };
}
function incomeTotals(events: UpcomingEventDto[]): MoneyDto[] {
const totals = new Map<string, Decimal>();
function incomeTotal(events: UpcomingEventDto[]): MoneyDto {
let total: Decimal = { value: 0n, scale: 0 };
for (const event of events) {
if (!['coupon', 'dividend'].includes(event.type) || !event.projectedAmount) {
continue;
}
const current = totals.get(event.projectedAmount.currency) ?? {
value: 0n,
scale: 0,
};
totals.set(
event.projectedAmount.currency,
add(current, decimalFromString(event.projectedAmount.value)),
);
total = add(total, decimalFromString(event.projectedAmount.value));
}
return [...totals]
.sort(([left], [right]) => left.localeCompare(right))
.map(([currency, value]) => ({ currency, value: formatDecimal(value) }));
return { currency: 'RUB', value: formatDecimal(total) };
}