fix: product service
This commit is contained in:
parent
aa8764ff2b
commit
4361539072
|
@ -88,7 +88,6 @@ export class ProductService {
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
dataHistoryPrice = await this.productHistoryPrice.findOne({
|
||||
product: productData,
|
||||
|
@ -302,31 +301,16 @@ export class ProductService {
|
|||
const user = await this.usersService.findOneByUsername(username);
|
||||
const supplier = await this.supplierService.findByActive();
|
||||
|
||||
let filterSupplier, filterSubCategories;
|
||||
|
||||
if (subCategories) {
|
||||
filterSubCategories = subCategories.split(',').map((data) => data.trim());
|
||||
} else {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Sub Categories not inlcude',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.where(
|
||||
`product.sub_categories_id IN (:...subCategoryId) and product.supplier_id = :supplier_id and product.status = 'ACTIVE'`,
|
||||
`product.supplier_id = :supplier_id and product.status = 'ACTIVE'`,
|
||||
{
|
||||
subCategoryId: filterSubCategories,
|
||||
supplier_id: supplier.id,
|
||||
},
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
.innerJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
|
@ -341,6 +325,16 @@ export class ProductService {
|
|||
'(current_price.price + current_price.mark_up_price) as price',
|
||||
);
|
||||
|
||||
if (
|
||||
subCategories != 'null' &&
|
||||
subCategories &&
|
||||
subCategories != 'undifined'
|
||||
) {
|
||||
baseQuery.where('product.sub_categories_id = :id', {
|
||||
id: subCategories,
|
||||
});
|
||||
}
|
||||
|
||||
const data = await baseQuery
|
||||
.offset(page * 10)
|
||||
.limit(10)
|
||||
|
|
Loading…
Reference in New Issue
Block a user