add: product price
This commit is contained in:
		| @@ -10,9 +10,9 @@ export class CoaService { | ||||
|     private coaRepository: Repository<COA>, | ||||
|   ) {} | ||||
|  | ||||
|   async findByUser(id: string, type: coaType) { | ||||
|   async findByUser(id: string, typeOfCoa: coaType) { | ||||
|     try { | ||||
|       return await this.coaRepository.findOneOrFail({ user: id, type: type }); | ||||
|       return await this.coaRepository.findOneOrFail({ user: id, type: typeOfCoa }); | ||||
|     } catch (e) { | ||||
|       if (e instanceof EntityNotFoundError) { | ||||
|         throw new HttpException( | ||||
|   | ||||
| @@ -28,22 +28,4 @@ export class TransactionController { | ||||
|   orderTransaction(@Body() orderTransactionDto: OrderTransactionDto) { | ||||
|     return this.transactionService.orderTransaction(orderTransactionDto); | ||||
|   } | ||||
|  | ||||
|   @Get(':id') | ||||
|   findOne(@Param('id') id: string) { | ||||
|     return this.transactionService.findOne(+id); | ||||
|   } | ||||
|  | ||||
|   @Patch(':id') | ||||
|   update( | ||||
|     @Param('id') id: string, | ||||
|     @Body() updateTransactionDto: UpdateTransactionDto, | ||||
|   ) { | ||||
|     return this.transactionService.update(+id, updateTransactionDto); | ||||
|   } | ||||
|  | ||||
|   @Delete(':id') | ||||
|   remove(@Param('id') id: string) { | ||||
|     return this.transactionService.remove(+id); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,18 +1,21 @@ | ||||
| import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; | ||||
| import { DistributeTransactionDto } from './dto/distribute-transaction.dto'; | ||||
| import { OrderTransactionDto } from './dto/order-transaction.dto'; | ||||
| import { UpdateTransactionDto } from './dto/update-transaction.dto'; | ||||
| import { InjectRepository } from '@nestjs/typeorm'; | ||||
| import { Transactions } from './entities/transactions.entity'; | ||||
| import { Connection, EntityNotFoundError, Repository } from 'typeorm'; | ||||
| import { Connection, Repository } from 'typeorm'; | ||||
| import { COA } from './entities/coa.entity'; | ||||
| import { TransactionType } from './entities/transaction-type.entity'; | ||||
| import { TransactionJournal } from './entities/transaction-journal.entity'; | ||||
| import { CoaService } from './coa.service'; | ||||
| import { statusTransaction } from '../helper/enum-list'; | ||||
| import { | ||||
|   balanceType, | ||||
|   coaType, | ||||
|   statusTransaction, | ||||
|   typeTransaction, | ||||
| } from '../helper/enum-list'; | ||||
| import { ProductService } from '../product/product.service'; | ||||
| import * as irsService from '../helper/irs-service'; | ||||
| import { balanceType, typeTransaction } from '../helper/enum-list'; | ||||
|  | ||||
| @Injectable() | ||||
| export class TransactionService { | ||||
| @@ -32,8 +35,14 @@ export class TransactionService { | ||||
|  | ||||
|   async distributeDeposit(distributeTransactionDto: DistributeTransactionDto) { | ||||
|     // GET COA | ||||
|     const coaSender = await this.coaService.findByUser('id_user'); | ||||
|     const coaReciever = await this.coaService.findByUser('id_user'); | ||||
|     const coaSender = await this.coaService.findByUser( | ||||
|       'id_user', | ||||
|       coaType.WALLET, | ||||
|     ); | ||||
|     const coaReciever = await this.coaService.findByUser( | ||||
|       'id_user', | ||||
|       coaType.WALLET, | ||||
|     ); | ||||
|  | ||||
|     await this.connection.transaction(async (manager) => { | ||||
|       //INSERT TRANSACTION | ||||
| @@ -73,7 +82,10 @@ export class TransactionService { | ||||
|   } | ||||
|  | ||||
|   async orderTransaction(orderTransactionDto: OrderTransactionDto) { | ||||
|     const coaAccount = await this.coaService.findByUser('id_user'); | ||||
|     const coaAccount = await this.coaService.findByUser( | ||||
|       'id_user', | ||||
|       coaType.WALLET, | ||||
|     ); | ||||
|  | ||||
|     //GET PRODUCT | ||||
|     const product = await this.productService.findOne( | ||||
| @@ -90,8 +102,7 @@ export class TransactionService { | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|  | ||||
|       try { | ||||
|     try { | ||||
|       const orderIRS = await irsService.createTransaction( | ||||
|         orderTransactionDto.productCode, | ||||
|         orderTransactionDto.destination, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user