fix: get deposit return to
This commit is contained in:
		| @@ -165,16 +165,14 @@ export class TransactionController { | ||||
|     @Query('pageSize') pageSize: number, | ||||
|     @Request() req, | ||||
|   ) { | ||||
|     const [data, count] = | ||||
|       await this.transactionService.getAllDepositReturnToUser( | ||||
|         req.user.userId, | ||||
|         page, | ||||
|         pageSize, | ||||
|       ); | ||||
|     const data = await this.transactionService.getAllDepositReturnToUser( | ||||
|       req.user.userId, | ||||
|       page, | ||||
|       pageSize, | ||||
|     ); | ||||
|  | ||||
|     return { | ||||
|       data, | ||||
|       count, | ||||
|       ...data, | ||||
|       statusCode: HttpStatus.OK, | ||||
|       message: 'success', | ||||
|     }; | ||||
|   | ||||
| @@ -24,6 +24,8 @@ import { SupplierService } from '../users/supplier/supplier.service'; | ||||
| import { ProductHistoryPriceService } from '../product/history-price/history-price.service'; | ||||
| import { CommissionService } from '../configurable/commission.service'; | ||||
| import { DepositReturnDto } from './dto/deposit_return.dto'; | ||||
| import { User } from '../users/entities/user.entity'; | ||||
| import { UserDetail } from '../users/entities/user_detail.entity'; | ||||
|  | ||||
| interface JournalEntry { | ||||
|   coa_id: string; | ||||
| @@ -673,6 +675,32 @@ export class TransactionService { | ||||
|     page: number, | ||||
|     pageSize?: number, | ||||
|   ) { | ||||
|     const baseQuery = this.transactionRepository | ||||
|       .createQueryBuilder('transaction') | ||||
|       .select('transaction.id', 'id') | ||||
|       .addSelect(['transaction.created_at', 'image_prove', 'amount']) | ||||
|       .where('transaction.user_destination = :id and transaction.type = 3', { | ||||
|         id: user, | ||||
|       }) | ||||
|       .leftJoinAndMapOne( | ||||
|         'transaction.userData', | ||||
|         UserDetail, | ||||
|         'userData', | ||||
|         'userData.user = transaction.user', | ||||
|       ) | ||||
|       .addSelect('userData.name', 'name'); | ||||
|  | ||||
|     const data = await baseQuery | ||||
|       .offset(page * (pageSize || 10)) | ||||
|       .limit(pageSize || 10) | ||||
|       .getRawMany(); | ||||
|  | ||||
|     const totalData = await baseQuery.getCount(); | ||||
|  | ||||
|     return { | ||||
|       data, | ||||
|       count: totalData, | ||||
|     }; | ||||
|     return this.transactionRepository.findAndCount({ | ||||
|       skip: page * (pageSize || 10), | ||||
|       take: pageSize || 10, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user