Merge branch 'master' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-production
This commit is contained in:
commit
90625c9e5b
|
@ -11,25 +11,49 @@ export const doTransaction = async (
|
||||||
destination,
|
destination,
|
||||||
idtrx,
|
idtrx,
|
||||||
supplier,
|
supplier,
|
||||||
|
authorization,
|
||||||
|
typePaid,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
if(supplier.code == 'IRS'){
|
if (supplier.code == 'IRS') {
|
||||||
const res = await axios.get(
|
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}`,
|
`${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;
|
return res.data;
|
||||||
} else if (supplier.code == 'NIRS') {
|
} else if (supplier.code == 'NIRS') {
|
||||||
const res = await axios.get(
|
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}`,
|
`${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;
|
return res.data;
|
||||||
} else {
|
} else if (supplier.code == 'Hemat') {
|
||||||
|
if (authorization != "") {
|
||||||
|
console.log("initoken", authorization)
|
||||||
|
const options = {
|
||||||
|
headers: {'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + authorization}
|
||||||
|
};
|
||||||
|
const data = {
|
||||||
|
idtransaction: idtrx,
|
||||||
|
destination: `${destination}`,
|
||||||
|
code: `${productCode}`,
|
||||||
|
type: `${typePaid}`,
|
||||||
|
};
|
||||||
|
const res = await axios.post(`${supplier.url}/v1/transaction/request`, data, options);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const res = await axios.get(
|
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}`,
|
`${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;
|
return res.data;
|
||||||
}
|
console.log('restranshemat', res)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log('errtranshemat', err.response.data);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
16
src/helper/sihemat-authorization.ts
Normal file
16
src/helper/sihemat-authorization.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
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}/authenticate`, data);
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
} catch (err) {
|
||||||
|
console.log('errauthhemat', 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 {
|
try {
|
||||||
return await this.productRepository.findOneOrFail({
|
return await this.productRepository.findOneOrFail({
|
||||||
relations: ['supplier'],
|
relations: ['supplier'],
|
||||||
where: {
|
where: {
|
||||||
code: code,
|
code: code,
|
||||||
|
id: productId
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -635,16 +636,16 @@ export class ProductService {
|
||||||
code: string,
|
code: string,
|
||||||
updatePriceProductDto: UpdatePriceProductDto,
|
updatePriceProductDto: UpdatePriceProductDto,
|
||||||
) {
|
) {
|
||||||
const product = await this.findOne(code, updatePriceProductDto.productType);
|
// const product = await this.findOne(code, updatePriceProductDto.productType);
|
||||||
|
|
||||||
await this.productHistoryPrice.insert({
|
// await this.productHistoryPrice.insert({
|
||||||
product: product,
|
// product: product,
|
||||||
type: updatePriceProductDto.type,
|
// type: updatePriceProductDto.type,
|
||||||
price: updatePriceProductDto.price,
|
// price: updatePriceProductDto.price,
|
||||||
mark_up_price: updatePriceProductDto.markUpPrice,
|
// mark_up_price: updatePriceProductDto.markUpPrice,
|
||||||
startDate: updatePriceProductDto.startDate,
|
// startDate: updatePriceProductDto.startDate,
|
||||||
endDate: updatePriceProductDto.endDate,
|
// endDate: updatePriceProductDto.endDate,
|
||||||
});
|
// });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,42 @@
|
||||||
import {HttpException, HttpStatus, Injectable, Logger} from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
|
||||||
import {DistributeTransactionDto} from './dto/distribute-transaction.dto';
|
import { DistributeTransactionDto } from './dto/distribute-transaction.dto';
|
||||||
import {OrderTransactionDto} from './dto/order-transaction.dto';
|
import { OrderTransactionDto } from './dto/order-transaction.dto';
|
||||||
import {InjectRepository} from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import {Transactions} from './entities/transactions.entity';
|
import { Transactions } from './entities/transactions.entity';
|
||||||
import {Between, Connection, EntityNotFoundError, In, Repository} from 'typeorm';
|
import {
|
||||||
import {COA} from './entities/coa.entity';
|
Between,
|
||||||
import {TransactionJournal} from './entities/transaction-journal.entity';
|
Connection,
|
||||||
import {CoaService} from './coa.service';
|
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 * as uuid from 'uuid';
|
||||||
import {uniq} from 'lodash';
|
import { uniq } from 'lodash';
|
||||||
import {Decimal} from 'decimal.js';
|
import { Decimal } from 'decimal.js';
|
||||||
import {balanceType, coaType, statusTransaction, typeTransaction,} from '../helper/enum-list';
|
import {
|
||||||
import {ProductService} from '../product/product.service';
|
balanceType,
|
||||||
import {CreateJournalDto} from './dto/create-journal.dto';
|
coaType,
|
||||||
import {UsersService} from 'src/users/users.service';
|
statusTransaction,
|
||||||
import {AddSaldoSupplier} from './dto/add-saldo-supplier.dto';
|
typeTransaction,
|
||||||
import {SupplierService} from '../users/supplier/supplier.service';
|
} from '../helper/enum-list';
|
||||||
import {ProductHistoryPriceService} from '../product/history-price/history-price.service';
|
import { ProductService } from '../product/product.service';
|
||||||
import {CommissionService} from '../configurable/commission.service';
|
import { CreateJournalDto } from './dto/create-journal.dto';
|
||||||
import {DepositReturnDto} from './dto/deposit_return.dto';
|
import { UsersService } from 'src/users/users.service';
|
||||||
import {UserDetail} from '../users/entities/user_detail.entity';
|
import { AddSaldoSupplier } from './dto/add-saldo-supplier.dto';
|
||||||
import {doTransaction} from '../helper/irs-api';
|
import { SupplierService } from '../users/supplier/supplier.service';
|
||||||
import {ProductHistoryPrice} from '../product/entities/product-history-price.entity';
|
import { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
||||||
|
import { CommissionService } from '../configurable/commission.service';
|
||||||
|
import { DepositReturnDto } from './dto/deposit_return.dto';
|
||||||
|
import { UserDetail } from '../users/entities/user_detail.entity';
|
||||||
|
import { doTransaction } from '../helper/irs-api';
|
||||||
|
import { ProductHistoryPrice } from '../product/entities/product-history-price.entity';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {CheckBillHistory} from './entities/check-bill-history.entity';
|
import { CheckBillHistory } from './entities/check-bill-history.entity';
|
||||||
import {CallbackPartner} from './entities/callback-partner.entity';
|
import { CallbackPartner } from './entities/callback-partner.entity';
|
||||||
|
import { doAuthorizeHemat } from '../helper/sihemat-authorization';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TransactionService {
|
export class TransactionService {
|
||||||
|
@ -165,7 +177,9 @@ export class TransactionService {
|
||||||
currentUser.userId,
|
currentUser.userId,
|
||||||
coaType.ACCOUNT_RECEIVABLE,
|
coaType.ACCOUNT_RECEIVABLE,
|
||||||
);
|
);
|
||||||
console.log('coamsk1', 'coa')
|
|
||||||
|
console.log('coamsk1', 'coa');
|
||||||
|
|
||||||
const coaWallet = await this.coaService.findByUser(
|
const coaWallet = await this.coaService.findByUser(
|
||||||
distributeTransactionDto.destination,
|
distributeTransactionDto.destination,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -227,7 +241,8 @@ export class TransactionService {
|
||||||
);
|
);
|
||||||
|
|
||||||
// GET COA
|
// GET COA
|
||||||
console.log('coamsk2', 'coa')
|
console.log('coamsk2', 'coa');
|
||||||
|
|
||||||
const coaSenderWallet = await this.coaService.findByUser(
|
const coaSenderWallet = await this.coaService.findByUser(
|
||||||
userData.id,
|
userData.id,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -239,7 +254,8 @@ export class TransactionService {
|
||||||
coaType.ACCOUNT_PAYABLE,
|
coaType.ACCOUNT_PAYABLE,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('coamsk3', 'coa')
|
console.log('coamsk3', 'coa');
|
||||||
|
|
||||||
const coaReceiverWallet = await this.coaService.findByUser(
|
const coaReceiverWallet = await this.coaService.findByUser(
|
||||||
distributeTransactionDto.destination,
|
distributeTransactionDto.destination,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -307,10 +323,10 @@ export class TransactionService {
|
||||||
orderTransactionDto: OrderTransactionDto,
|
orderTransactionDto: OrderTransactionDto,
|
||||||
currentUser: any,
|
currentUser: any,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const productData = await this.productService.findOne(
|
const productData = await this.productService.findOne(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid',
|
'prepaid',
|
||||||
|
orderTransactionDto.productId
|
||||||
);
|
);
|
||||||
|
|
||||||
// if (!productData.statusHistory.status.includes('ACTIVE')) {
|
// if (!productData.statusHistory.status.includes('ACTIVE')) {
|
||||||
|
@ -341,7 +357,7 @@ export class TransactionService {
|
||||||
const product = await this.productService.findOneActive(
|
const product = await this.productService.findOneActive(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid',
|
'prepaid',
|
||||||
orderTransactionDto.productId
|
orderTransactionDto.productId,
|
||||||
);
|
);
|
||||||
|
|
||||||
const product_price = await this.productHistoryPriceService.findOne(
|
const product_price = await this.productHistoryPriceService.findOne(
|
||||||
|
@ -353,7 +369,8 @@ export class TransactionService {
|
||||||
let profit = product_price.mark_up_price;
|
let profit = product_price.mark_up_price;
|
||||||
|
|
||||||
//GET COA
|
//GET COA
|
||||||
console.log('coamsk4', 'coa')
|
console.log('coamsk4', 'coa');
|
||||||
|
|
||||||
const coaAccount = await this.coaService.findByUser(
|
const coaAccount = await this.coaService.findByUser(
|
||||||
userData.id,
|
userData.id,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -468,10 +485,10 @@ export class TransactionService {
|
||||||
orderTransactionDto: OrderTransactionDto,
|
orderTransactionDto: OrderTransactionDto,
|
||||||
currentUser: any,
|
currentUser: any,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const productData = await this.productService.findOne(
|
const productData = await this.productService.findOne(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid',
|
'prepaid',
|
||||||
|
orderTransactionDto.productId
|
||||||
);
|
);
|
||||||
|
|
||||||
// if (!productData.statusHistory.status.includes('ACTIVE')) {
|
// if (!productData.statusHistory.status.includes('ACTIVE')) {
|
||||||
|
@ -496,21 +513,23 @@ export class TransactionService {
|
||||||
const product = await this.productService.findOneActive(
|
const product = await this.productService.findOneActive(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid',
|
'prepaid',
|
||||||
orderTransactionDto.productId
|
orderTransactionDto.productId,
|
||||||
);
|
);
|
||||||
|
|
||||||
const supplier = await this.supplierService.findByCode(
|
const supplier = await this.supplierService.findByCode(
|
||||||
product.supplier.code,
|
product.supplier.code,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('userdatapartnerid', userData.partner?.id)
|
console.log('userdatapartnerid', userData.partner?.id);
|
||||||
|
|
||||||
let product_price = await this.productHistoryPriceService.findOne(
|
let product_price = await this.productHistoryPriceService.findOne(
|
||||||
product.id,
|
product.id,
|
||||||
userData.partner?.id,
|
userData.partner?.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
//GET COA
|
//GET COA
|
||||||
console.log('coamsk5', product_price.id)
|
console.log('coamsk5', product_price.id);
|
||||||
|
|
||||||
const coaAccount = await this.coaService.findByUser(
|
const coaAccount = await this.coaService.findByUser(
|
||||||
userData.id,
|
userData.id,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -532,9 +551,10 @@ export class TransactionService {
|
||||||
try {
|
try {
|
||||||
const billId = await this.checkBillHistoryRepository.findOneOrFail({
|
const billId = await this.checkBillHistoryRepository.findOneOrFail({
|
||||||
where: {
|
where: {
|
||||||
trx_id: orderTransactionDto.bill_trx_id
|
trx_id: orderTransactionDto.bill_trx_id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
product_price.price = billId.amount;
|
product_price.price = billId.amount;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof EntityNotFoundError) {
|
if (e instanceof EntityNotFoundError) {
|
||||||
|
@ -569,16 +589,40 @@ export class TransactionService {
|
||||||
})
|
})
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
let hitSupplier = await doTransaction(
|
let hitLoginHemat;
|
||||||
|
|
||||||
|
if (supplier.code == 'Hemat') {
|
||||||
|
hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
let hitSupplier = supplier.code == 'Hemat' ?
|
||||||
|
await doTransaction(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
orderTransactionDto.destination,
|
orderTransactionDto.destination,
|
||||||
trxId,
|
trxId,
|
||||||
supplier,
|
supplier,
|
||||||
|
hitLoginHemat.data,
|
||||||
|
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||||
|
) : await doTransaction(
|
||||||
|
orderTransactionDto.productCode,
|
||||||
|
orderTransactionDto.destination,
|
||||||
|
trxId,
|
||||||
|
supplier,
|
||||||
|
"",
|
||||||
|
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||||
);
|
);
|
||||||
|
|
||||||
// let hitSupplier;
|
// let hitSupplier;
|
||||||
|
|
||||||
if (supplier.code != 'IRS') {
|
console.log('iniresponsupplierharga', hitSupplier)
|
||||||
|
console.log('iniresponsupplier', hitSupplier.harga)
|
||||||
|
console.log(supplier.code, 'sdkfjsd');
|
||||||
|
console.log(product_price, 'price');
|
||||||
|
|
||||||
|
|
||||||
|
if (supplier.code == 'metro') {
|
||||||
const parsingResponse = hitSupplier.split(' ');
|
const parsingResponse = hitSupplier.split(' ');
|
||||||
|
console.log('parsingResponse', parsingResponse)
|
||||||
const newHitSupplier = {
|
const newHitSupplier = {
|
||||||
success: hitSupplier.includes('diproses'),
|
success: hitSupplier.includes('diproses'),
|
||||||
harga: parseInt(
|
harga: parseInt(
|
||||||
|
@ -586,11 +630,28 @@ export class TransactionService {
|
||||||
),
|
),
|
||||||
msg: hitSupplier,
|
msg: hitSupplier,
|
||||||
};
|
};
|
||||||
|
|
||||||
hitSupplier = newHitSupplier;
|
hitSupplier = newHitSupplier;
|
||||||
|
|
||||||
|
if (orderTransactionDto.bill_trx_id !== null) {
|
||||||
|
hitSupplier.harga = product_price.price;
|
||||||
|
}
|
||||||
|
} else if (supplier.code == 'Hemat') {
|
||||||
|
const newHitSupplier = {
|
||||||
|
success: hitSupplier.success,
|
||||||
|
harga: product_price.price,
|
||||||
|
msg: hitSupplier.msg,
|
||||||
|
};
|
||||||
|
|
||||||
|
hitSupplier = newHitSupplier;
|
||||||
|
|
||||||
if (orderTransactionDto.bill_trx_id !== null) {
|
if (orderTransactionDto.bill_trx_id !== null) {
|
||||||
hitSupplier.harga = product_price.price;
|
hitSupplier.harga = product_price.price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(hitSupplier, 'newhitSupplier');
|
||||||
|
|
||||||
// const hitSupplier = {
|
// const hitSupplier = {
|
||||||
// harga: 2000,
|
// harga: 2000,
|
||||||
// success: true,
|
// success: true,
|
||||||
|
@ -605,10 +666,11 @@ export class TransactionService {
|
||||||
|
|
||||||
if (hitSupplier.harga != undefined) {
|
if (hitSupplier.harga != undefined) {
|
||||||
if (hitSupplier.harga != product_price.price) {
|
if (hitSupplier.harga != product_price.price) {
|
||||||
console.log("priceupdate1supplier", hitSupplier.harga)
|
console.log('priceupdate1supplier', hitSupplier.harga);
|
||||||
console.log("priceupdate1normal", product_price.price)
|
console.log('priceupdate1normal', product_price.price);
|
||||||
product_price.endDate = new Date();
|
product_price.endDate = new Date();
|
||||||
costInventory = hitSupplier.harga;
|
costInventory = hitSupplier.harga;
|
||||||
|
|
||||||
const listActivePrice =
|
const listActivePrice =
|
||||||
await this.productHistoryPriceService.getAllActivePriceByProduct(
|
await this.productHistoryPriceService.getAllActivePriceByProduct(
|
||||||
product.id,
|
product.id,
|
||||||
|
@ -632,6 +694,7 @@ export class TransactionService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//TRANSACTION DATA
|
//TRANSACTION DATA
|
||||||
await this.connection.transaction(async (manager) => {
|
await this.connection.transaction(async (manager) => {
|
||||||
|
@ -647,7 +710,8 @@ export class TransactionService {
|
||||||
transactionData.partner_trx_id = orderTransactionDto.trx_id;
|
transactionData.partner_trx_id = orderTransactionDto.trx_id;
|
||||||
transactionData.supplier_trx_id = trxId;
|
transactionData.supplier_trx_id = trxId;
|
||||||
transactionData.check_bill = orderTransactionDto.bill_trx_id;
|
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) {
|
if (!hitSupplier.success) {
|
||||||
transactionData.status = statusTransaction.FAILED;
|
transactionData.status = statusTransaction.FAILED;
|
||||||
|
@ -722,19 +786,21 @@ export class TransactionService {
|
||||||
const product = await this.productService.findOne(
|
const product = await this.productService.findOne(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'postpaid',
|
'postpaid',
|
||||||
|
orderTransactionDto.productId
|
||||||
);
|
);
|
||||||
|
|
||||||
const supplier = await this.supplierService.findByCode(
|
const supplier = await this.supplierService.findByCode(
|
||||||
product.supplier.code,
|
product.supplier.code,
|
||||||
);
|
);
|
||||||
|
|
||||||
let product_price = await this.productHistoryPriceService.findOne(
|
const product_price = await this.productHistoryPriceService.findOne(
|
||||||
product.id,
|
product.id,
|
||||||
userData.partner?.id,
|
userData.partner?.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
//GET COA
|
//GET COA
|
||||||
console.log('coamsk6', 'coa')
|
console.log('coamsk6', 'coa');
|
||||||
|
|
||||||
const coaAccount = await this.coaService.findByUser(
|
const coaAccount = await this.coaService.findByUser(
|
||||||
userData.id,
|
userData.id,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -770,15 +836,32 @@ export class TransactionService {
|
||||||
})
|
})
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
let hitSupplier = await doTransaction(
|
let hitLoginHemat;
|
||||||
|
|
||||||
|
if (supplier.code == 'Hemat') {
|
||||||
|
hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
let hitSupplier = supplier.code == 'Hemat' ?
|
||||||
|
await doTransaction(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
orderTransactionDto.destination,
|
orderTransactionDto.destination,
|
||||||
trxId,
|
trxId,
|
||||||
supplier,
|
supplier,
|
||||||
|
hitLoginHemat.data,
|
||||||
|
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||||
|
) : await doTransaction(
|
||||||
|
orderTransactionDto.productCode,
|
||||||
|
orderTransactionDto.destination,
|
||||||
|
trxId,
|
||||||
|
supplier,
|
||||||
|
"",
|
||||||
|
product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (supplier.code != 'IRS') {
|
if (supplier.code != 'IRS') {
|
||||||
const parsingResponse = hitSupplier.split(' ');
|
const parsingResponse = hitSupplier.split(' ');
|
||||||
|
|
||||||
hitSupplier = {
|
hitSupplier = {
|
||||||
success: hitSupplier.includes('diproses'),
|
success: hitSupplier.includes('diproses'),
|
||||||
harga: parseInt(
|
harga: parseInt(
|
||||||
|
@ -886,13 +969,14 @@ export class TransactionService {
|
||||||
const product = await this.productService.findOne(
|
const product = await this.productService.findOne(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'postpaid',
|
'postpaid',
|
||||||
|
orderTransactionDto.productId
|
||||||
);
|
);
|
||||||
|
|
||||||
const supplier = await this.supplierService.findByCode(
|
const supplier = await this.supplierService.findByCode(
|
||||||
product.supplier.code,
|
product.supplier.code,
|
||||||
);
|
);
|
||||||
|
|
||||||
let product_price = await this.productHistoryPriceService.findOne(
|
const product_price = await this.productHistoryPriceService.findOne(
|
||||||
product.id,
|
product.id,
|
||||||
userData.partner?.id,
|
userData.partner?.id,
|
||||||
);
|
);
|
||||||
|
@ -907,18 +991,43 @@ export class TransactionService {
|
||||||
let status;
|
let status;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let hitSupplier = await doTransaction(
|
|
||||||
'CEK' + orderTransactionDto.productCode.slice(3),
|
let hitLoginHemat;
|
||||||
|
|
||||||
|
if (supplier.code == 'Hemat') {
|
||||||
|
hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
let hitSupplier = supplier.code == 'Hemat' ? await doTransaction(
|
||||||
|
orderTransactionDto.productCode,
|
||||||
orderTransactionDto.destination,
|
orderTransactionDto.destination,
|
||||||
trxId,
|
trxId,
|
||||||
supplier,
|
supplier,
|
||||||
|
hitLoginHemat.data,
|
||||||
|
'INQUIRY'
|
||||||
|
) : await doTransaction(
|
||||||
|
`CEK${orderTransactionDto.productCode.slice(3)}`,
|
||||||
|
orderTransactionDto.destination,
|
||||||
|
trxId,
|
||||||
|
supplier,
|
||||||
|
"",
|
||||||
|
'INQUIRY'
|
||||||
);
|
);
|
||||||
const parsingResponse = hitSupplier.split(' ');
|
// const parsingResponse = hitSupplier.split(' ');
|
||||||
|
|
||||||
|
if (supplier.code == 'Hemat') {
|
||||||
|
hitSupplier = {
|
||||||
|
success: hitSupplier.success == true,
|
||||||
|
msg: hitSupplier.msg,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
hitSupplier = {
|
hitSupplier = {
|
||||||
success: hitSupplier.includes('diproses'),
|
success: hitSupplier.includes('diproses'),
|
||||||
msg: hitSupplier,
|
msg: hitSupplier,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
console.log('inidatacheckbill', hitSupplier)
|
||||||
|
console.log('statushitsupplier', hitSupplier.success)
|
||||||
if (!hitSupplier.success) {
|
if (!hitSupplier.success) {
|
||||||
status = statusTransaction[statusTransaction.FAILED];
|
status = statusTransaction[statusTransaction.FAILED];
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
|
@ -1077,9 +1186,9 @@ export class TransactionService {
|
||||||
try {
|
try {
|
||||||
await this.connection.transaction(async (manager) => {
|
await this.connection.transaction(async (manager) => {
|
||||||
transactionData.status =
|
transactionData.status =
|
||||||
statusApproval === 'Accept'
|
statusApproval === 'Accept' ?
|
||||||
? statusTransaction.APPROVED
|
statusTransaction.APPROVED :
|
||||||
: statusTransaction.REJECTED;
|
statusTransaction.REJECTED;
|
||||||
await manager.save(transactionData);
|
await manager.save(transactionData);
|
||||||
|
|
||||||
await this.accountingTransaction({
|
await this.accountingTransaction({
|
||||||
|
@ -1109,28 +1218,29 @@ export class TransactionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkCallbackOrderFailed(supplier_trx_id: string, callback: any) {
|
async checkCallbackOrderFailed(supplier_trx_id: string, callback: any) {
|
||||||
|
|
||||||
const transactionData = await this.findDataTransactionBySupplierTrxId(
|
const transactionData = await this.findDataTransactionBySupplierTrxId(
|
||||||
supplier_trx_id
|
supplier_trx_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (transactionData.status == statusTransaction.FAILED) {
|
// if (transactionData.status == statusTransaction.FAILED) {
|
||||||
throw new HttpException(
|
// throw new HttpException(
|
||||||
{
|
// {
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
// statusCode: HttpStatus.BAD_REQUEST,
|
||||||
error: 'failed to update, the transaction already failed',
|
// error: 'failed to update, the transaction already failed',
|
||||||
},
|
// },
|
||||||
HttpStatus.BAD_REQUEST,
|
// HttpStatus.BAD_REQUEST,
|
||||||
);
|
// );
|
||||||
} else if (transactionData.status == statusTransaction.SUCCESS) {
|
// } else if (transactionData.status == statusTransaction.SUCCESS) {
|
||||||
throw new HttpException(
|
// throw new HttpException(
|
||||||
{
|
// {
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
// statusCode: HttpStatus.BAD_REQUEST,
|
||||||
error: 'failed to update, the transaction already success',
|
// error: 'failed to update, the transaction already success',
|
||||||
},
|
// },
|
||||||
HttpStatus.BAD_REQUEST,
|
// HttpStatus.BAD_REQUEST,
|
||||||
);
|
// );
|
||||||
} else {
|
// } else {
|
||||||
|
|
||||||
|
|
||||||
const updateTransaction = await this.callbackOrderFailed(
|
const updateTransaction = await this.callbackOrderFailed(
|
||||||
supplier_trx_id,
|
supplier_trx_id,
|
||||||
callback,
|
callback,
|
||||||
|
@ -1144,37 +1254,32 @@ export class TransactionService {
|
||||||
},
|
},
|
||||||
HttpStatus.BAD_REQUEST,
|
HttpStatus.BAD_REQUEST,
|
||||||
);
|
);
|
||||||
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkCallbackOrderSuccess(supplier_trx_id: string, callback: any) {
|
async checkCallbackOrderSuccess(supplier_trx_id: string, callback: any) {
|
||||||
|
|
||||||
const transactionData = await this.findDataTransactionBySupplierTrxId(
|
const transactionData = await this.findDataTransactionBySupplierTrxId(
|
||||||
supplier_trx_id
|
supplier_trx_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (transactionData.status == statusTransaction.FAILED) {
|
// if (transactionData.status == statusTransaction.FAILED) {
|
||||||
throw new HttpException(
|
// throw new HttpException(
|
||||||
{
|
// {
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
// statusCode: HttpStatus.BAD_REQUEST,
|
||||||
error: 'failed to update, the transaction already failed',
|
// error: 'failed to update, the transaction already failed',
|
||||||
},
|
// },
|
||||||
HttpStatus.BAD_REQUEST,
|
// HttpStatus.BAD_REQUEST,
|
||||||
);
|
// );
|
||||||
} else if (transactionData.status == statusTransaction.SUCCESS) {
|
// } else if (transactionData.status == statusTransaction.SUCCESS) {
|
||||||
throw new HttpException(
|
// throw new HttpException(
|
||||||
{
|
// {
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
// statusCode: HttpStatus.BAD_REQUEST,
|
||||||
error: 'failed to update, the transaction already success',
|
// error: 'failed to update, the transaction already success',
|
||||||
},
|
// },
|
||||||
HttpStatus.BAD_REQUEST,
|
// HttpStatus.BAD_REQUEST,
|
||||||
);
|
// );
|
||||||
} else {
|
// } else {
|
||||||
|
const updateTransaction = await this.callbackOrderSuccess(
|
||||||
const updateTransaction =
|
|
||||||
await this.callbackOrderSuccess(
|
|
||||||
supplier_trx_id,
|
supplier_trx_id,
|
||||||
callback,
|
callback,
|
||||||
);
|
);
|
||||||
|
@ -1187,9 +1292,7 @@ export class TransactionService {
|
||||||
},
|
},
|
||||||
HttpStatus.OK,
|
HttpStatus.OK,
|
||||||
);
|
);
|
||||||
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async findDataTransactionBySupplierTrxId(supplier_trx_id: string) {
|
async findDataTransactionBySupplierTrxId(supplier_trx_id: string) {
|
||||||
|
@ -1242,19 +1345,21 @@ export class TransactionService {
|
||||||
product_price.product.id,
|
product_price.product.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("inipricetable", dataTransaction.product_price.price)
|
console.log('inipricetable', dataTransaction.product_price.price);
|
||||||
console.log("inipricecallback", callback['price'])
|
console.log('inipricecallback', callback['price']);
|
||||||
if(callback['message']) {
|
|
||||||
|
if (callback['message']) {
|
||||||
if (callback['message'].includes('METRO')) {
|
if (callback['message'].includes('METRO')) {
|
||||||
if (callback['price'] != dataTransaction.product_price.price) {
|
if (callback['price'] != dataTransaction.product_price.price) {
|
||||||
console.log("mskupdt", "msk")
|
console.log('mskupdt', 'msk');
|
||||||
dataTransaction.product_price.price = parseInt(callback['price'])
|
dataTransaction.product_price.price = parseInt(callback['price']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//GET COA
|
//GET COA
|
||||||
console.log('coamsk7', 'coa')
|
console.log('coamsk7', 'coa');
|
||||||
|
|
||||||
const coaAccount = await this.coaService.findByUser(
|
const coaAccount = await this.coaService.findByUser(
|
||||||
userData.id,
|
userData.id,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -1263,7 +1368,8 @@ export class TransactionService {
|
||||||
dataTransaction.status = statusTransaction.FAILED;
|
dataTransaction.status = statusTransaction.FAILED;
|
||||||
dataTransaction.callback_json = callback;
|
dataTransaction.callback_json = callback;
|
||||||
dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`;
|
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(
|
const coaInventory = await this.coaService.findByName(
|
||||||
`${coaType[coaType.INVENTORY]}-${product.supplier.code}`,
|
`${coaType[coaType.INVENTORY]}-${product.supplier.code}`,
|
||||||
|
@ -1313,6 +1419,7 @@ export class TransactionService {
|
||||||
|
|
||||||
if (userData.partner) {
|
if (userData.partner) {
|
||||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`;
|
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`;
|
||||||
|
|
||||||
this.callbackToPartner(
|
this.callbackToPartner(
|
||||||
userData.partner.id,
|
userData.partner.id,
|
||||||
message,
|
message,
|
||||||
|
@ -1341,25 +1448,28 @@ export class TransactionService {
|
||||||
});
|
});
|
||||||
|
|
||||||
dataTransaction.status = statusTransaction.SUCCESS;
|
dataTransaction.status = statusTransaction.SUCCESS;
|
||||||
|
|
||||||
if (callback['sn']) {
|
if (callback['sn']) {
|
||||||
dataTransaction.seri_number = callback['sn'];
|
dataTransaction.seri_number = callback['sn'];
|
||||||
console.log("msksn1", dataTransaction.seri_number)
|
console.log('msksn1', dataTransaction.seri_number);
|
||||||
} else {
|
} else {
|
||||||
const response = callback['message'];
|
const response = callback['message'];
|
||||||
const responseBaru = response.split(' ');
|
const responseBaru = response.split(' ');
|
||||||
|
|
||||||
dataTransaction.seri_number =
|
dataTransaction.seri_number =
|
||||||
responseBaru[10].length > 1 ? responseBaru[10] : responseBaru[9];
|
responseBaru[10].length > 1 ? responseBaru[10] : responseBaru[9];
|
||||||
|
|
||||||
if (dataTransaction.seri_number == 'SN:') {
|
if (dataTransaction.seri_number == 'SN:') {
|
||||||
dataTransaction.seri_number = responseBaru[11]
|
dataTransaction.seri_number = responseBaru[11];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dataTransaction.callback_json = callback;
|
dataTransaction.callback_json = callback;
|
||||||
|
|
||||||
if (callback['message']) {
|
if (callback['message']) {
|
||||||
if (callback['message'].includes('METRO')) {
|
if (callback['message'].includes('METRO')) {
|
||||||
if (callback['price'] != dataTransaction.product_price.price) {
|
if (callback['price'] != dataTransaction.product_price.price) {
|
||||||
dataProductHistoryPrice.price = parseInt(callback['price'])
|
dataProductHistoryPrice.price = parseInt(callback['price']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1386,7 +1496,7 @@ export class TransactionService {
|
||||||
// dataTransaction.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory;
|
// dataTransaction.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory;
|
||||||
|
|
||||||
if (userData.partner == null) {
|
if (userData.partner == null) {
|
||||||
console.log('partnernull', 'masuk')
|
console.log('partnernull', 'masuk');
|
||||||
//GET SALES
|
//GET SALES
|
||||||
supervisorData = await this.calculateCommission(
|
supervisorData = await this.calculateCommission(
|
||||||
supervisorData,
|
supervisorData,
|
||||||
|
@ -1412,7 +1522,7 @@ export class TransactionService {
|
||||||
try {
|
try {
|
||||||
await this.connection.transaction(async (manager) => {
|
await this.connection.transaction(async (manager) => {
|
||||||
await manager.save(dataTransaction);
|
await manager.save(dataTransaction);
|
||||||
await manager.save(dataProductHistoryPrice)
|
await manager.save(dataProductHistoryPrice);
|
||||||
|
|
||||||
await this.accountingTransaction({
|
await this.accountingTransaction({
|
||||||
createTransaction: false,
|
createTransaction: false,
|
||||||
|
@ -1425,10 +1535,13 @@ export class TransactionService {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userData.partner != null) {
|
if (userData.partner != null) {
|
||||||
if (userData.partner) {
|
if (userData.partner) {
|
||||||
console.log('partnernotnull', 'masuk')
|
console.log('partnernotnull', 'masuk');
|
||||||
|
|
||||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
|
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
|
||||||
|
|
||||||
this.callbackToPartner(
|
this.callbackToPartner(
|
||||||
userData.partner.id,
|
userData.partner.id,
|
||||||
message,
|
message,
|
||||||
|
@ -1443,7 +1556,7 @@ export class TransactionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async resendOrderToPartner(supplier_trx_id: string, status: boolean){
|
async resendOrderToPartner(supplier_trx_id: string, status: boolean) {
|
||||||
const dataTransaction = await this.transactionRepository.findOne({
|
const dataTransaction = await this.transactionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
supplier_trx_id: supplier_trx_id,
|
supplier_trx_id: supplier_trx_id,
|
||||||
|
@ -1463,6 +1576,7 @@ export class TransactionService {
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
|
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`;
|
||||||
|
|
||||||
await this.callbackToPartner(
|
await this.callbackToPartner(
|
||||||
userData.partner.id,
|
userData.partner.id,
|
||||||
message,
|
message,
|
||||||
|
@ -1475,6 +1589,7 @@ export class TransactionService {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`;
|
const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`;
|
||||||
|
|
||||||
this.callbackToPartner(
|
this.callbackToPartner(
|
||||||
userData.partner.id,
|
userData.partner.id,
|
||||||
message,
|
message,
|
||||||
|
@ -1486,8 +1601,6 @@ export class TransactionService {
|
||||||
'gagal',
|
'gagal',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async callbackToPartner(
|
async callbackToPartner(
|
||||||
|
@ -1503,7 +1616,8 @@ export class TransactionService {
|
||||||
const partnerData = await this.userService.findPartner(partnerId);
|
const partnerData = await this.userService.findPartner(partnerId);
|
||||||
const userData = await this.userService.findOneByPartner(partnerId);
|
const userData = await this.userService.findOneByPartner(partnerId);
|
||||||
|
|
||||||
console.log('coamsk8', 'coa')
|
console.log('coamsk8', 'coa');
|
||||||
|
|
||||||
const coaAccount = await this.coaService.findByUser(
|
const coaAccount = await this.coaService.findByUser(
|
||||||
userData.id,
|
userData.id,
|
||||||
coaType.WALLET,
|
coaType.WALLET,
|
||||||
|
@ -1511,6 +1625,7 @@ export class TransactionService {
|
||||||
|
|
||||||
if (!partnerData.callback_url) {
|
if (!partnerData.callback_url) {
|
||||||
this.logger.error(`Call to partner failed, reason: no callback url`);
|
this.logger.error(`Call to partner failed, reason: no callback url`);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,6 +1642,7 @@ export class TransactionService {
|
||||||
return res;
|
return res;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`Call to partner failed, reason: ${e.message}`);
|
this.logger.error(`Call to partner failed, reason: ${e.message}`);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1540,7 +1656,7 @@ export class TransactionService {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if (trxId.length % 2 != 0) {
|
if (trxId.length % 2 != 0) {
|
||||||
throw Error("Not Balance")
|
throw Error('Not Balance');
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataTransactionJurnal = await this.transactionJournalRepository.find({
|
const dataTransactionJurnal = await this.transactionJournalRepository.find({
|
||||||
|
@ -1550,10 +1666,10 @@ export class TransactionService {
|
||||||
relations: ['coa'],
|
relations: ['coa'],
|
||||||
});
|
});
|
||||||
|
|
||||||
let dataRollbackJurnal = [];
|
const dataRollbackJurnal = [];
|
||||||
|
|
||||||
dataTransactionJurnal.map((it) => {
|
dataTransactionJurnal.map((it) => {
|
||||||
let data = {
|
const data = {
|
||||||
coa_id: it.coa.id,
|
coa_id: it.coa.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1586,7 +1702,8 @@ export class TransactionService {
|
||||||
async withdrawBenefit(user) {
|
async withdrawBenefit(user) {
|
||||||
const userData = await this.userService.findExist(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 coaProfit = await this.coaService.findByUser(user, coaType.PROFIT);
|
||||||
|
|
||||||
const coaBank = await this.coaService.findByName(
|
const coaBank = await this.coaService.findByName(
|
||||||
|
@ -1762,7 +1879,7 @@ export class TransactionService {
|
||||||
take: pageSize || 10,
|
take: pageSize || 10,
|
||||||
order: {
|
order: {
|
||||||
createdAt: 'DESC',
|
createdAt: 'DESC',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
|
@ -2062,7 +2179,8 @@ export class TransactionService {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('coamsk10', 'coa')
|
console.log('coamsk10', 'coa');
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
supervisorData.map(async (it) => {
|
supervisorData.map(async (it) => {
|
||||||
const coaAccount = await this.coaService.findByUser(
|
const coaAccount = await this.coaService.findByUser(
|
||||||
|
@ -2129,9 +2247,9 @@ export class TransactionService {
|
||||||
const journalEntry = new TransactionJournal();
|
const journalEntry = new TransactionJournal();
|
||||||
|
|
||||||
journalEntry.coa = coa;
|
journalEntry.coa = coa;
|
||||||
journalEntry.type = journal.debit
|
journalEntry.type = journal.debit ?
|
||||||
? balanceType.DEBIT
|
balanceType.DEBIT :
|
||||||
: balanceType.CREDIT;
|
balanceType.CREDIT;
|
||||||
journalEntry.amount = journal.debit ? journal.debit : journal.credit;
|
journalEntry.amount = journal.debit ? journal.debit : journal.credit;
|
||||||
journalEntry.transaction_head = transaction;
|
journalEntry.transaction_head = transaction;
|
||||||
|
|
||||||
|
@ -2204,7 +2322,9 @@ export class TransactionService {
|
||||||
message: string,
|
message: string,
|
||||||
) {
|
) {
|
||||||
const billData = await this.findOneBillById(trxId);
|
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 userData = await this.userService.findExist(billData.user);
|
||||||
|
|
||||||
const product_price = await this.productHistoryPriceService.findById(
|
const product_price = await this.productHistoryPriceService.findById(
|
||||||
|
@ -2216,12 +2336,12 @@ export class TransactionService {
|
||||||
trx_id: trxId,
|
trx_id: trxId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount: status
|
amount: status ?
|
||||||
? amount -
|
amount -
|
||||||
admin +
|
admin +
|
||||||
product_price.partner_fee +
|
product_price.partner_fee +
|
||||||
product_price.mark_up_price
|
product_price.mark_up_price :
|
||||||
: 0,
|
0,
|
||||||
admin_price: admin,
|
admin_price: admin,
|
||||||
status: status ? 'SUCCESS' : 'FAILED',
|
status: status ? 'SUCCESS' : 'FAILED',
|
||||||
callback_json: JSON.stringify(message),
|
callback_json: JSON.stringify(message),
|
||||||
|
@ -2229,12 +2349,13 @@ export class TransactionService {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (userData.partner) {
|
if (userData.partner) {
|
||||||
const message = status
|
const message = status ?
|
||||||
? `Bill dari ${billData.destination} adalah ${
|
`Bill dari ${billData.destination} adalah ${
|
||||||
amount + product_price.partner_fee + product_price.mark_up_price
|
amount + product_price.partner_fee + product_price.mark_up_price
|
||||||
}.`
|
}.` :
|
||||||
: '';
|
'';
|
||||||
const statusResponse = status ? 'berhasil' : 'gagal';
|
const statusResponse = status ? 'berhasil' : 'gagal';
|
||||||
|
|
||||||
this.callbackToPartner(
|
this.callbackToPartner(
|
||||||
userData.id,
|
userData.id,
|
||||||
message,
|
message,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user