/**
 * Container ORM Entity (Infrastructure Layer)
 *
 * TypeORM entity for container persistence
 */

import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
import { BookingOrmEntity } from './booking.orm-entity';

@Entity('containers')
@Index('idx_containers_booking', ['bookingId'])
@Index('idx_containers_container_number', ['containerNumber'])
export class ContainerOrmEntity {
  @PrimaryColumn('uuid')
  id: string;

  @Column({ name: 'booking_id', type: 'uuid' })
  bookingId: string;

  @ManyToOne(() => BookingOrmEntity, booking => booking.containers, {
    onDelete: 'CASCADE',
  })
  @JoinColumn({ name: 'booking_id' })
  booking: BookingOrmEntity;

  @Column({ type: 'varchar', length: 50 })
  type: string;

  @Column({ name: 'container_number', type: 'varchar', length: 20, nullable: true })
  containerNumber: string | null;

  @Column({ type: 'decimal', precision: 10, scale: 2, nullable: true })
  vgm: number | null;

  @Column({ type: 'decimal', precision: 5, scale: 2, nullable: true })
  temperature: number | null;

  @Column({ name: 'seal_number', type: 'varchar', length: 50, nullable: true })
  sealNumber: string | null;
}
