mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 18:41:46 +00:00
25 lines
703 B
TypeScript
25 lines
703 B
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { SpendingHistoryItemDto } from './spending-history-item.response.dto';
|
|
|
|
export class SpendingHistoryResponseDto {
|
|
@ApiProperty({ type: [SpendingHistoryItemDto] })
|
|
transactions!: SpendingHistoryItemDto[];
|
|
|
|
@ApiProperty({ example: 150.75 })
|
|
totalSpent!: number;
|
|
|
|
@ApiProperty({ example: 'SAR' })
|
|
currency!: string;
|
|
|
|
@ApiProperty({ example: 10 })
|
|
count!: number;
|
|
|
|
constructor(transactions: SpendingHistoryItemDto[], currency: string = 'SAR') {
|
|
this.transactions = transactions;
|
|
this.totalSpent = transactions.reduce((sum, tx) => sum + tx.amount, 0);
|
|
this.currency = currency;
|
|
this.count = transactions.length;
|
|
}
|
|
}
|
|
|