Merge branch 'master' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-production
This commit is contained in:
commit
1e4aa16550
|
@ -429,6 +429,30 @@ export class ProductService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findOneActive(code: string, type: string) {
|
||||||
|
try {
|
||||||
|
return await this.productRepository.findOneOrFail({
|
||||||
|
relations: ['supplier'],
|
||||||
|
where: {
|
||||||
|
code: code,
|
||||||
|
status: 'ACTIVE',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof EntityNotFoundError) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Product not found',
|
||||||
|
},
|
||||||
|
HttpStatus.NOT_FOUND,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async findOneById(id: string) {
|
async findOneById(id: string) {
|
||||||
try {
|
try {
|
||||||
return await this.productRepository.findOneOrFail({
|
return await this.productRepository.findOneOrFail({
|
||||||
|
|
|
@ -310,7 +310,7 @@ export class TransactionService {
|
||||||
'prepaid',
|
'prepaid',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (productData.status == 'NOT ACTIVE') {
|
if (!productData.status.includes('ACTIVE')) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
{
|
{
|
||||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
@ -333,7 +333,7 @@ export class TransactionService {
|
||||||
);
|
);
|
||||||
|
|
||||||
//GET PRODUCT
|
//GET PRODUCT
|
||||||
const product = await this.productService.findOne(
|
const product = await this.productService.findOneActive(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid'
|
'prepaid'
|
||||||
);
|
);
|
||||||
|
@ -467,7 +467,7 @@ export class TransactionService {
|
||||||
'prepaid',
|
'prepaid',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (productData.status == 'NOT ACTIVE') {
|
if (!productData.status.includes('ACTIVE')) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
{
|
{
|
||||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
@ -484,7 +484,7 @@ export class TransactionService {
|
||||||
);
|
);
|
||||||
|
|
||||||
//GET PRODUCT AND PRICE
|
//GET PRODUCT AND PRICE
|
||||||
const product = await this.productService.findOne(
|
const product = await this.productService.findOneActive(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid',
|
'prepaid',
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user