fix: rollback jurnal
This commit is contained in:
parent
c2b4b5ec30
commit
953161c4b2
|
@ -1310,12 +1310,26 @@ export class TransactionService {
|
|||
relations: ['product_price'],
|
||||
});
|
||||
|
||||
const dataTransactionJurnal = await this.transactionJournalRepository.find({
|
||||
where: {
|
||||
transaction_head: trxId,
|
||||
},
|
||||
relations: ['coa'],
|
||||
});
|
||||
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: {
|
||||
transaction_head: trxId,
|
||||
},
|
||||
relations: ['coa'],
|
||||
});
|
||||
}
|
||||
|
||||
let dataRollbackJurnal = [];
|
||||
|
||||
|
@ -1333,18 +1347,20 @@ export class TransactionService {
|
|||
dataRollbackJurnal.push(data);
|
||||
});
|
||||
|
||||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
await this.accountingTransaction({
|
||||
createTransaction: false,
|
||||
transactionalEntityManager: manager,
|
||||
transaction: dataTransaction,
|
||||
amount: dataTransaction.amount,
|
||||
journals: dataRollbackJurnal,
|
||||
if (dataRollbackJurnal.length > 0) {
|
||||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
await this.accountingTransaction({
|
||||
createTransaction: false,
|
||||
transactionalEntityManager: manager,
|
||||
transaction: dataTransaction,
|
||||
amount: dataTransaction.amount,
|
||||
journals: dataRollbackJurnal,
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user