From 401c91f66d21c107c57ffe6cc18958fa1bfe1188 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 10 May 2023 15:00:07 +0700 Subject: [PATCH] - Added filter by Partner Trx Id for transaction history --- src/transaction/transaction.service.ts | 42 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index dc4ceed..1d04905 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1960,20 +1960,34 @@ export class TransactionService { enDate: new Date(endDate), }, ); - } else if (trxId != null) { - baseQuery.andWhere( - 'transaction.supplier_trx_id = :trxId', - { - trxId: trxId - }, - ); - } else if (partnerTrxId != null) { - baseQuery.andWhere( - 'transaction.partner_trx_id = :partnerTrxId', - { - partnerTrxId: partnerTrxId - }, - ); + } else if (trxId != null || partnerTrxId != null) { + if (trxId != null && partnerTrxId != null) { + baseQuery.andWhere( + 'transaction.supplier_trx_id = :trxId and transaction.partner_trx_id = :partnerTrxId', + { + trxId: trxId, + partnerTrxId: partnerTrxId, + }, + ); + } else { + if (trxId != null) { + baseQuery.andWhere( + 'transaction.supplier_trx_id = :trxId', + { + trxId: trxId + }, + ); + } else if (partnerTrxId != null) { + baseQuery.andWhere( + 'transaction.partner_trx_id = :partnerTrxId', + { + partnerTrxId: partnerTrxId + }, + ); + } + } + + } const data = await baseQuery