import { Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { VehicleEntity } from './vehicle.entity';

@Entity('fines')
export class FineEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', width: 10 }) entity: FineEntities;
    @Column({ type: 'int' }) entity_id: number;
    @Column({ type: 'varchar', width: 60 }) entity_name: string;
    @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) issued_on: Date;
    @Column({ type: 'int' }) issued_by_character_id: number;
    @Column({ type: 'varchar', width: 100 }) issued_by_name: string;
    @Column({ type: 'varchar', width: 156 }) reason: string;
    @Column({ type: 'int' }) amount: number;
    @Column({ type: 'varchar', width: 40 }) location: string;
    @Column({ type: 'varchar', width: 1000 }) issuer_testimony: string;
    @Column({ type: 'datetime', nullable: true, default: null }) paid: Date | null;
    @Column({ type: 'datetime', nullable: true, default: null }) excused: Date | null;
    @Column({ type: 'varchar', width: 100, nullable: true, default: null }) excused_by: string | null;

    @OneToOne(() => VehicleEntity)
    @JoinColumn({
        name: 'entity_id',
        referencedColumnName: 'id',
    })
    vehicle?: VehicleEntity;
}
