diff --git a/src/card/repositories/transaction.repository.ts b/src/card/repositories/transaction.repository.ts index 13ccee1..30b51ab 100644 --- a/src/card/repositories/transaction.repository.ts +++ b/src/card/repositories/transaction.repository.ts @@ -92,7 +92,9 @@ export class TransactionRepository { return this.transactionRepository .createQueryBuilder('transaction') .innerJoinAndSelect('transaction.card', 'card') - .where('card.customerId = :juniorId', { juniorId }) + .innerJoin('card.customer', 'customer') + .innerJoin('customer.junior', 'junior') + .where('junior.id = :juniorId', { juniorId }) .andWhere('transaction.transactionScope = :scope', { scope: TransactionScope.CARD }) .andWhere('transaction.transactionType = :type', { type: TransactionType.EXTERNAL }) .andWhere('transaction.transactionDate BETWEEN :startDate AND :endDate', { startDate, endDate }) @@ -153,7 +155,9 @@ export class TransactionRepository { .createQueryBuilder('tx') .innerJoinAndSelect('tx.card', 'card') .innerJoinAndSelect('card.account', 'account') - .where('card.customerId = :juniorId', { juniorId }) + .innerJoin('card.customer', 'customer') + .innerJoin('customer.junior', 'junior') + .where('junior.id = :juniorId', { juniorId }) .andWhere('tx.transactionScope = :scope', { scope: TransactionScope.CARD }) .andWhere('tx.transactionType = :type', { type: TransactionType.INTERNAL }) .orderBy('tx.transactionDate', 'DESC') @@ -166,7 +170,9 @@ export class TransactionRepository { return this.transactionRepository .createQueryBuilder('tx') .innerJoin('tx.card', 'card') - .where('card.customerId = :juniorId', { juniorId }) + .innerJoin('card.customer', 'customer') + .innerJoin('customer.junior', 'junior') + .where('junior.id = :juniorId', { juniorId }) .andWhere('tx.transactionScope = :scope', { scope: TransactionScope.CARD }) .andWhere('tx.transactionType = :type', { type: TransactionType.INTERNAL }) .getCount(); @@ -176,8 +182,10 @@ export class TransactionRepository { return this.transactionRepository .createQueryBuilder('tx') .innerJoinAndSelect('tx.card', 'card') + .innerJoin('card.customer', 'customer') + .innerJoin('customer.junior', 'junior') .where('tx.id = :transactionId', { transactionId }) - .andWhere('card.customerId = :juniorId', { juniorId }) + .andWhere('junior.id = :juniorId', { juniorId }) .getOne(); } }