import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Demanda } from './demanda.entity';

@Entity('itens_linha')
export class ItemLinha {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  demanda_id: string;

  @ManyToOne(() => Demanda, d => d.itens_linha)
  @JoinColumn({ name: 'demanda_id' })
  demanda: Demanda;

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

  @Column({ length: 50, nullable: true })
  tipo: string;

  @Column({ type: 'float', nullable: true })
  quantidade: number;

  @Column({ length: 30, nullable: true })
  unidade: string;

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

  @Column({ default: 0 })
  ordem: number;

  @CreateDateColumn()
  created_at: Date;
}
