import { Entity, Column, Index } from 'typeorm';
import { BaseEntity } from '../database/base.entity';

/**
 * VehicleType entity — tenant-scoped master table.
 *
 * Used by: Vehicle (type field), Transport Pricing (vehicle type column).
 * Seeded on tenant onboarding: Sedan, SUV, Van, Coaster, Bus, Mini Bus, Limousine.
 */
@Entity('vehicle_types')
@Index(['tenant_id', 'name'], { unique: true, where: '"is_deleted" = false' })
export class VehicleTypeEntity extends BaseEntity {
  @Column({ type: 'varchar', length: 100 })
  name: string;

  /**
   * Physical seating capacity — the legal/safety upper bound for the
   * vehicle type (e.g. an Innova "seats 7"). Used for double-booking
   * guards and capacity reports.
   *
   * Per stakeholder spec, capacity is owned by the vehicle TYPE
   * master, not by individual vehicles. Vehicle.seating_capacity
   * remains as a nullable per-vehicle override for refitted /
   * non-standard vehicles.
   */
  @Column({ type: 'int', nullable: true })
  seating_capacity: number | null;

  /**
   * Operational cap — the planning maximum used by quote/booking
   * pax-to-vehicle math (≤ seating_capacity). Often lower than
   * seating because of luggage / comfort / safety policy. The
   * Movement Chart uses this when grouping pax across vehicles.
   */
  @Column({ type: 'int', nullable: true })
  operational_cap: number | null;

  @Column({ type: 'boolean', default: true })
  is_active: boolean;

  @Column({ type: 'boolean', default: false })
  is_system: boolean;
}
