- fix order-prod and order-stg if suppliers have same code product
This commit is contained in:
parent
399c6ff9e4
commit
6d9ce6f8ec
|
@ -505,16 +505,14 @@ export class ProductService {
|
|||
async findOneActive(
|
||||
code: string,
|
||||
type: string,
|
||||
roles: string,
|
||||
supplierId: string,
|
||||
productId: string
|
||||
) {
|
||||
if (roles == 'Retail') {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
supplier: supplierId,
|
||||
id: productId
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
|
@ -530,28 +528,7 @@ export class ProductService {
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOneById(id: string) {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { IsNotEmpty, IsOptional } from 'class-validator';
|
||||
|
||||
export class OrderTransactionDto {
|
||||
|
||||
@IsNotEmpty()
|
||||
productId: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
productCode: string;
|
||||
|
||||
|
|
|
@ -335,14 +335,13 @@ export class TransactionService {
|
|||
currentUser.username,
|
||||
);
|
||||
|
||||
const supplierData = await this.supplierService.findByCode('IRS');
|
||||
// const supplierData = await this.supplierService.findByCode('IRS');
|
||||
|
||||
//GET PRODUCT
|
||||
const product = await this.productService.findOneActive(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
userData.roles.name,
|
||||
supplierData.id
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
const product_price = await this.productHistoryPriceService.findOne(
|
||||
|
@ -491,16 +490,13 @@ export class TransactionService {
|
|||
currentUser.username,
|
||||
);
|
||||
|
||||
const supplierData = await this.supplierService.findByCode('IRS');
|
||||
|
||||
|
||||
// const supplierData = await this.supplierService.findByCode('IRS');
|
||||
|
||||
//GET PRODUCT AND PRICE
|
||||
const product = await this.productService.findOneActive(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
userData.roles.name,
|
||||
supplierData.id
|
||||
orderTransactionDto.productId
|
||||
);
|
||||
|
||||
const supplier = await this.supplierService.findByCode(
|
||||
|
|
Loading…
Reference in New Issue
Block a user