Merge branch 'development' into 'devops-staging'
fix: one way pembayaran See merge request empatnusabangsa/ppob/ppob-backend!109
This commit is contained in:
commit
7b2cfc649e
|
@ -437,7 +437,7 @@ export class TransactionService {
|
|||
currentUser: any,
|
||||
) {
|
||||
let status;
|
||||
let amount = 0;
|
||||
const amount = 0;
|
||||
//GET USER DATA
|
||||
const userData = await this.userService.findByUsername(
|
||||
currentUser.username,
|
||||
|
@ -591,6 +591,7 @@ export class TransactionService {
|
|||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return {
|
||||
trx_id: trxId,
|
||||
client_trx_id: orderTransactionDto.trx_id,
|
||||
|
@ -632,63 +633,67 @@ export class TransactionService {
|
|||
) {
|
||||
const transactionData = await this.findApprovalDepositReturn(id);
|
||||
|
||||
const coaSenderWallet = await this.coaService.findByUser(
|
||||
transactionData.user,
|
||||
coaType.WALLET,
|
||||
);
|
||||
// const coaSenderWallet = await this.coaService.findByUser(
|
||||
// transactionData.user,
|
||||
// coaType.WALLET,
|
||||
// );
|
||||
//
|
||||
// const coaAP = await this.coaService.findByUserWithRelated(
|
||||
// transactionData.user,
|
||||
// userData.userId,
|
||||
// coaType.ACCOUNT_PAYABLE,
|
||||
// );
|
||||
//
|
||||
// const coaReceiverWallet = await this.coaService.findByUser(
|
||||
// transactionData.user,
|
||||
// coaType.WALLET,
|
||||
// );
|
||||
//
|
||||
// const coaAR = await this.coaService.findByUserWithRelated(
|
||||
// transactionData.user,
|
||||
// userData.userId,
|
||||
// coaType.ACCOUNT_RECEIVABLE,
|
||||
// );
|
||||
|
||||
const coaAP = await this.coaService.findByUserWithRelated(
|
||||
transactionData.user,
|
||||
userData.userId,
|
||||
coaType.ACCOUNT_PAYABLE,
|
||||
);
|
||||
|
||||
const coaReceiverWallet = await this.coaService.findByUser(
|
||||
transactionData.user,
|
||||
coaType.WALLET,
|
||||
);
|
||||
|
||||
const coaAR = await this.coaService.findByUserWithRelated(
|
||||
transactionData.user,
|
||||
userData.userId,
|
||||
coaType.ACCOUNT_RECEIVABLE,
|
||||
);
|
||||
const userFind = await this.userService.findByUsername(userData.username);
|
||||
|
||||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
transactionData.status =
|
||||
statusApproval === 'accept'
|
||||
? statusTransaction.APPROVED
|
||||
: statusTransaction.REJECTED;
|
||||
if (statusApproval === 'accept') {
|
||||
if (userFind.roles.name != 'Admin') {
|
||||
transactionData.user_destination = userFind.superior.id;
|
||||
} else {
|
||||
transactionData.status = statusTransaction.APPROVED;
|
||||
}
|
||||
// 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,
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
} else {
|
||||
transactionData.status = statusTransaction.REJECTED;
|
||||
}
|
||||
|
||||
await manager.save(transactionData);
|
||||
|
||||
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;
|
||||
|
@ -722,7 +727,6 @@ export class TransactionService {
|
|||
statusApproval === 'Accept'
|
||||
? statusTransaction.APPROVED
|
||||
: statusTransaction.REJECTED;
|
||||
|
||||
await manager.save(transactionData);
|
||||
|
||||
await this.accountingTransaction({
|
||||
|
@ -764,7 +768,7 @@ export class TransactionService {
|
|||
|
||||
dataTransaction.status = statusTransaction.FAILED;
|
||||
dataTransaction.callback_json = callback;
|
||||
dataTransaction.failed_reason = failedReason[0] + ', ' + failedReason[1];
|
||||
dataTransaction.failed_reason = `${failedReason[0]}, ${failedReason[1]}`;
|
||||
|
||||
const userData = await this.userService.findExist(dataTransaction.user);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user