fix order-prod for b2c temporary
This commit is contained in:
parent
73820927ce
commit
95dc740ca2
|
@ -466,7 +466,32 @@ export class ProductService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneActive(code: string, type: string) {
|
async findOneActive(code: string, type: string, roles: string, supplierId: string) {
|
||||||
|
if (roles == "Retail") {
|
||||||
|
try {
|
||||||
|
return await this.productRepository.findOneOrFail({
|
||||||
|
relations: ['supplier'],
|
||||||
|
where: {
|
||||||
|
code: code,
|
||||||
|
supplier: supplierId
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof EntityNotFoundError) {
|
||||||
|
throw new HttpException(
|
||||||
|
{
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Product not found',
|
||||||
|
},
|
||||||
|
HttpStatus.NOT_FOUND,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.productRepository.findOneOrFail({
|
return await this.productRepository.findOneOrFail({
|
||||||
relations: ['supplier'],
|
relations: ['supplier'],
|
||||||
|
@ -487,6 +512,8 @@ export class ProductService {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneById(id: string) {
|
async findOneById(id: string) {
|
||||||
|
|
|
@ -332,10 +332,14 @@ export class TransactionService {
|
||||||
currentUser.username,
|
currentUser.username,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const supplierData = await this.supplierService.findByCode('IRS');
|
||||||
|
|
||||||
//GET PRODUCT
|
//GET PRODUCT
|
||||||
const product = await this.productService.findOneActive(
|
const product = await this.productService.findOneActive(
|
||||||
orderTransactionDto.productCode,
|
orderTransactionDto.productCode,
|
||||||
'prepaid'
|
'prepaid',
|
||||||
|
userData.roles.name,
|
||||||
|
supplierData.id
|
||||||
);
|
);
|
||||||
|
|
||||||
const product_price = await this.productHistoryPriceService.findOne(
|
const product_price = await this.productHistoryPriceService.findOne(
|
||||||
|
@ -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