Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!85
This commit is contained in:
		| @@ -169,27 +169,6 @@ export class TransactionController { | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   @Get('deposit-return') | ||||
|   async findDepositReturn( | ||||
|     @Query('page') page: number, | ||||
|     @Query('pageSize') pageSize: number, | ||||
|     @Request() req, | ||||
|   ) { | ||||
|     const [data, count] = | ||||
|       await this.transactionService.getAllDepositReturnFromUser( | ||||
|         req.user.userId, | ||||
|         page, | ||||
|         pageSize, | ||||
|       ); | ||||
|  | ||||
|     return { | ||||
|       data, | ||||
|       count, | ||||
|       statusCode: HttpStatus.OK, | ||||
|       message: 'success', | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   @Get('total-order') | ||||
|   async findTotalOrder(@Request() req) { | ||||
|     const data = await this.transactionService.getTotalSell(req.user); | ||||
| @@ -223,15 +202,46 @@ export class TransactionController { | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   @Get('deposit-return') | ||||
|   async findDepositReturn( | ||||
|     @Query('page') page: number, | ||||
|     @Query('pageSize') pageSize: number, | ||||
|     @Query('start') startDate: string, | ||||
|     @Query('end') endDate: string, | ||||
|     @Request() req, | ||||
|   ) { | ||||
|     const [data, count] = | ||||
|       await this.transactionService.getAllDepositReturnFromUser( | ||||
|         req.user.userId, | ||||
|         page, | ||||
|         startDate == 'null' ? null : startDate, | ||||
|         endDate == 'null' ? null : endDate, | ||||
|         pageSize, | ||||
|       ); | ||||
|  | ||||
|     return { | ||||
|       data, | ||||
|       count, | ||||
|       statusCode: HttpStatus.OK, | ||||
|       message: 'success', | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   @Get('deposit-return/confirmation') | ||||
|   async findDepositReturnConfirmation( | ||||
|     @Query('page') page: number, | ||||
|     @Query('pageSize') pageSize: number, | ||||
|     @Query('start') startDate: string, | ||||
|     @Query('end') endDate: string, | ||||
|     @Query('sender') sender: string, | ||||
|     @Request() req, | ||||
|   ) { | ||||
|     const data = await this.transactionService.getAllDepositReturnToUser( | ||||
|       req.user.userId, | ||||
|       page, | ||||
|       sender == 'null' ? null : sender, | ||||
|       startDate == 'null' ? null : startDate, | ||||
|       endDate == 'null' ? null : endDate, | ||||
|       pageSize, | ||||
|     ); | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import { DistributeTransactionDto } from './dto/distribute-transaction.dto'; | ||||
| import { OrderTransactionDto } from './dto/order-transaction.dto'; | ||||
| import { InjectRepository } from '@nestjs/typeorm'; | ||||
| import { Transactions } from './entities/transactions.entity'; | ||||
| import { Connection, EntityNotFoundError, Repository } from 'typeorm'; | ||||
| import { Between, Connection, EntityNotFoundError, Repository } from 'typeorm'; | ||||
| import { COA } from './entities/coa.entity'; | ||||
| import { TransactionJournal } from './entities/transaction-journal.entity'; | ||||
| import { CoaService } from './coa.service'; | ||||
| @@ -1001,24 +1001,38 @@ export class TransactionService { | ||||
|   async getAllDepositReturnFromUser( | ||||
|     user: string, | ||||
|     page: number, | ||||
|     startDate: string, | ||||
|     endDate: string, | ||||
|     pageSize?: number, | ||||
|   ) { | ||||
|     return this.transactionRepository.findAndCount({ | ||||
|     const filter = { | ||||
|       user: user, | ||||
|       type: typeTransaction.DEPOSIT_RETURN, | ||||
|     }; | ||||
|  | ||||
|     if (startDate && endDate) { | ||||
|       filter['start'] = Between(new Date(startDate), new Date(endDate)); | ||||
|     } | ||||
|     const baseQuery = this.transactionRepository.findAndCount({ | ||||
|       skip: page * (pageSize || 10), | ||||
|       take: pageSize || 10, | ||||
|       where: { | ||||
|         user: user, | ||||
|         type: typeTransaction.DEPOSIT_RETURN, | ||||
|       }, | ||||
|       where: filter, | ||||
|       order: { | ||||
|         createdAt: 'DESC', | ||||
|       }, | ||||
|     }); | ||||
|  | ||||
|  | ||||
|  | ||||
|     return baseQuery; | ||||
|   } | ||||
|  | ||||
|   async getAllDepositReturnToUser( | ||||
|     user: string, | ||||
|     page: number, | ||||
|     sender: string, | ||||
|     startDate: string, | ||||
|     endDate: string, | ||||
|     pageSize?: number, | ||||
|   ) { | ||||
|     const baseQuery = this.transactionRepository | ||||
| @@ -1041,6 +1055,22 @@ export class TransactionService { | ||||
|         'userData.name', | ||||
|       ]); | ||||
|  | ||||
|     if (startDate && endDate) { | ||||
|       baseQuery.andWhere( | ||||
|         'transaction.created_at between :startDate and :enDate', | ||||
|         { | ||||
|           startDate: new Date(startDate), | ||||
|           enDate: new Date(endDate), | ||||
|         }, | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     if (sender) { | ||||
|       baseQuery.andWhere('transaction.user = :sender', { | ||||
|         sender, | ||||
|       }); | ||||
|     } | ||||
|  | ||||
|     const data = await baseQuery | ||||
|       .offset(page * (pageSize || 10)) | ||||
|       .limit(pageSize || 10) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user