fix filter transaction

This commit is contained in:
2021-12-29 09:39:43 +07:00
parent 2948462ff8
commit bd6bf448a6
2 changed files with 9 additions and 12 deletions

View File

@@ -765,7 +765,8 @@ export class TransactionService {
async transactionHistoryByUser(
page: number,
user: string,
transactionDate: string,
startDate: string,
endDate: string,
pageSize?: number,
) {
const userData = await this.userService.findExist(user);
@@ -779,12 +780,6 @@ export class TransactionService {
userBySupperior.push(user)
}
if (transactionDate) {
filterTransactionDate = transactionDate.split(',').map((data) => {
return data.trim();
});
}
const baseQuery = this.transactionRepository
.createQueryBuilder('transaction')
.select('transaction.id', 'id')
@@ -798,10 +793,10 @@ export class TransactionService {
.addSelect('product.name', 'name')
.addSelect('product.id', 'product_id');
if (transactionDate && filterTransactionDate.length > 0) {
if (startDate && endDate) {
baseQuery.where('transaction.created_at between :startDate and :enDate', {
startDate: filterTransactionDate[0],
enDate: filterTransactionDate[0],
startDate: new Date(startDate),
enDate: new Date(endDate),
});
}