Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!186
This commit is contained in:
commit
564166f14f
|
@ -132,10 +132,19 @@ export class TransactionController {
|
|||
};
|
||||
}
|
||||
|
||||
@Get('rollback-jurnal/:trxId')
|
||||
async rollbackJurnal(@Request() req, @Param('trxId') trxId: string) {
|
||||
const data = await this.transactionService.rollbackJurnal(trxId);
|
||||
return {
|
||||
data,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
@Get('resend-partner/success/:code')
|
||||
async resendSuccess(@Request() req, @Param('code') code: string) {
|
||||
const data = await this.transactionService.resendOrderToPartner(code, true);
|
||||
|
||||
return {
|
||||
data,
|
||||
statusCode: HttpStatus.OK,
|
||||
|
|
|
@ -1180,7 +1180,8 @@ export class TransactionService {
|
|||
const coaExpense = await this.coaService.findByName(
|
||||
`${coaType[coaType.EXPENSE]}-SYSTEM`,
|
||||
);
|
||||
if (userData.partner != null) {
|
||||
|
||||
if (userData.partner == null) {
|
||||
//GET SALES
|
||||
supervisorData = await this.calculateCommission(
|
||||
supervisorData,
|
||||
|
@ -1302,6 +1303,68 @@ export class TransactionService {
|
|||
return res;
|
||||
}
|
||||
|
||||
async rollbackJurnal(trxId: string) {
|
||||
const dataTransaction = await this.transactionRepository.findOne({
|
||||
where: {
|
||||
id: trxId,
|
||||
},
|
||||
relations: ['product_price'],
|
||||
});
|
||||
|
||||
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 = [];
|
||||
|
||||
dataTransactionJurnal.map((it) => {
|
||||
let data = {
|
||||
coa_id: it.coa.id,
|
||||
};
|
||||
|
||||
if (it.type == 0) {
|
||||
data['credit'] = it.amount;
|
||||
} else {
|
||||
data['debit'] = it.amount;
|
||||
}
|
||||
|
||||
dataRollbackJurnal.push(data);
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async withdrawBenefit(user) {
|
||||
const userData = await this.userService.findExist(user);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user