From 819c59f28feb8514773401d8b88ec1dd454dc027 Mon Sep 17 00:00:00 2001 From: ilham Date: Sun, 8 May 2022 22:42:22 +0700 Subject: [PATCH] fix: product in partner --- src/product/product.service.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/product/product.service.ts b/src/product/product.service.ts index 1afb8a0..5cb5745 100644 --- a/src/product/product.service.ts +++ b/src/product/product.service.ts @@ -172,7 +172,7 @@ export class ProductService { 'product.currentPrice', 'product.priceHistory', 'current_price', - 'current_price.partner_id is null and current_price.end_date is NULL', + 'current_price.end_date is NULL', ) .select(['product.id']) .addSelect([ @@ -297,7 +297,6 @@ export class ProductService { username: string, ) { const user = await this.usersService.findOneByUsername(username); - const supplier = await this.supplierService.findByActive(); if (user.partner === null) { throw new HttpException( @@ -312,12 +311,12 @@ export class ProductService { const baseQuery = this.productRepository .createQueryBuilder('product') .leftJoin('product.sub_categories', 'sub_categories') - .where( - `product.supplier_id = :supplier_id and product.status = 'ACTIVE'`, - { - supplier_id: supplier.id, - }, + .leftJoinAndSelect( + 'product.supplier', + 'supplier', + 'supplier.status = true', ) + .where(`product.status = 'ACTIVE'`) .innerJoinAndMapOne( 'product.currentPrice', 'product.priceHistory',