import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { StateCodeEntity } from './state-codes.entity';

@Entity('penal_code')
export class StateCodeChargeEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) title_id: number;
    @Column({ type: 'int' }) code_id: number;
    @Column({ type: 'varchar', length: 12 }) type: 'felony' | 'misdemeanor' | 'infraction';
    @Column({ type: 'varchar', length: 40 }) number: string;
    @Column({ type: 'varchar', length: 100 }) name: string;
    @Column({ type: 'longtext' }) description: string;
    @Column({ type: 'boolean' }) can_be_attempt: boolean;
    @Column({ type: 'boolean' }) can_be_conspiracy: boolean;
    @Column({ type: 'boolean' }) can_be_soliciting: boolean;
    @Column({ type: 'boolean' }) can_be_armed: boolean;
    @Column({ type: 'boolean', default: null, nullable: true }) can_be_impounded: boolean | null;
    @Column({ type: 'boolean', default: null, nullable: true }) can_be_revoked: boolean | null;
    @Column({ type: 'boolean', default: null, nullable: true }) can_be_revoked_permit: boolean | null;
    @Column({ type: 'int', default: null, nullable: true }) license_point: number | null;
    @Column({ type: 'int' }) penalty: number;
    @Column({ type: 'int' }) penalty_hours: number;
    @Column({ type: 'longtext', nullable: true, default: null }) notes: string | null;

    @ManyToOne(() => StateCodeEntity)
    @JoinColumn({
        name: 'code_id',
    })
    code: StateCodeEntity;

    titleAbbreviation?: string;
}
