git checkout -b ZOD-204-view-spending-from-child-login

This commit is contained in:
Abdalhamid Alhamad
2025-10-19 15:26:47 +03:00
parent fdd2e23669
commit d2e084d3e4
11 changed files with 285 additions and 0 deletions

View File

@ -273,6 +273,42 @@ export class JuniorService {
return this.transactionService.getChildTransfersPaginated(juniorId, page, size);
}
async getSpendingHistory(juniorId: string, userId: string, startUtc: Date, endUtc: Date) {
this.logger.log(`Getting spending history for junior ${juniorId}`);
// Check if user is the junior themselves or their guardian
let junior: Junior | null;
if (juniorId === userId) {
junior = await this.findJuniorById(juniorId, false);
} else {
junior = await this.findJuniorById(juniorId, false, userId);
}
if (!junior) {
throw new BadRequestException('JUNIOR.NOT_FOUND');
}
return this.transactionService.getChildSpendingHistory(juniorId, startUtc, endUtc);
}
async getTransactionDetail(juniorId: string, userId: string, transactionId: string) {
this.logger.log(`Getting transaction detail ${transactionId} for junior ${juniorId}`);
// Check if user is the junior themselves or their guardian
let junior: Junior | null;
if (juniorId === userId) {
junior = await this.findJuniorById(juniorId, false);
} else {
junior = await this.findJuniorById(juniorId, false, userId);
}
if (!junior) {
throw new BadRequestException('JUNIOR.NOT_FOUND');
}
return this.transactionService.getTransactionDetail(transactionId, juniorId);
}
private async prepareJuniorImages(juniors: Junior[]) {
this.logger.log(`Preparing junior images`);
await Promise.all(