This commit is contained in:
Muhammad Fadli 2023-05-10 05:47:15 +07:00
commit 166ee1f2e0
2 changed files with 13 additions and 1 deletions

View File

@ -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,
);

View File

@ -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