add: check bill
This commit is contained in:
parent
4685797ad4
commit
49e22932b6
|
@ -13,14 +13,14 @@ export const doTransaction = async (
|
||||||
supplier,
|
supplier,
|
||||||
) => {
|
) => {
|
||||||
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 {
|
} else {
|
||||||
const res = await axios.get(
|
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;
|
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')
|
@Post('deposit-return')
|
||||||
async depositReturn(
|
async depositReturn(
|
||||||
@Body() depositReturnDto: DepositReturnDto,
|
@Body() depositReturnDto: DepositReturnDto,
|
||||||
|
|
|
@ -497,7 +497,7 @@ export class TransactionService {
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
orderTransactionDto.destination,
|
orderTransactionDto.destination,
|
||||||
trxId,
|
trxId,
|
||||||
supplier
|
supplier,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (supplier.code != 'IRS') {
|
if (supplier.code != 'IRS') {
|
||||||
|
@ -507,7 +507,7 @@ export class TransactionService {
|
||||||
harga: parseInt(
|
harga: parseInt(
|
||||||
parsingResponse[parsingResponse.length - 2].replaceAll('.', ''),
|
parsingResponse[parsingResponse.length - 2].replaceAll('.', ''),
|
||||||
),
|
),
|
||||||
msg: hitSupplier
|
msg: hitSupplier,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// const 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) {
|
async createDepositReturn(currentUser, depositReturnDto: DepositReturnDto) {
|
||||||
const userData = await this.userService.findByUsername(
|
const userData = await this.userService.findByUsername(
|
||||||
currentUser.username,
|
currentUser.username,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user