fix(investments): align roles and date contracts
Backend security / security (push) Successful in 9s
Backend verify / verify (push) Successful in 10m23s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Successful in 10m39s
Conventional commits / commits (pull_request) Successful in 29s

Identify income dependencies by role and document screen-specific dates.
Convert inclusive calendar days into half-open source ranges while
preserving operation timestamps and existing stored coverage.
This commit is contained in:
2026-09-27 11:38:13 +03:00
parent e4232138d0
commit 516e43203e
18 changed files with 500 additions and 74 deletions
@@ -12,7 +12,11 @@ import type {
TbankOperationItem,
TbankOperationsByCursorResponse,
} from '../../../../integrations/tbank/tbank.api';
import { DateOnlyRange, dateOnlyBounds } from '../../investment-calendar';
import {
DateOnlyRange,
dateOnlyBounds,
moscowDate,
} from '../../investment-calendar';
import { operationCategory } from './brokerage-operation.mapper';
import {
type OperationInterval,
@@ -96,14 +100,12 @@ export class BrokerageOperationsRepository {
? new Date(`${oldest}T00:00:00+03:00`)
: undefined;
const periods = input.periods?.(openedAt).map((period) => {
const bounds = dateOnlyBounds(period);
// Date-only end is inclusive; persisted coverage is half-open.
const end = new Date(`${period.to}T21:00:00Z`);
const now = new Date();
const bounds = dateOnlyBounds(period, now);
return {
...bounds,
key: `${period.from}/${period.to}`,
movingEnd: end.valueOf() > Date.now(),
to: new Date(Math.min(end.valueOf(), Date.now())),
movingEnd: period.to >= moscowDate(now),
};
});
const binding = createHash('sha256')