Compare commits

...

2 Commits

Author SHA1 Message Date
shancheas f4387767a8 fix: add item rate to bundling breakdown
continuous-integration/drone/tag Build is passing Details
2024-08-16 18:46:10 +07:00
shancheas 8b82f9b7db feat: estimation play to item 2024-08-16 16:44:04 +07:00
5 changed files with 41 additions and 4 deletions

View File

@ -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"`,
);
}
}

View File

@ -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;

View File

@ -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`,

View File

@ -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`,

View File

@ -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`,