fix: add coa in supplier
This commit is contained in:
@@ -101,7 +101,7 @@ export class ProductController {
|
||||
@Query('categories') categories: string,
|
||||
@Query('supplier') supplier: string,
|
||||
) {
|
||||
const data = await this.productService.findAllByCategories(
|
||||
const data = await this.productService.findAllBySubCategories(
|
||||
page,
|
||||
categories,
|
||||
supplier,
|
||||
|
||||
@@ -63,14 +63,45 @@ export class ProductService {
|
||||
});
|
||||
}
|
||||
|
||||
async findAllByCategories(page, categories, supplier) {
|
||||
async findAllByCategories(page, subCategories, supplier) {
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.where(
|
||||
'sub_categories.category_id = :id and product.supplier_id = :supplier_id',
|
||||
{
|
||||
id: categories,
|
||||
id: subCategories,
|
||||
supplier_id: supplier,
|
||||
},
|
||||
)
|
||||
.leftJoinAndMapOne(
|
||||
'product.currentPrice',
|
||||
'product.priceHistory',
|
||||
'current_price',
|
||||
'current_price.partner_id is null',
|
||||
);
|
||||
|
||||
const data = await baseQuery
|
||||
.skip(page * 10)
|
||||
.take(10)
|
||||
.getMany();
|
||||
|
||||
const totalData = await baseQuery.getCount();
|
||||
|
||||
return {
|
||||
data,
|
||||
count: totalData,
|
||||
};
|
||||
}
|
||||
|
||||
async findAllBySubCategories(page, subCategories, supplier) {
|
||||
const baseQuery = this.productRepository
|
||||
.createQueryBuilder('product')
|
||||
.leftJoin('product.sub_categories', 'sub_categories')
|
||||
.where(
|
||||
'sub_categories.category_id = :id and product.supplier_id = :supplier_id',
|
||||
{
|
||||
id: subCategories,
|
||||
supplier_id: supplier,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user