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

@Entity('tenant_plans', { schema: 'auth' })
export class TenantPlan {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 100, unique: true })
  name: string;

  @Column({ length: 50, unique: true })
  code: string;

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

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

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

  // Limites del plan
  @Column({ type: 'int', default: 5 })
  max_users: number;

  @Column({ type: 'int', default: 10 })
  max_clients: number;

  @Column({ type: 'int', default: 20 })
  max_brands: number;

  @Column({ type: 'int', default: 100 })
  max_generations_month: number;

  @Column({ type: 'bigint', default: 5368709120 }) // 5GB default
  max_storage_bytes: number;

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

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

  @Column({ type: 'jsonb', nullable: true })
  features: Record<string, boolean> | null;

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

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

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

  @UpdateDateColumn({ type: 'timestamptz' })
  updated_at: Date;
}
