mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
Merge pull request #43 from HamzaSha1/ZOD-204-view-spending-from-child-login
git checkout -b ZOD-204-view-spending-from-child-login
This commit is contained in:
@ -274,6 +274,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(
|
||||
|
||||
Reference in New Issue
Block a user