fix: add item rate to bundling breakdown
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
parent
8b82f9b7db
commit
f4387767a8
|
@ -19,14 +19,25 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
async afterProcess(): Promise<void> {
|
||||||
this.result.data?.map((item) => {
|
this.result.data?.map((rates) => {
|
||||||
|
const item = rates['item'];
|
||||||
const item_price =
|
const item_price =
|
||||||
Number(item['item']?.total_price ?? 0) == 0
|
Number(item?.total_price ?? 0) == 0
|
||||||
? item['item']?.total_price
|
? item?.total_price
|
||||||
: item['item']?.base_price;
|
: item?.base_price;
|
||||||
|
|
||||||
|
const bundlings = item?.bundling_items ?? [];
|
||||||
|
const bundling_items = bundlings.map((bundling) => {
|
||||||
|
const rate = bundling.item_rates?.[0]?.price ?? 0;
|
||||||
|
return {
|
||||||
|
...bundling,
|
||||||
|
item_rates: rate,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
Object.assign(item, {
|
Object.assign(item, {
|
||||||
price: item.price ?? item_price,
|
price: item.price ?? item_price,
|
||||||
|
bundling_items,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -43,6 +54,7 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
'season_period.season_type',
|
'season_period.season_type',
|
||||||
'item',
|
'item',
|
||||||
'item.bundling_items',
|
'item.bundling_items',
|
||||||
|
'bundling_items.item_rates',
|
||||||
],
|
],
|
||||||
|
|
||||||
// relation yang hanya ingin dihitung (akan return number)
|
// relation yang hanya ingin dihitung (akan return number)
|
||||||
|
@ -64,6 +76,9 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
'bundling_items.hpp',
|
'bundling_items.hpp',
|
||||||
'bundling_items.id',
|
'bundling_items.id',
|
||||||
'bundling_items.name',
|
'bundling_items.name',
|
||||||
|
|
||||||
|
'item_rates.price',
|
||||||
|
|
||||||
`season_period.id`,
|
`season_period.id`,
|
||||||
`season_period.priority`,
|
`season_period.priority`,
|
||||||
`season_period.created_at`,
|
`season_period.created_at`,
|
||||||
|
|
Loading…
Reference in New Issue