Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!142
This commit is contained in:
		@@ -248,33 +248,33 @@ 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('(current_price.price + current_price.mark_up_price) as price')
 | 
				
			||||||
        '(current_price.price + current_price.mark_up_price) as price',
 | 
					      .orderBy('price', 'ASC');
 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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