add: check bill

This commit is contained in:
ilham
2022-04-29 15:50:16 +07:00
parent 4685797ad4
commit 49e22932b6
3 changed files with 59 additions and 4 deletions

View File

@@ -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,