import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { TruckingContractEntity } from './trucking-contract.entity';

export type TruckingContractRunStatus = 'in_progress' | 'completed';

@Entity('trucking_contract_runs')
export class TruckingContractRunEntity {
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    contract_id: number;

    @Column()
    character_id: number;

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

    @Column({ type: 'enum', enum: ['in_progress', 'completed'], default: 'in_progress' })
    status: TruckingContractRunStatus;

    @Column({ type: 'timestamp', nullable: true })
    completed_at: Date | null;

    @ManyToOne(() => TruckingContractEntity, { onDelete: 'CASCADE' })
    @JoinColumn({ name: 'contract_id' })
    contract: TruckingContractEntity;
}
