diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index 6f07872..98fed2e 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -185,6 +185,7 @@ export class TransactionController { @Query('pageSize') pageSize: number, @Query('start') startDate: string, @Query('end') endDate: string, + @Query('trxId') trxId: string, @Request() req, ) { const data = await this.transactionService.transactionHistoryByUser( @@ -192,6 +193,7 @@ export class TransactionController { req.user.userId, startDate == 'null' ? null : startDate, endDate == 'null' ? null : endDate, + trxId == 'null' ? null : trxId, pageSize, ); @@ -229,6 +231,7 @@ export class TransactionController { @Query('pageSize') pageSize: number, @Query('start') startDate: string, @Query('end') endDate: string, + @Query('trxId') trxId: string, @Param('id', ParseUUIDPipe) id: string, ) { const data = await this.transactionService.transactionHistoryByUser( @@ -236,6 +239,7 @@ export class TransactionController { id, startDate == 'null' ? null : startDate, endDate == 'null' ? null : endDate, + trxId == 'null' ? null : trxId, pageSize, ); diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 9637255..cdc062a 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1885,6 +1885,7 @@ export class TransactionService { user: string, startDate: string, endDate: string, + trxId: string, pageSize?: number, ) { const userData = await this.userService.findExist(user); @@ -1950,7 +1951,7 @@ export class TransactionService { .addSelect('supplier.name', 'supplier_name') .orderBy('transaction.created_at', 'DESC'); - if (startDate && endDate) { + if (startDate != null && endDate != null) { baseQuery.andWhere( 'transaction.created_at between :startDate and :enDate', { @@ -1958,6 +1959,13 @@ export class TransactionService { enDate: new Date(endDate), }, ); + } else if (trxId != null) { + baseQuery.andWhere( + 'transaction.supplier_trx_id = :trxId', + { + trxId: trxId + }, + ); } const data = await baseQuery