Feat: add rumus prepaid and postpaid
This commit is contained in:
parent
cb7d6833aa
commit
1050ca4c85
|
@ -321,7 +321,7 @@ export class ProductService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseQuery = this.productRepository
|
const baseQuery = await this.productRepository
|
||||||
.createQueryBuilder('product')
|
.createQueryBuilder('product')
|
||||||
.leftJoin('product.sub_categories', 'sub_categories')
|
.leftJoin('product.sub_categories', 'sub_categories')
|
||||||
.leftJoinAndSelect(
|
.leftJoinAndSelect(
|
||||||
|
@ -343,12 +343,16 @@ export class ProductService {
|
||||||
.addSelect([
|
.addSelect([
|
||||||
'product.name',
|
'product.name',
|
||||||
'product.code',
|
'product.code',
|
||||||
|
'product.type',
|
||||||
'sub_categories.name',
|
'sub_categories.name',
|
||||||
'current_price.admin_price as admin_price',
|
'current_price.admin_price as admin_price',
|
||||||
|
'current_price.mark_up_price as markup_price',
|
||||||
|
'current_price.partner_fee as partner_fee',
|
||||||
|
'current_price.price as price',
|
||||||
])
|
])
|
||||||
.addSelect(
|
// .addSelect(
|
||||||
'(current_price.price + current_price.mark_up_price) as price',
|
// '(current_price.price + current_price.mark_up_price) as price',
|
||||||
);
|
// );
|
||||||
|
|
||||||
// if (
|
// if (
|
||||||
// subCategories != 'null' &&
|
// subCategories != 'null' &&
|
||||||
|
@ -360,17 +364,39 @@ export class ProductService {
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (subCategories && filterSubCategories.length > 0) {
|
|
||||||
|
if (subCategories && filterSubCategories.length > 0) {
|
||||||
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
|
baseQuery.where('product.sub_categories_id IN (:...subCategoryId)', {
|
||||||
subCategoryId: filterSubCategories,
|
subCategoryId: filterSubCategories,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newData = []
|
||||||
|
|
||||||
const data = await baseQuery
|
const data = await baseQuery
|
||||||
.offset(page * pageSize)
|
.offset(page * pageSize)
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
|
||||||
|
data.map((dataa) => {
|
||||||
|
let actualPrice = 0
|
||||||
|
|
||||||
|
if (dataa.product_type === 'prepaid') {
|
||||||
|
actualPrice = Number(dataa['price']) + Number(dataa['markup_price'])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataa.product_type === 'postpaid') {
|
||||||
|
actualPrice = Number(dataa['admin_price'])- (Number(dataa['partner_fee']) + Number(dataa['markup_price']))
|
||||||
|
}
|
||||||
|
|
||||||
|
dataa.price = actualPrice
|
||||||
|
|
||||||
|
newData.push({
|
||||||
|
...dataa
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
const totalData = await baseQuery.getCount();
|
const totalData = await baseQuery.getCount();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user