fix(SPG-602) Harga Item belum mengambil harga season periode
parent
b574d3a39d
commit
78ae2a5d8e
|
@ -6,6 +6,7 @@ import {
|
|||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
|
||||
@Injectable()
|
||||
export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
||||
|
@ -27,6 +28,7 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
|||
) {
|
||||
const rate = item['item_rates']?.find(
|
||||
(rate) =>
|
||||
rate.season_period?.status == STATUS.ACTIVE &&
|
||||
d >= new Date(rate.season_period.start_date) &&
|
||||
d <= new Date(rate.season_period.end_date),
|
||||
);
|
||||
|
@ -84,6 +86,7 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
|||
'item_rates.price',
|
||||
|
||||
'season_period.id',
|
||||
'season_period.status',
|
||||
'season_period.holiday_name',
|
||||
'season_period.start_date',
|
||||
'season_period.end_date',
|
||||
|
|
|
@ -6,4 +6,5 @@ export interface FilterItemEntity extends BaseFilterEntity {
|
|||
limit_types: string[];
|
||||
tenant_ids: string[];
|
||||
all_item: boolean;
|
||||
season_period_ids: string[];
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ItemRateEntity } from 'src/modules/item-related/item-rate/domain/entiti
|
|||
@Injectable()
|
||||
export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
this.filterParam.order_by = `${this.tableName}.id`;
|
||||
this.filterParam.order_by = `season_period.id`;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,11 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.item_id`,
|
||||
`${this.tableName}.price`,
|
||||
|
||||
`season_period.id`,
|
||||
`season_period.priority`,
|
||||
`season_period.created_at`,
|
||||
`season_period.creator_name`,
|
||||
`season_period.editor_name`,
|
||||
|
@ -68,20 +70,25 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
itemIds: this.filterParam.item_ids,
|
||||
});
|
||||
}
|
||||
if (this.filterParam.start_date) {
|
||||
queryBuilder.andWhere(`season_period.start_date BETWEEN :from AND :to`, {
|
||||
from: this.filterParam.start_date,
|
||||
to: this.filterParam.end_date,
|
||||
|
||||
if (this.filterParam.season_period_ids) {
|
||||
queryBuilder.andWhere(`season_period.id In (:...itemIds)`, {
|
||||
itemIds: this.filterParam.season_period_ids,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.filterParam.end_date) {
|
||||
queryBuilder.andWhere(`season_period.end_date BETWEEN :from AND :to`, {
|
||||
from: this.filterParam.start_date,
|
||||
to: this.filterParam.end_date,
|
||||
if (this.filterParam.start_date) {
|
||||
queryBuilder.andWhere(`season_period.start_date < :inputStartDate`, {
|
||||
inputStartDate: this.filterParam.end_date,
|
||||
});
|
||||
|
||||
queryBuilder.andWhere(`season_period.end_date > :inputEndDate`, {
|
||||
inputEndDate: this.filterParam.start_date,
|
||||
});
|
||||
}
|
||||
|
||||
queryBuilder.addOrderBy('season_period.priority', 'ASC');
|
||||
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,12 @@ export class FilterItemDto extends BaseFilterDto implements FilterItemEntity {
|
|||
})
|
||||
item_categories: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
season_period_ids: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
|
|
Loading…
Reference in New Issue