Merge branch 'development' into 'devops-production'
fix: product See merge request empatnusabangsa/ppob/ppob-backend!139
This commit is contained in:
		| @@ -248,18 +248,19 @@ export class ProductService { | |||||||
|     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 and product.status = 'ACTIVE'`, |  | ||||||
|         { |  | ||||||
|           supplier_id: supplier, |  | ||||||
|         }, |  | ||||||
|       ) |  | ||||||
|       .leftJoinAndMapOne( |       .leftJoinAndMapOne( | ||||||
|         'product.currentPrice', |         'product.currentPrice', | ||||||
|         'product.priceHistory', |         'product.priceHistory', | ||||||
|         'current_price', |         'current_price', | ||||||
|         'current_price.partner_id is NULL and current_price.end_date is NULL', |         'current_price.partner_id is NULL and current_price.end_date is NULL', | ||||||
|       ) |       ) | ||||||
|  |       .where( | ||||||
|  |         `product.supplier_id = :supplier_id and product.status = 'ACTIVE'`, | ||||||
|  |         { | ||||||
|  |           supplier_id: supplier, | ||||||
|  |         }, | ||||||
|  |       ) | ||||||
|       .select(['product.id']) |       .select(['product.id']) | ||||||
|       .addSelect(['product.name', 'product.code', 'sub_categories.name']) |       .addSelect(['product.name', 'product.code', 'sub_categories.name']) | ||||||
|       .addSelect( |       .addSelect( | ||||||
| @@ -267,14 +268,14 @@ export class ProductService { | |||||||
|       ); |       ); | ||||||
|  |  | ||||||
|     if (subCategories != 'null' && subCategories) { |     if (subCategories != 'null' && subCategories) { | ||||||
|       baseQuery.where('product.sub_categories_id = :id', { |       baseQuery.andWhere('product.sub_categories_id = :id', { | ||||||
|         id: subCategories, |         id: subCategories, | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const data = await baseQuery |     const data = await baseQuery | ||||||
|       .offset(page * 10) |       .offset(page * 1000) | ||||||
|       .limit(10) |       .limit(1000) | ||||||
|       .getRawMany(); |       .getRawMany(); | ||||||
|  |  | ||||||
|     const totalData = await baseQuery.getCount(); |     const totalData = await baseQuery.getCount(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user