import { ApiProperty } from '@nestjs/swagger'; import { MoneyDto } from '../../../common/money.dto'; import { InvestmentResourceMetaDto } from '../investment-resource.dto'; import { PortfolioStructureDto } from '../portfolio/portfolio.api'; import { HourlySyncStatusDto } from '../tbank-sync/tbank-sync.dto'; export class UnrealizedReturnDto { @ApiProperty() declare currency: string; @ApiProperty({ example: '12.345678901' }) declare absolute: string; @ApiProperty({ example: '100.00' }) declare costBasis: string; @ApiProperty({ type: String, nullable: true, example: '12.34' }) declare percent: null | string; @ApiProperty() declare partial: boolean; } export class PortfolioSummaryDto { @ApiProperty({ type: MoneyDto, isArray: true }) declare totalsByCurrency: MoneyDto[]; @ApiProperty({ type: MoneyDto, isArray: true }) declare cashBalances: MoneyDto[]; @ApiProperty({ type: PortfolioStructureDto }) declare structure: PortfolioStructureDto; @ApiProperty({ type: UnrealizedReturnDto, isArray: true }) declare unrealizedReturnByCurrency: UnrealizedReturnDto[]; @ApiProperty({ type: 'integer', minimum: 0, description: 'Number of non-zero stock positions, not the number of units.', }) declare stockPositionCount: number; @ApiProperty({ type: 'integer', minimum: 0, description: 'Number of non-zero bond positions, not the number of units.', }) declare bondPositionCount: number; @ApiProperty({ type: 'integer', minimum: 0, description: 'Number of non-zero fund positions, not the number of units.', }) declare fundPositionCount: number; @ApiProperty({ type: 'integer', minimum: 0, description: 'Number of all non-zero positions, not the number of units.', }) declare totalPositionCount: number; } export class BrokerageAccountDto { @ApiProperty() declare id: string; @ApiProperty() declare name: string; @ApiProperty({ enum: [ 'BROKERAGE', 'INDIVIDUAL_INVESTMENT', 'INVEST_BOX', 'MONEY_MARKET_FUND', ], }) declare type: 'BROKERAGE' | 'INDIVIDUAL_INVESTMENT' | 'INVEST_BOX' | 'MONEY_MARKET_FUND'; @ApiProperty({ type: String, nullable: true, format: 'date' }) declare openedOn: null | string; // eslint-disable-next-line @darraghor/nestjs-typed/api-property-matches-property-optionality -- Preserve the published required nullable schema; partial internal models may omit the field. @ApiProperty({ type: PortfolioSummaryDto, nullable: true }) portfolioSummary?: null | PortfolioSummaryDto; } export class BrokerageAccountsResourceDto { // eslint-disable-next-line @darraghor/nestjs-typed/api-property-returning-array-should-set-array -- Nullable array union requires isArray in the explicit wire schema. @ApiProperty({ type: BrokerageAccountDto, isArray: true, nullable: true }) declare data: BrokerageAccountDto[] | null; @ApiProperty({ type: InvestmentResourceMetaDto }) declare meta: InvestmentResourceMetaDto; @ApiProperty({ type: HourlySyncStatusDto, nullable: true, description: 'Read-only status of the last hourly walk for the current connection. Null when no walk attempt exists yet.', }) declare sync: HourlySyncStatusDto | null; }