fix: product in partner

This commit is contained in:
ilham 2022-05-08 22:42:22 +07:00
parent 137ca8e6f3
commit 819c59f28f

View File

@ -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',