Merge branch 'devops-staging' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend
This commit is contained in:
commit
79d776af8d
|
@ -466,26 +466,53 @@ export class ProductService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneActive(code: string, type: string) {
|
async findOneActive(code: string, type: string, roles: string, supplierId: string) {
|
||||||
try {
|
if (roles == "Retail") {
|
||||||
return await this.productRepository.findOneOrFail({
|
try {
|
||||||
relations: ['supplier'],
|
return await this.productRepository.findOneOrFail({
|
||||||
where: {
|
relations: ['supplier'],
|
||||||
code: code,
|
where: {
|
||||||
},
|
code: code,
|
||||||
});
|
supplier: supplierId
|
||||||
} catch (e) {
|
},
|
||||||
if (e instanceof EntityNotFoundError) {
|
});
|
||||||
throw new HttpException(
|
} catch (e) {
|
||||||
{
|
if (e instanceof EntityNotFoundError) {
|
||||||
statusCode: HttpStatus.NOT_FOUND,
|
throw new HttpException(
|
||||||
error: 'Product not found',
|
{
|
||||||
},
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
HttpStatus.NOT_FOUND,
|
error: 'Product not found',
|
||||||
);
|
},
|
||||||
} else {
|
HttpStatus.NOT_FOUND,
|
||||||
throw e;
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await this.productRepository.findOneOrFail({
|
||||||
|
relations: ['supplier'],
|
||||||
|
where: {
|
||||||
|
code: code,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof EntityNotFoundError) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Product not found',
|
||||||
|
},
|
||||||
|
HttpStatus.NOT_FOUND,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,11 +332,15 @@ export class TransactionService {
|
||||||
currentUser.username,
|
currentUser.username,
|
||||||
);
|
);
|
||||||
|
|
||||||
//GET PRODUCT
|
const supplierData = await this.supplierService.findByCode('IRS');
|
||||||
const product = await this.productService.findOneActive(
|
|
||||||
orderTransactionDto.productCode,
|
//GET PRODUCT
|
||||||
'prepaid'
|
const product = await this.productService.findOneActive(
|
||||||
);
|
orderTransactionDto.productCode,
|
||||||
|
'prepaid',
|
||||||
|
userData.roles.name,
|
||||||
|
supplierData.id
|
||||||
|
);
|
||||||
|
|
||||||
const product_price = await this.productHistoryPriceService.findOne(
|
const product_price = await this.productHistoryPriceService.findOne(
|
||||||
product.id,
|
product.id,
|
||||||
|
@ -483,10 +487,16 @@ export class TransactionService {
|
||||||
currentUser.username,
|
currentUser.username,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const supplierData = await this.supplierService.findByCode('IRS');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//GET PRODUCT AND PRICE
|
//GET PRODUCT AND PRICE
|
||||||
const product = await this.productService.findOneActive(
|
const product = await this.productService.findOneActive(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid',
|
'prepaid',
|
||||||
|
userData.roles.name,
|
||||||
|
supplierData.id
|
||||||
);
|
);
|
||||||
|
|
||||||
const supplier = await this.supplierService.findByCode(
|
const supplier = await this.supplierService.findByCode(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user