fix(SPG-645) Button generate price belum berfungsi
parent
d9bbe1290d
commit
190f42d598
|
@ -1,7 +1,9 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
||||
|
||||
export interface FilterItemRateEntity extends BaseFilterEntity {
|
||||
item_ids: string[];
|
||||
item_types: ItemType[];
|
||||
season_period_ids: string[];
|
||||
start_date: Date;
|
||||
end_date: Date;
|
||||
|
|
|
@ -86,6 +86,7 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
|||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.item_type`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.name`,
|
||||
|
|
|
@ -2,6 +2,7 @@ import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.d
|
|||
import { FilterItemRateEntity } from '../../domain/entities/filter-item-rate.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
||||
|
||||
export class FilterItemRateDto
|
||||
extends BaseFilterDto
|
||||
|
@ -21,6 +22,16 @@ export class FilterItemRateDto
|
|||
})
|
||||
end_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: ['string'],
|
||||
required: false,
|
||||
description: `Select ["${Object.values(ItemType)}"]`,
|
||||
})
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
item_types: ItemType[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
|
|
|
@ -19,6 +19,16 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
this.result.data?.map((item) => {
|
||||
const item_price =
|
||||
Number(item['item']?.total_price ?? 0) == 0
|
||||
? item['item']?.total_price
|
||||
: item['item']?.base_price;
|
||||
|
||||
Object.assign(item, {
|
||||
price: item.price ?? item_price,
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,7 +38,7 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: ['season_period', 'season_period.season_type'],
|
||||
selectRelations: ['season_period', 'season_period.season_type', 'item'],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
|
@ -41,6 +51,10 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
`${this.tableName}.item_id`,
|
||||
`${this.tableName}.price`,
|
||||
|
||||
'item.id',
|
||||
'item.total_price',
|
||||
'item.base_price',
|
||||
|
||||
`season_period.id`,
|
||||
`season_period.priority`,
|
||||
`season_period.created_at`,
|
||||
|
|
Loading…
Reference in New Issue