diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 6a8a8fd..f66cdb7 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -528,7 +528,7 @@ export class TransactionService { await this.productHistoryPriceService.updateEndDate(product.id); listActivePrice.map(async (x) => { - let newProductPrice = new ProductHistoryPrice(); + const newProductPrice = new ProductHistoryPrice(); newProductPrice.id = uuid.v4(); newProductPrice.type = x.type; @@ -613,30 +613,32 @@ export class TransactionService { await manager.save(transactionData); - await this.accountingTransaction({ - createTransaction: false, - transactionalEntityManager: manager, - transaction: transactionData, - amount: transactionData.amount, - journals: [ - { - coa_id: coaSenderWallet.id, - credit: transactionData.amount, - }, - { - coa_id: coaReceiverWallet.id, - debit: transactionData.amount, - }, - { - coa_id: coaAR.id, - credit: transactionData.amount, - }, - { - coa_id: coaAP.id, - debit: transactionData.amount, - }, - ], - }); + if (statusApproval === 'accept') { + await this.accountingTransaction({ + createTransaction: false, + transactionalEntityManager: manager, + transaction: transactionData, + amount: transactionData.amount, + journals: [ + { + coa_id: coaSenderWallet.id, + credit: transactionData.amount, + }, + { + coa_id: coaReceiverWallet.id, + debit: transactionData.amount, + }, + { + coa_id: coaAR.id, + credit: transactionData.amount, + }, + { + coa_id: coaAP.id, + debit: transactionData.amount, + }, + ], + }); + } }); return transactionData; @@ -1020,6 +1022,7 @@ export class TransactionService { if (startDate && endDate) { filter['start'] = Between(new Date(startDate), new Date(endDate)); } + const baseQuery = this.transactionRepository.findAndCount({ skip: page * (pageSize || 10), take: pageSize || 10, @@ -1028,6 +1031,7 @@ export class TransactionService { createdAt: 'DESC', }, }); + return baseQuery; }