diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index b4e3c30..be3a07a 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -292,6 +292,13 @@ export class TransactionService { orderTransactionDto: OrderTransactionDto, currentUser: any, ) { + const trxId = Array(6) + .fill(null) + .map(() => { + return Math.round(Math.random() * 16).toString(16); + }) + .join(''); + //GET USER const userData = await this.userService.findByUsername( currentUser.username, @@ -378,6 +385,7 @@ export class TransactionService { transactionData.product_price = product_price; transactionData.destination = orderTransactionDto.destination; transactionData.partner_trx_id = orderTransactionDto.trx_id; + transactionData.partner_trx_id = trxId; await manager.insert(Transactions, transactionData); await this.accountingTransaction({ @@ -410,7 +418,13 @@ export class TransactionService { throw e; } - return true; + return { + trx_id: trxId, + client_trx_id: orderTransactionDto.trx_id, + product: orderTransactionDto.productCode, + amount: product_price.mark_up_price + product_price.price, + status: statusTransaction[statusTransaction.SUCCESS], + }; } async orderTransactionProd( @@ -490,7 +504,13 @@ export class TransactionService { await this.productHistoryPriceService.create(newProductPrice); } - return hitSupplier; + return { + trx_id: trxId, + client_trx_id: orderTransactionDto.trx_id, + product: orderTransactionDto.productCode, + amount: transactionData.amount, + status: statusTransaction[transactionData.status], + }; } async createDepositReturn(currentUser, depositReturnDto: DepositReturnDto) {