import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { ItemRateEntity } from '../../domain/entities/item-rate.entity';
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
import { SeasonPeriodModel } from 'src/modules/season-related/season-period/data/models/season-period.model';

@Entity(TABLE_NAME.ITEM_RATE)
export class ItemRateModel
  extends BaseCoreModel<ItemRateEntity>
  implements ItemRateEntity
{
  @Column('varchar', { name: 'item_id', nullable: true })
  item_id: string;

  @ManyToOne(() => ItemModel, (model) => model.item_rates, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  @JoinColumn({ name: 'item_id' })
  item: ItemModel;

  @Column('varchar', { name: 'season_period_id', nullable: true })
  season_period_id: string;

  @ManyToOne(() => SeasonPeriodModel, (model) => model.item_rates, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  @JoinColumn({ name: 'season_period_id' })
  season_period: SeasonPeriodModel;

  @Column('bigint', { name: 'price', nullable: true })
  price: number;
}
