Merge branch 'development' into 'master'

fix: product

See merge request empatnusabangsa/ppob/ppob-backend!138
This commit is contained in:
ilham dwi pratama 2022-03-10 17:05:25 +00:00
commit 132bce0426

View File

@ -248,18 +248,19 @@ 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,
},
)
.leftJoinAndMapOne(
'product.currentPrice',
'product.priceHistory',
'current_price',
'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'])
.addSelect(['product.name', 'product.code', 'sub_categories.name'])
.addSelect(
@ -267,14 +268,14 @@ export class ProductService {
);
if (subCategories != 'null' && subCategories) {
baseQuery.where('product.sub_categories_id = :id', {
baseQuery.andWhere('product.sub_categories_id = :id', {
id: subCategories,
});
}
const data = await baseQuery
.offset(page * 10)
.limit(10)
.offset(page * 1000)
.limit(1000)
.getRawMany();
const totalData = await baseQuery.getCount();