Compare commits
2 Commits
ee232447b6
...
f4387767a8
Author | SHA1 | Date |
---|---|---|
|
f4387767a8 | |
|
8b82f9b7db |
|
@ -0,0 +1,17 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddEstimationToItem1723801180604 implements MigrationInterface {
|
||||
name = 'AddEstimationToItem1723801180604';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ADD "play_estimation" integer`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" DROP COLUMN "play_estimation"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -50,6 +50,9 @@ export class ItemModel
|
|||
@Column('bigint', { name: 'base_price', nullable: true })
|
||||
base_price: number;
|
||||
|
||||
@Column('int', { name: 'play_estimation', nullable: true })
|
||||
play_estimation: number;
|
||||
|
||||
@Column('boolean', { name: 'use_queue', default: false })
|
||||
use_queue: boolean;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
|
|||
`${this.tableName}.use_queue`,
|
||||
`${this.tableName}.show_to_booking`,
|
||||
`${this.tableName}.breakdown_bundling`,
|
||||
`${this.tableName}.play_estimation`,
|
||||
|
||||
`item_category.id`,
|
||||
`item_category.name`,
|
||||
|
|
|
@ -19,14 +19,25 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
this.result.data?.map((item) => {
|
||||
this.result.data?.map((rates) => {
|
||||
const item = rates['item'];
|
||||
const item_price =
|
||||
Number(item['item']?.total_price ?? 0) == 0
|
||||
? item['item']?.total_price
|
||||
: item['item']?.base_price;
|
||||
Number(item?.total_price ?? 0) == 0
|
||||
? item?.total_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, {
|
||||
price: item.price ?? item_price,
|
||||
bundling_items,
|
||||
});
|
||||
});
|
||||
return;
|
||||
|
@ -43,6 +54,7 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
'season_period.season_type',
|
||||
'item',
|
||||
'item.bundling_items',
|
||||
'bundling_items.item_rates',
|
||||
],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
|
@ -64,6 +76,9 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
'bundling_items.hpp',
|
||||
'bundling_items.id',
|
||||
'bundling_items.name',
|
||||
|
||||
'item_rates.price',
|
||||
|
||||
`season_period.id`,
|
||||
`season_period.priority`,
|
||||
`season_period.created_at`,
|
||||
|
|
|
@ -47,6 +47,7 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
|||
`${this.tableName}.base_price`,
|
||||
`${this.tableName}.share_profit`,
|
||||
`${this.tableName}.breakdown_bundling`,
|
||||
`${this.tableName}.play_estimation`,
|
||||
|
||||
`item_category.id`,
|
||||
`item_category.name`,
|
||||
|
|
Loading…
Reference in New Issue