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

@Entity({ name: 'transfer_orders', schema: 'inventory' })
export class TransferOrder {
  @PrimaryGeneratedColumn('uuid')
  id: string;

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

  @Column({ name: 'transfer_number', type: 'varchar', length: 30 })
  transferNumber: string;

  @Index()
  @Column({ name: 'source_warehouse_id', type: 'uuid' })
  sourceWarehouseId: string;

  @Index()
  @Column({ name: 'dest_warehouse_id', type: 'uuid' })
  destWarehouseId: string;

  @Column({ name: 'scheduled_date', type: 'date', nullable: true })
  scheduledDate?: Date;

  @Column({ name: 'shipped_at', type: 'timestamptz', nullable: true })
  shippedAt?: Date;

  @Column({ name: 'received_at', type: 'timestamptz', nullable: true })
  receivedAt?: Date;

  @Index()
  @Column({ type: 'varchar', length: 20, default: 'draft' })
  status: 'draft' | 'confirmed' | 'shipped' | 'in_transit' | 'received' | 'cancelled';

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

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

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

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

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