import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
import { BaseEntity } from '../database/base.entity';
import { QueryQuoteEntity } from './query-quote.entity';
import { HotelEntity } from './hotel.entity';

@Entity('query_quote_hotels')
export class QueryQuoteHotelEntity extends BaseEntity {
  @ManyToOne(() => QueryQuoteEntity, (q) => q.hotel_items, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'quote_id' })
  quote: QueryQuoteEntity;

  @Column({ type: 'uuid' })
  quote_id: string;

  @ManyToOne(() => HotelEntity)
  @JoinColumn({ name: 'hotel_id' })
  hotel: HotelEntity;

  @Column({ type: 'uuid' })
  hotel_id: string;

  @Column({ type: 'varchar', length: 100, nullable: true })
  room_type: string | null;

  @Column({ type: 'varchar', length: 100, nullable: true })
  meal_plan: string | null;

  @Column({ type: 'date' })
  check_in_date: string;

  @Column({ type: 'date' })
  check_out_date: string;

  @Column({ type: 'int' })
  nights: number;

  @Column({ type: 'int', default: 1 })
  pax_per_room: number;

  @Column({ type: 'int', default: 1 })
  num_rooms: number;

  @Column({ type: 'int', default: 0 })
  aweb: number;

  @Column({ type: 'int', default: 0 })
  cweb: number;

  @Column({ type: 'int', default: 0 })
  cnb: number;

  @Column({ type: 'simple-json', nullable: true })
  nightly_rates: { date: string; rate: number }[] | null;

  @Column({ type: 'decimal', precision: 12, scale: 2, default: 0 })
  subtotal: number;
}
