Merge branch 'development' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-staging
This commit is contained in:
commit
49464e876e
|
@ -405,7 +405,8 @@ export class ProductService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseQuery = await this.productRepository
|
const baseQuery = user.roles.name == 'Admin' ?
|
||||||
|
await this.productRepository
|
||||||
.createQueryBuilder('product')
|
.createQueryBuilder('product')
|
||||||
.leftJoin('product.sub_categories', 'sub_categories')
|
.leftJoin('product.sub_categories', 'sub_categories')
|
||||||
.leftJoin('product.supplier', 'supplier')
|
.leftJoin('product.supplier', 'supplier')
|
||||||
|
@ -458,6 +459,71 @@ export class ProductService {
|
||||||
'current_price.price as price',
|
'current_price.price as price',
|
||||||
])
|
])
|
||||||
.addSelect('history_status.status', 'status')
|
.addSelect('history_status.status', 'status')
|
||||||
|
.distinct()
|
||||||
|
// .addSelect(
|
||||||
|
// '(current_price.price + current_price.mark_up_price) as price',
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// subCategories != 'null' &&
|
||||||
|
// subCategories &&
|
||||||
|
// subCategories != 'undefined'
|
||||||
|
// ) {
|
||||||
|
// baseQuery.where('product.sub_categories_id = :id', {
|
||||||
|
// id: subCategories,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
:
|
||||||
|
await this.productRepository
|
||||||
|
.createQueryBuilder('product')
|
||||||
|
.leftJoin('product.sub_categories', 'sub_categories')
|
||||||
|
.leftJoin('product.supplier', 'supplier')
|
||||||
|
// .leftJoinAndSelect(
|
||||||
|
// 'product.supplier',
|
||||||
|
// 'supplier',
|
||||||
|
// 'supplier.status = true',
|
||||||
|
// {
|
||||||
|
// status: true
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// )
|
||||||
|
.innerJoinAndMapOne(
|
||||||
|
'product.currentPrice',
|
||||||
|
'product.priceHistory',
|
||||||
|
'current_price',
|
||||||
|
'current_price.partner_id = :id_partner and current_price.end_date is NULL',
|
||||||
|
{
|
||||||
|
id_partner: user.partner.id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.innerJoinAndMapOne(
|
||||||
|
'product.currentStatus',
|
||||||
|
'product.statusHistory',
|
||||||
|
'history_status',
|
||||||
|
'history_status.partner_id = :id_partner and history_status.deleted_at is NULL',
|
||||||
|
{
|
||||||
|
id_partner: user.partner.id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
// .where(`history_status.partner_id = :id_partner`, {
|
||||||
|
// partner: user.partner.id,
|
||||||
|
// })
|
||||||
|
.where(`history_status.status = 'ACTIVE'`, {
|
||||||
|
status: 'ACTIVE',
|
||||||
|
})
|
||||||
|
.andWhere('supplier.status = TRUE', {
|
||||||
|
status: true
|
||||||
|
})
|
||||||
|
.select(['product.id'])
|
||||||
|
.addSelect([
|
||||||
|
'product.name',
|
||||||
|
'product.code',
|
||||||
|
'product.type',
|
||||||
|
'product.supplier_id',
|
||||||
|
'sub_categories.name',
|
||||||
|
'current_price.price as price',
|
||||||
|
])
|
||||||
|
.addSelect('history_status.status', 'status')
|
||||||
.distinct();
|
.distinct();
|
||||||
// .addSelect(
|
// .addSelect(
|
||||||
// '(current_price.price + current_price.mark_up_price) as price',
|
// '(current_price.price + current_price.mark_up_price) as price',
|
||||||
|
@ -472,7 +538,6 @@ export class ProductService {
|
||||||
// id: subCategories,
|
// id: subCategories,
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (subCategories && filterSubCategories.length > 0) {
|
if (subCategories && filterSubCategories.length > 0) {
|
||||||
baseQuery
|
baseQuery
|
||||||
.where('product.sub_categories_id IN (:...subCategoryId)', {
|
.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user