import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, OneToMany } from 'typeorm';
import { Certidao } from './certidao.entity';

@Entity('fornecedores')
export class Fornecedor {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 10 })
  tipo_pessoa: string;

  @Column({ unique: true, length: 18 })
  cpf_cnpj: string;

  @Column({ length: 300 })
  razao_social: string;

  @Column({ length: 300, nullable: true })
  nome_fantasia: string;

  @Column({ length: 255, nullable: true })
  email: string;

  @Column({ length: 20, nullable: true })
  telefone: string;

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

  @Column({ type: 'simple-json', nullable: true })
  categorias_atendidas: string[];

  @Column({ type: 'float', default: 3.0 })
  rating: number;

  @Column({ nullable: true })
  usuario_id: string;

  @Column({ length: 200, nullable: true })
  nome_contato: string;

  @Column({ default: false })
  possui_politica_ambiental: boolean;

  @Column({ default: false })
  possui_politica_sst: boolean;

  @Column({ default: false })
  declara_uso_epi: boolean;

  @Column({ default: false })
  equipe_treinada: boolean;

  @Column({ length: 20, nullable: true })
  classificacao_esg: string;

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

  @OneToMany(() => Certidao, c => c.fornecedor)
  certidoes: Certidao[];

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}
