/**
 * Prototipo Entity
 * Prototipos de vivienda (modelos)
 *
 * @module Construction
 */

import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  Index,
} from 'typeorm';

@Entity({ schema: 'construction', name: 'prototipos' })
@Index(['tenantId', 'code'], { unique: true })
export class Prototipo {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'tenant_id', type: 'uuid' })
  tenantId: string;

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

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

  @Column({ type: 'text', nullable: true })
  description: string;

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

  @Column({ name: 'area_construction_m2', type: 'decimal', precision: 10, scale: 2, nullable: true })
  areaConstructionM2: number;

  @Column({ name: 'area_terrain_m2', type: 'decimal', precision: 10, scale: 2, nullable: true })
  areaTerrainM2: number;

  @Column({ type: 'integer', default: 0 })
  bedrooms: number;

  @Column({ type: 'decimal', precision: 3, scale: 1, default: 0 })
  bathrooms: number;

  @Column({ name: 'parking_spaces', type: 'integer', default: 0 })
  parkingSpaces: number;

  @Column({ type: 'integer', default: 1 })
  floors: number;

  @Column({ name: 'base_price', type: 'decimal', precision: 14, scale: 2, nullable: true })
  basePrice: number;

  @Column({ name: 'blueprint_url', type: 'varchar', length: 500, nullable: true })
  blueprintUrl: string;

  @Column({ name: 'render_url', type: 'varchar', length: 500, nullable: true })
  renderUrl: string;

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

  @Column({ type: 'jsonb', default: {} })
  metadata: Record<string, unknown>;

  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
  createdAt: Date;

  @Column({ name: 'created_by', type: 'uuid', nullable: true })
  createdBy: string;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz', nullable: true })
  updatedAt: Date;

  @Column({ name: 'updated_by', type: 'uuid', nullable: true })
  updatedBy: string;

  @Column({ name: 'deleted_at', type: 'timestamptz', nullable: true })
  deletedAt: Date;
}
