import { TransactionDto } from '../types/generated/TransactionDto'; // TODO: Use generated TransactionDto when it includes all required fields export type FullTransactionDto = TransactionDto & { amount: number; description: string; createdAt: string; type: 'deposit' | 'withdrawal'; }; export class WalletTransactionViewModel { id: string; walletId: string; amount: number; description: string; createdAt: string; type: 'deposit' | 'withdrawal'; constructor(dto: FullTransactionDto) { this.id = dto.id; this.walletId = dto.walletId; this.amount = dto.amount; this.description = dto.description; this.createdAt = dto.createdAt; this.type = dto.type; } /** UI-specific: Formatted amount with sign */ get formattedAmount(): string { const sign = this.type === 'deposit' ? '+' : '-'; return `${sign}$${this.amount.toFixed(2)}`; } /** UI-specific: Amount color */ get amountColor(): string { return this.type === 'deposit' ? 'green' : 'red'; } /** UI-specific: Type display */ get typeDisplay(): string { return this.type.charAt(0).toUpperCase() + this.type.slice(1); } /** UI-specific: Amount color */ get amountColor(): string { return this.type === 'deposit' ? 'green' : 'red'; } /** UI-specific: Formatted created date */ get formattedCreatedAt(): string { return new Date(this.createdAt).toLocaleString(); } }