add all request for si hemat :
- Login - Request Transaction PrePaid - Request Inquiry / Check Bill PostPaid - Request Payment PostPaid
This commit is contained in:
parent
a5683666aa
commit
9b14685a92
|
@ -11,24 +11,42 @@ export const doTransaction = async (
|
|||
destination,
|
||||
idtrx,
|
||||
supplier,
|
||||
authorization,
|
||||
typePaid,
|
||||
) => {
|
||||
try {
|
||||
if (supplier.code == 'IRS') {
|
||||
const res = await axios.get(
|
||||
`${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else if (supplier.code == 'NIRS') {
|
||||
const res = await axios.get(
|
||||
`${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
} else {
|
||||
} else if (supplier.code == 'Hemat') {
|
||||
const options = {
|
||||
headers: { Authorization: `${authorization}` },
|
||||
};
|
||||
const data = {
|
||||
idtransaction: idtrx,
|
||||
destination: `${destination}`,
|
||||
code: `${productCode}`,
|
||||
type: `${typePaid}`,
|
||||
};
|
||||
const res = await axios.post(`${supplier.url}`, data, options);
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
const res = await axios.get(
|
||||
`${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`,
|
||||
);
|
||||
|
||||
return res.data;
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
|
|
15
src/helper/sihemat-authorization.ts
Normal file
15
src/helper/sihemat-authorization.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export const doAuthorizeHemat = async (user, pass, supplier) => {
|
||||
try {
|
||||
const data = {
|
||||
username: `${user}`,
|
||||
password: `${pass}`,
|
||||
};
|
||||
const res = await axios.post(`${supplier.url}`, data);
|
||||
|
||||
return res.data;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
};
|
|
@ -515,12 +515,13 @@ export class ProductService {
|
|||
};
|
||||
}
|
||||
|
||||
async findOne(code: string, type: string) {
|
||||
async findOne(code: string, type: string, productId: string) {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
id: productId
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
|
@ -635,16 +636,16 @@ export class ProductService {
|
|||
code: string,
|
||||
updatePriceProductDto: UpdatePriceProductDto,
|
||||
) {
|
||||
const product = await this.findOne(code, updatePriceProductDto.productType);
|
||||
// const product = await this.findOne(code, updatePriceProductDto.productType);
|
||||
|
||||
await this.productHistoryPrice.insert({
|
||||
product: product,
|
||||
type: updatePriceProductDto.type,
|
||||
price: updatePriceProductDto.price,
|
||||
mark_up_price: updatePriceProductDto.markUpPrice,
|
||||
startDate: updatePriceProductDto.startDate,
|
||||
endDate: updatePriceProductDto.endDate,
|
||||
});
|
||||
// await this.productHistoryPrice.insert({
|
||||
// product: product,
|
||||
// type: updatePriceProductDto.type,
|
||||
// price: updatePriceProductDto.price,
|
||||
// mark_up_price: updatePriceProductDto.markUpPrice,
|
||||
// startDate: updatePriceProductDto.startDate,
|
||||
// endDate: updatePriceProductDto.endDate,
|
||||
// });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,25 @@ import {DistributeTransactionDto} from './dto/distribute-transaction.dto';
|
|||
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Transactions } from './entities/transactions.entity';
|
||||
import {Between, Connection, EntityNotFoundError, In, Repository} from 'typeorm';
|
||||
import {
|
||||
Between,
|
||||
Connection,
|
||||
EntityNotFoundError,
|
||||
In,
|
||||
Repository,
|
||||
} from 'typeorm';
|
||||
import { COA } from './entities/coa.entity';
|
||||
import { TransactionJournal } from './entities/transaction-journal.entity';
|
||||
import { CoaService } from './coa.service';
|
||||
import * as uuid from 'uuid';
|
||||
import { uniq } from 'lodash';
|
||||
import { Decimal } from 'decimal.js';
|
||||
import {balanceType, coaType, statusTransaction, typeTransaction,} from '../helper/enum-list';
|
||||
import {
|
||||
balanceType,
|
||||
coaType,
|
||||
statusTransaction,
|
||||
typeTransaction,
|
||||
} from '../helper/enum-list';
|
||||
import { ProductService } from '../product/product.service';
|
||||
import { CreateJournalDto } from './dto/create-journal.dto';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
|
@ -25,6 +36,7 @@ import {ProductHistoryPrice} from '../product/entities/product-history-price.ent
|
|||
import axios from 'axios';
|
||||
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
||||
import { CallbackPartner } from './entities/callback-partner.entity';
|
||||
import { doAuthorizeHemat } from '../helper/sihemat-authorization';
|
||||
|
||||
@Injectable()
|
||||
export class TransactionService {
|
||||
|
@ -165,7 +177,9 @@ export class TransactionService {
|
|||
currentUser.userId,
|
||||
coaType.ACCOUNT_RECEIVABLE,
|
||||
);
|
||||
console.log('coamsk1', 'coa')
|
||||
|
||||
console.log('coamsk1', 'coa');
|
||||
|
||||
const coaWallet = await this.coaService.findByUser(
|
||||
distributeTransactionDto.destination,
|
||||
coaType.WALLET,
|
||||
|
@ -227,7 +241,8 @@ export class TransactionService {
|
|||
);
|
||||
|
||||
// GET COA
|
||||
console.log('coamsk2', 'coa')
|
||||
console.log('coamsk2', 'coa');
|
||||
|
||||
const coaSenderWallet = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
coaType.WALLET,
|
||||
|
@ -239,7 +254,8 @@ export class TransactionService {
|
|||
coaType.ACCOUNT_PAYABLE,
|
||||
);
|
||||
|
||||
console.log('coamsk3', 'coa')
|
||||
console.log('coamsk3', 'coa');
|
||||
|
||||
const coaReceiverWallet = await this.coaService.findByUser(
|
||||
distributeTransactionDto.destination,
|
||||
coaType.WALLET,
|
||||
|
@ -307,10 +323,10 @@ export class TransactionService {
|
|||
orderTransactionDto: OrderTransactionDto,
|
||||
currentUser: any,
|
||||
) {
|
||||
|
||||
const productData = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
// if (!productData.statusHistory.status.includes('ACTIVE')) {
|
||||
|
@ -341,7 +357,7 @@ export class TransactionService {
|
|||
const product = await this.productService.findOneActive(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
orderTransactionDto.productId
|
||||
orderTransactionDto.productId,
|
||||
);
|
||||
|
||||
const product_price = await this.productHistoryPriceService.findOne(
|
||||
|
@ -353,7 +369,8 @@ export class TransactionService {
|
|||
let profit = product_price.mark_up_price;
|
||||
|
||||
//GET COA
|
||||
console.log('coamsk4', 'coa')
|
||||
console.log('coamsk4', 'coa');
|
||||
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
coaType.WALLET,
|
||||
|
@ -468,10 +485,10 @@ export class TransactionService {
|
|||
orderTransactionDto: OrderTransactionDto,
|
||||
currentUser: any,
|
||||
) {
|
||||
|
||||
const productData = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
// if (!productData.statusHistory.status.includes('ACTIVE')) {
|
||||
|
@ -496,21 +513,23 @@ export class TransactionService {
|
|||
const product = await this.productService.findOneActive(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
orderTransactionDto.productId
|
||||
orderTransactionDto.productId,
|
||||
);
|
||||
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
product.supplier.code,
|
||||
);
|
||||
|
||||
console.log('userdatapartnerid', userData.partner?.id)
|
||||
console.log('userdatapartnerid', userData.partner?.id);
|
||||
|
||||
let product_price = await this.productHistoryPriceService.findOne(
|
||||
product.id,
|
||||
userData.partner?.id,
|
||||
);
|
||||
|
||||
//GET COA
|
||||
console.log('coamsk5', product_price.id)
|
||||
console.log('coamsk5', product_price.id);
|
||||
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
coaType.WALLET,
|
||||
|
@ -532,9 +551,10 @@ export class TransactionService {
|
|||
try {
|
||||
const billId = await this.checkBillHistoryRepository.findOneOrFail({
|
||||
where: {
|
||||
trx_id: orderTransactionDto.bill_trx_id
|
||||
trx_id: orderTransactionDto.bill_trx_id,
|
||||
},
|
||||
});
|
||||
|
||||
product_price.price = billId.amount;
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
|
@ -569,11 +589,18 @@ export class TransactionService {
|
|||
})
|
||||
.join('');
|
||||
|
||||
const hitLoginHemat =
|
||||
supplier.code == 'Hemat' ?
|
||||
await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier) :
|
||||
'';
|
||||
|
||||
let hitSupplier = await doTransaction(
|
||||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||
);
|
||||
// let hitSupplier;
|
||||
|
||||
|
@ -586,7 +613,9 @@ export class TransactionService {
|
|||
),
|
||||
msg: hitSupplier,
|
||||
};
|
||||
|
||||
hitSupplier = newHitSupplier;
|
||||
|
||||
if (orderTransactionDto.bill_trx_id !== null) {
|
||||
hitSupplier.harga = product_price.price;
|
||||
}
|
||||
|
@ -605,10 +634,11 @@ export class TransactionService {
|
|||
|
||||
if (hitSupplier.harga != undefined) {
|
||||
if (hitSupplier.harga != product_price.price) {
|
||||
console.log("priceupdate1supplier", hitSupplier.harga)
|
||||
console.log("priceupdate1normal", product_price.price)
|
||||
console.log('priceupdate1supplier', hitSupplier.harga);
|
||||
console.log('priceupdate1normal', product_price.price);
|
||||
product_price.endDate = new Date();
|
||||
costInventory = hitSupplier.harga;
|
||||
|
||||
const listActivePrice =
|
||||
await this.productHistoryPriceService.getAllActivePriceByProduct(
|
||||
product.id,
|
||||
|
@ -632,6 +662,7 @@ export class TransactionService {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
//TRANSACTION DATA
|
||||
await this.connection.transaction(async (manager) => {
|
||||
|
@ -647,7 +678,8 @@ export class TransactionService {
|
|||
transactionData.partner_trx_id = orderTransactionDto.trx_id;
|
||||
transactionData.supplier_trx_id = trxId;
|
||||
transactionData.check_bill = orderTransactionDto.bill_trx_id;
|
||||
transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory;
|
||||
transactionData.balance_remaining =
|
||||
coaAccount.amount - product_price.mark_up_price - costInventory;
|
||||
|
||||
if (!hitSupplier.success) {
|
||||
transactionData.status = statusTransaction.FAILED;
|
||||
|
@ -722,19 +754,21 @@ export class TransactionService {
|
|||
const product = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
'postpaid',
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
product.supplier.code,
|
||||
);
|
||||
|
||||
let product_price = await this.productHistoryPriceService.findOne(
|
||||
const product_price = await this.productHistoryPriceService.findOne(
|
||||
product.id,
|
||||
userData.partner?.id,
|
||||
);
|
||||
|
||||
//GET COA
|
||||
console.log('coamsk6', 'coa')
|
||||
console.log('coamsk6', 'coa');
|
||||
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
coaType.WALLET,
|
||||
|
@ -770,15 +804,23 @@ export class TransactionService {
|
|||
})
|
||||
.join('');
|
||||
|
||||
const hitLoginHemat =
|
||||
supplier.code == 'Hemat' ?
|
||||
await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier) :
|
||||
'';
|
||||
|
||||
let hitSupplier = await doTransaction(
|
||||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
product
|
||||
);
|
||||
|
||||
if (supplier.code != 'IRS') {
|
||||
const parsingResponse = hitSupplier.split(' ');
|
||||
|
||||
hitSupplier = {
|
||||
success: hitSupplier.includes('diproses'),
|
||||
harga: parseInt(
|
||||
|
@ -886,13 +928,14 @@ export class TransactionService {
|
|||
const product = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
'postpaid',
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
product.supplier.code,
|
||||
);
|
||||
|
||||
let product_price = await this.productHistoryPriceService.findOne(
|
||||
const product_price = await this.productHistoryPriceService.findOne(
|
||||
product.id,
|
||||
userData.partner?.id,
|
||||
);
|
||||
|
@ -907,13 +950,21 @@ export class TransactionService {
|
|||
let status;
|
||||
|
||||
try {
|
||||
const hitLoginHemat =
|
||||
supplier.code == 'Hemat' ?
|
||||
await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier) :
|
||||
'';
|
||||
|
||||
let hitSupplier = await doTransaction(
|
||||
'CEK' + orderTransactionDto.productCode.slice(3),
|
||||
`CEK${orderTransactionDto.productCode.slice(3)}`,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
hitLoginHemat.data,
|
||||
'INQUIRY'
|
||||
);
|
||||
const parsingResponse = hitSupplier.split(' ');
|
||||
|
||||
hitSupplier = {
|
||||
success: hitSupplier.includes('diproses'),
|
||||
msg: hitSupplier,
|
||||
|
@ -1077,9 +1128,9 @@ export class TransactionService {
|
|||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
transactionData.status =
|
||||
statusApproval === 'Accept'
|
||||
? statusTransaction.APPROVED
|
||||
: statusTransaction.REJECTED;
|
||||
statusApproval === 'Accept' ?
|
||||
statusTransaction.APPROVED :
|
||||
statusTransaction.REJECTED;
|
||||
await manager.save(transactionData);
|
||||
|
||||
await this.accountingTransaction({
|
||||
|
@ -1109,9 +1160,8 @@ export class TransactionService {
|
|||
}
|
||||
|
||||
async checkCallbackOrderFailed(supplier_trx_id: string, callback: any) {
|
||||
|
||||
const transactionData = await this.findDataTransactionBySupplierTrxId(
|
||||
supplier_trx_id
|
||||
supplier_trx_id,
|
||||
);
|
||||
|
||||
if (transactionData.status == statusTransaction.FAILED) {
|
||||
|
@ -1144,15 +1194,12 @@ export class TransactionService {
|
|||
},
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async checkCallbackOrderSuccess(supplier_trx_id: string, callback: any) {
|
||||
|
||||
const transactionData = await this.findDataTransactionBySupplierTrxId(
|
||||
supplier_trx_id
|
||||
supplier_trx_id,
|
||||
);
|
||||
|
||||
if (transactionData.status == statusTransaction.FAILED) {
|
||||
|
@ -1172,9 +1219,7 @@ export class TransactionService {
|
|||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
} else {
|
||||
|
||||
const updateTransaction =
|
||||
await this.callbackOrderSuccess(
|
||||
const updateTransaction = await this.callbackOrderSuccess(
|
||||
supplier_trx_id,
|
||||
callback,
|
||||
);
|
||||
|
@ -1187,9 +1232,7 @@ export class TransactionService {
|
|||
},
|
||||
HttpStatus.OK,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findDataTransactionBySupplierTrxId(supplier_trx_id: string) {
|
||||
|
@ -1242,19 +1285,21 @@ export class TransactionService {
|
|||
product_price.product.id,
|
||||
);
|
||||
|
||||
console.log("inipricetable", dataTransaction.product_price.price)
|
||||
console.log("inipricecallback", callback['price'])
|
||||
console.log('inipricetable', dataTransaction.product_price.price);
|
||||
console.log('inipricecallback', callback['price']);
|
||||
|
||||
if (callback['message']) {
|
||||
if (callback['message'].includes('METRO')) {
|
||||
if (callback['price'] != dataTransaction.product_price.price) {
|
||||
console.log("mskupdt", "msk")
|
||||
dataTransaction.product_price.price = parseInt(callback['price'])
|
||||
console.log('mskupdt', 'msk');
|
||||
dataTransaction.product_price.price = parseInt(callback['price']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//GET COA
|
||||
console.log('coamsk7', 'coa')
|
||||
console.log('coamsk7', 'coa');
|
||||
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
coaType.WALLET,
|
||||
|
@ -1263,7 +1308,8 @@ export class TransactionService {
|
|||
dataTransaction.status = statusTransaction.FAILED;
|
||||
dataTransaction.callback_json = callback;
|
||||
dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`;
|
||||
dataTransaction.balance_remaining = coaAccount.amount + dataTransaction.amount;
|
||||
dataTransaction.balance_remaining =
|
||||
coaAccount.amount + dataTransaction.amount;
|
||||
|
||||
const coaInventory = await this.coaService.findByName(
|
||||
`${coaType[coaType.INVENTORY]}-${product.supplier.code}`,
|
||||
|
@ -1313,6 +1359,7 @@ export class TransactionService {
|
|||
|
||||
if (userData.partner) {
|
||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`;
|
||||
|
||||
this.callbackToPartner(
|
||||
userData.partner.id,
|
||||
message,
|
||||
|
@ -1341,25 +1388,28 @@ export class TransactionService {
|
|||
});
|
||||
|
||||
dataTransaction.status = statusTransaction.SUCCESS;
|
||||
|
||||
if (callback['sn']) {
|
||||
dataTransaction.seri_number = callback['sn'];
|
||||
console.log("msksn1", dataTransaction.seri_number)
|
||||
console.log('msksn1', dataTransaction.seri_number);
|
||||
} else {
|
||||
const response = callback['message'];
|
||||
const responseBaru = response.split(' ');
|
||||
|
||||
dataTransaction.seri_number =
|
||||
responseBaru[10].length > 1 ? responseBaru[10] : responseBaru[9];
|
||||
|
||||
if (dataTransaction.seri_number == 'SN:') {
|
||||
dataTransaction.seri_number = responseBaru[11]
|
||||
dataTransaction.seri_number = responseBaru[11];
|
||||
}
|
||||
}
|
||||
|
||||
dataTransaction.callback_json = callback;
|
||||
|
||||
if (callback['message']) {
|
||||
if (callback['message'].includes('METRO')) {
|
||||
if (callback['price'] != dataTransaction.product_price.price) {
|
||||
dataProductHistoryPrice.price = parseInt(callback['price'])
|
||||
dataProductHistoryPrice.price = parseInt(callback['price']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1386,7 +1436,7 @@ export class TransactionService {
|
|||
// dataTransaction.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory;
|
||||
|
||||
if (userData.partner == null) {
|
||||
console.log('partnernull', 'masuk')
|
||||
console.log('partnernull', 'masuk');
|
||||
//GET SALES
|
||||
supervisorData = await this.calculateCommission(
|
||||
supervisorData,
|
||||
|
@ -1412,7 +1462,7 @@ export class TransactionService {
|
|||
try {
|
||||
await this.connection.transaction(async (manager) => {
|
||||
await manager.save(dataTransaction);
|
||||
await manager.save(dataProductHistoryPrice)
|
||||
await manager.save(dataProductHistoryPrice);
|
||||
|
||||
await this.accountingTransaction({
|
||||
createTransaction: false,
|
||||
|
@ -1425,10 +1475,13 @@ export class TransactionService {
|
|||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (userData.partner != null) {
|
||||
if (userData.partner) {
|
||||
console.log('partnernotnull', 'masuk')
|
||||
console.log('partnernotnull', 'masuk');
|
||||
|
||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
|
||||
|
||||
this.callbackToPartner(
|
||||
userData.partner.id,
|
||||
message,
|
||||
|
@ -1463,6 +1516,7 @@ export class TransactionService {
|
|||
|
||||
if (status) {
|
||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
|
||||
|
||||
await this.callbackToPartner(
|
||||
userData.partner.id,
|
||||
message,
|
||||
|
@ -1475,6 +1529,7 @@ export class TransactionService {
|
|||
);
|
||||
} else {
|
||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`;
|
||||
|
||||
this.callbackToPartner(
|
||||
userData.partner.id,
|
||||
message,
|
||||
|
@ -1486,8 +1541,6 @@ export class TransactionService {
|
|||
'gagal',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async callbackToPartner(
|
||||
|
@ -1503,7 +1556,8 @@ export class TransactionService {
|
|||
const partnerData = await this.userService.findPartner(partnerId);
|
||||
const userData = await this.userService.findOneByPartner(partnerId);
|
||||
|
||||
console.log('coamsk8', 'coa')
|
||||
console.log('coamsk8', 'coa');
|
||||
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
coaType.WALLET,
|
||||
|
@ -1511,6 +1565,7 @@ export class TransactionService {
|
|||
|
||||
if (!partnerData.callback_url) {
|
||||
this.logger.error(`Call to partner failed, reason: no callback url`);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1527,6 +1582,7 @@ export class TransactionService {
|
|||
return res;
|
||||
} catch (e) {
|
||||
this.logger.error(`Call to partner failed, reason: ${e.message}`);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1540,7 +1596,7 @@ export class TransactionService {
|
|||
// });
|
||||
|
||||
if (trxId.length % 2 != 0) {
|
||||
throw Error("Not Balance")
|
||||
throw Error('Not Balance');
|
||||
}
|
||||
|
||||
const dataTransactionJurnal = await this.transactionJournalRepository.find({
|
||||
|
@ -1550,10 +1606,10 @@ export class TransactionService {
|
|||
relations: ['coa'],
|
||||
});
|
||||
|
||||
let dataRollbackJurnal = [];
|
||||
const dataRollbackJurnal = [];
|
||||
|
||||
dataTransactionJurnal.map((it) => {
|
||||
let data = {
|
||||
const data = {
|
||||
coa_id: it.coa.id,
|
||||
};
|
||||
|
||||
|
@ -1586,7 +1642,8 @@ export class TransactionService {
|
|||
async withdrawBenefit(user) {
|
||||
const userData = await this.userService.findExist(user);
|
||||
|
||||
console.log('coamsk9', 'coa')
|
||||
console.log('coamsk9', 'coa');
|
||||
|
||||
const coaProfit = await this.coaService.findByUser(user, coaType.PROFIT);
|
||||
|
||||
const coaBank = await this.coaService.findByName(
|
||||
|
@ -1762,7 +1819,7 @@ export class TransactionService {
|
|||
take: pageSize || 10,
|
||||
order: {
|
||||
createdAt: 'DESC',
|
||||
}
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
throw new HttpException(
|
||||
|
@ -2062,7 +2119,8 @@ export class TransactionService {
|
|||
),
|
||||
);
|
||||
|
||||
console.log('coamsk10', 'coa')
|
||||
console.log('coamsk10', 'coa');
|
||||
|
||||
return Promise.all(
|
||||
supervisorData.map(async (it) => {
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
|
@ -2129,9 +2187,9 @@ export class TransactionService {
|
|||
const journalEntry = new TransactionJournal();
|
||||
|
||||
journalEntry.coa = coa;
|
||||
journalEntry.type = journal.debit
|
||||
? balanceType.DEBIT
|
||||
: balanceType.CREDIT;
|
||||
journalEntry.type = journal.debit ?
|
||||
balanceType.DEBIT :
|
||||
balanceType.CREDIT;
|
||||
journalEntry.amount = journal.debit ? journal.debit : journal.credit;
|
||||
journalEntry.transaction_head = transaction;
|
||||
|
||||
|
@ -2204,7 +2262,9 @@ export class TransactionService {
|
|||
message: string,
|
||||
) {
|
||||
const billData = await this.findOneBillById(trxId);
|
||||
console.log(billData,"ini dia")
|
||||
|
||||
console.log(billData, 'ini dia');
|
||||
|
||||
const userData = await this.userService.findExist(billData.user);
|
||||
|
||||
const product_price = await this.productHistoryPriceService.findById(
|
||||
|
@ -2216,12 +2276,12 @@ export class TransactionService {
|
|||
trx_id: trxId,
|
||||
},
|
||||
{
|
||||
amount: status
|
||||
? amount -
|
||||
amount: status ?
|
||||
amount -
|
||||
admin +
|
||||
product_price.partner_fee +
|
||||
product_price.mark_up_price
|
||||
: 0,
|
||||
product_price.mark_up_price :
|
||||
0,
|
||||
admin_price: admin,
|
||||
status: status ? 'SUCCESS' : 'FAILED',
|
||||
callback_json: JSON.stringify(message),
|
||||
|
@ -2229,12 +2289,13 @@ export class TransactionService {
|
|||
);
|
||||
|
||||
if (userData.partner) {
|
||||
const message = status
|
||||
? `Bill dari ${billData.destination} adalah ${
|
||||
const message = status ?
|
||||
`Bill dari ${billData.destination} adalah ${
|
||||
amount + product_price.partner_fee + product_price.mark_up_price
|
||||
}.`
|
||||
: '';
|
||||
}.` :
|
||||
'';
|
||||
const statusResponse = status ? 'berhasil' : 'gagal';
|
||||
|
||||
this.callbackToPartner(
|
||||
userData.id,
|
||||
message,
|
||||
|
|
Loading…
Reference in New Issue
Block a user