fix: rollback jurnal

This commit is contained in:
ilham 2022-06-28 15:14:51 +07:00
parent c2b4b5ec30
commit 953161c4b2

View File

@ -1310,12 +1310,26 @@ export class TransactionService {
relations: ['product_price'], relations: ['product_price'],
}); });
const dataTransactionJurnal = await this.transactionJournalRepository.find({ let dataTransactionJurnal;
if (dataTransaction.type == typeTransaction.ORDER) {
dataTransactionJurnal = await this.transactionJournalRepository.find({
where: {
transaction_head: trxId,
},
relations: ['coa'],
skip: 4,
order: {
createdAt: 'ASC',
},
});
} else {
dataTransactionJurnal = await this.transactionJournalRepository.find({
where: { where: {
transaction_head: trxId, transaction_head: trxId,
}, },
relations: ['coa'], relations: ['coa'],
}); });
}
let dataRollbackJurnal = []; let dataRollbackJurnal = [];
@ -1333,6 +1347,7 @@ export class TransactionService {
dataRollbackJurnal.push(data); dataRollbackJurnal.push(data);
}); });
if (dataRollbackJurnal.length > 0) {
try { try {
await this.connection.transaction(async (manager) => { await this.connection.transaction(async (manager) => {
await this.accountingTransaction({ await this.accountingTransaction({
@ -1347,6 +1362,7 @@ export class TransactionService {
throw e; throw e;
} }
} }
}
async withdrawBenefit(user) { async withdrawBenefit(user) {
const userData = await this.userService.findExist(user); const userData = await this.userService.findExist(user);