fix: unselect product that not active
This commit is contained in:
		| @@ -57,11 +57,12 @@ export class ProductService { | |||||||
|     if (supplier == 'null' || !supplier) { |     if (supplier == 'null' || !supplier) { | ||||||
|       supplier = (await this.supplierService.findByActive()).id; |       supplier = (await this.supplierService.findByActive()).id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const baseQuery = this.productRepository |     const baseQuery = this.productRepository | ||||||
|       .createQueryBuilder('product') |       .createQueryBuilder('product') | ||||||
|       .leftJoin('product.sub_categories', 'sub_categories') |       .leftJoin('product.sub_categories', 'sub_categories') | ||||||
|       .leftJoin('sub_categories.category', 'category') |       .leftJoin('sub_categories.category', 'category') | ||||||
|       .where('product.supplier_id = :supplier_id', { |       .where(`product.supplier_id = :supplier_id`, { | ||||||
|         supplier_id: supplier, |         supplier_id: supplier, | ||||||
|       }) |       }) | ||||||
|       .leftJoinAndMapOne( |       .leftJoinAndMapOne( | ||||||
| @@ -131,12 +132,16 @@ export class ProductService { | |||||||
|     if (supplier != 'null' && !supplier) { |     if (supplier != 'null' && !supplier) { | ||||||
|       supplier = (await this.supplierService.findByActive()).id; |       supplier = (await this.supplierService.findByActive()).id; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const baseQuery = this.productRepository |     const baseQuery = this.productRepository | ||||||
|       .createQueryBuilder('product') |       .createQueryBuilder('product') | ||||||
|       .leftJoin('product.sub_categories', 'sub_categories') |       .leftJoin('product.sub_categories', 'sub_categories') | ||||||
|       .where('product.supplier_id = :supplier_id', { |       .where( | ||||||
|  |         `product.supplier_id = :supplier_id and product.status = 'ACTIVE'`, | ||||||
|  |         { | ||||||
|           supplier_id: supplier, |           supplier_id: supplier, | ||||||
|       }) |         }, | ||||||
|  |       ) | ||||||
|       .leftJoinAndMapOne( |       .leftJoinAndMapOne( | ||||||
|         'product.currentPrice', |         'product.currentPrice', | ||||||
|         'product.priceHistory', |         'product.priceHistory', | ||||||
| @@ -176,7 +181,7 @@ export class ProductService { | |||||||
|       .createQueryBuilder('product') |       .createQueryBuilder('product') | ||||||
|       .leftJoin('product.sub_categories', 'sub_categories') |       .leftJoin('product.sub_categories', 'sub_categories') | ||||||
|       .where( |       .where( | ||||||
|         'sub_categories.category_id = :id and product.supplier_id = :supplier_id', |         `sub_categories.category_id = :id and product.supplier_id = :supplier_id and product.status = 'ACTIVE'`, | ||||||
|         { |         { | ||||||
|           id: categories, |           id: categories, | ||||||
|           supplier_id: supplier.id, |           supplier_id: supplier.id, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user