Merge branch 'development' into 'devops-staging'
fix filter transaction See merge request empatnusabangsa/ppob/ppob-backend!75
This commit is contained in:
commit
b289f78baa
|
@ -117,13 +117,15 @@ export class TransactionController {
|
||||||
async getHistoryTransactionUser(
|
async getHistoryTransactionUser(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
@Query('pageSize') pageSize: number,
|
@Query('pageSize') pageSize: number,
|
||||||
@Query('transactionDate') transactionDate: string,
|
@Query('startDate') startDate: string,
|
||||||
|
@Query('endDate') endDate: string,
|
||||||
@Request() req,
|
@Request() req,
|
||||||
) {
|
) {
|
||||||
const data = await this.transactionService.transactionHistoryByUser(
|
const data = await this.transactionService.transactionHistoryByUser(
|
||||||
page,
|
page,
|
||||||
req.user.userId,
|
req.user.userId,
|
||||||
transactionDate,
|
startDate,
|
||||||
|
endDate,
|
||||||
pageSize,
|
pageSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -765,7 +765,8 @@ export class TransactionService {
|
||||||
async transactionHistoryByUser(
|
async transactionHistoryByUser(
|
||||||
page: number,
|
page: number,
|
||||||
user: string,
|
user: string,
|
||||||
transactionDate: string,
|
startDate: string,
|
||||||
|
endDate: string,
|
||||||
pageSize?: number,
|
pageSize?: number,
|
||||||
) {
|
) {
|
||||||
const userData = await this.userService.findExist(user);
|
const userData = await this.userService.findExist(user);
|
||||||
|
@ -779,12 +780,6 @@ export class TransactionService {
|
||||||
userBySupperior.push(user)
|
userBySupperior.push(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactionDate) {
|
|
||||||
filterTransactionDate = transactionDate.split(',').map((data) => {
|
|
||||||
return data.trim();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const baseQuery = this.transactionRepository
|
const baseQuery = this.transactionRepository
|
||||||
.createQueryBuilder('transaction')
|
.createQueryBuilder('transaction')
|
||||||
.select('transaction.id', 'id')
|
.select('transaction.id', 'id')
|
||||||
|
@ -798,10 +793,10 @@ export class TransactionService {
|
||||||
.addSelect('product.name', 'name')
|
.addSelect('product.name', 'name')
|
||||||
.addSelect('product.id', 'product_id');
|
.addSelect('product.id', 'product_id');
|
||||||
|
|
||||||
if (transactionDate && filterTransactionDate.length > 0) {
|
if (startDate && endDate) {
|
||||||
baseQuery.where('transaction.created_at between :startDate and :enDate', {
|
baseQuery.where('transaction.created_at between :startDate and :enDate', {
|
||||||
startDate: filterTransactionDate[0],
|
startDate: new Date(startDate),
|
||||||
enDate: filterTransactionDate[0],
|
enDate: new Date(endDate),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user