add: check bill
This commit is contained in:
parent
4685797ad4
commit
49e22932b6
|
@ -13,14 +13,14 @@ export const doTransaction = async (
|
|||
supplier,
|
||||
) => {
|
||||
try {
|
||||
if(supplier.code != 'IRS'){
|
||||
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 {
|
||||
const res = await axios.get(
|
||||
`${supplier.url}/trx?memberID=${irs_id}&pin=${irs_pin}&user=${irs_user}&password=${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;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,21 @@ export class TransactionController {
|
|||
};
|
||||
}
|
||||
|
||||
@Post('check-bill')
|
||||
async checkBill(
|
||||
@Body() orderTransactionDto: OrderTransactionDto,
|
||||
@Request() req,
|
||||
) {
|
||||
return {
|
||||
data: await this.transactionService.checkBill(
|
||||
orderTransactionDto,
|
||||
req.user,
|
||||
),
|
||||
statusCode: HttpStatus.CREATED,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
@Post('deposit-return')
|
||||
async depositReturn(
|
||||
@Body() depositReturnDto: DepositReturnDto,
|
||||
|
|
|
@ -497,7 +497,7 @@ export class TransactionService {
|
|||
orderTransactionDto.productCode,
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier
|
||||
supplier,
|
||||
);
|
||||
|
||||
if (supplier.code != 'IRS') {
|
||||
|
@ -507,7 +507,7 @@ export class TransactionService {
|
|||
harga: parseInt(
|
||||
parsingResponse[parsingResponse.length - 2].replaceAll('.', ''),
|
||||
),
|
||||
msg: hitSupplier
|
||||
msg: hitSupplier,
|
||||
};
|
||||
}
|
||||
// const hitSupplier = {
|
||||
|
@ -620,6 +620,46 @@ export class TransactionService {
|
|||
};
|
||||
}
|
||||
|
||||
async checkBill(orderTransactionDto: OrderTransactionDto, currentUser: any) {
|
||||
//GET USER DATA
|
||||
const userData = await this.userService.findByUsername(
|
||||
currentUser.username,
|
||||
);
|
||||
|
||||
//GET PRODUCT AND PRICE
|
||||
const product = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
);
|
||||
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
product.supplier.code,
|
||||
);
|
||||
|
||||
//HIT API SUPPLIER
|
||||
const trxId = Array(6)
|
||||
.fill(null)
|
||||
.map(() => {
|
||||
return Math.round(Math.random() * 16).toString(16);
|
||||
})
|
||||
.join('');
|
||||
|
||||
// let hitSupplier = await doTransaction(
|
||||
// 'CEK' + orderTransactionDto.productCode.slice(3),
|
||||
// orderTransactionDto.destination,
|
||||
// trxId,
|
||||
// supplier,
|
||||
// );
|
||||
|
||||
let hitSupplier = await doTransaction(
|
||||
'CEKXL1',
|
||||
orderTransactionDto.destination,
|
||||
trxId,
|
||||
supplier,
|
||||
);
|
||||
|
||||
return hitSupplier;
|
||||
}
|
||||
|
||||
async createDepositReturn(currentUser, depositReturnDto: DepositReturnDto) {
|
||||
const userData = await this.userService.findByUsername(
|
||||
currentUser.username,
|
||||
|
|
Loading…
Reference in New Issue
Block a user