109 lines
3.5 KiB
TypeScript
109 lines
3.5 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum InspectionFindingResponseDueBasis {
|
|
FINDING_DATE = 'FINDING_DATE',
|
|
REPORT_NOTIFICATION = 'REPORT_NOTIFICATION',
|
|
}
|
|
|
|
export enum InspectionFindingStatus {
|
|
OPEN = 'OPEN',
|
|
CLOSED = 'CLOSED',
|
|
VOIDED = 'VOIDED',
|
|
}
|
|
|
|
@Entity({ name: 'inspection_findings' })
|
|
@Index('uq_inspection_findings_number', ['actId', 'findingNumber'], { unique: true })
|
|
@Index('uq_inspection_findings_code', ['code'], { unique: true })
|
|
@Index('idx_inspection_findings_status_control', ['status', 'nextControlOn'])
|
|
@Index('idx_inspection_findings_asset_status', ['assetId', 'status'])
|
|
@Index('idx_inspection_findings_catalog_item', ['catalogItemId'])
|
|
export class InspectionFinding extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'act_id', type: 'uuid' })
|
|
actId!: string;
|
|
|
|
@Column({ name: 'asset_id', type: 'uuid' })
|
|
assetId!: string;
|
|
|
|
@Column({ name: 'catalog_item_id', type: 'uuid', nullable: true })
|
|
catalogItemId!: string | null;
|
|
|
|
@Column({ name: 'finding_number', type: 'integer' })
|
|
findingNumber!: number;
|
|
|
|
@Column({ type: 'varchar', length: 40 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'varchar', length: 20, default: InspectionFindingStatus.OPEN })
|
|
status!: InspectionFindingStatus;
|
|
|
|
@Column({ type: 'varchar', length: 500 })
|
|
title!: string;
|
|
|
|
@Column({ type: 'text' })
|
|
description!: string;
|
|
|
|
@Column({ name: 'legal_basis', type: 'text', nullable: true })
|
|
legalBasis!: string | null;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
glossary!: string | null;
|
|
|
|
@Column({ name: 'catalog_revision', type: 'integer', nullable: true })
|
|
catalogRevision!: number | null;
|
|
|
|
@Column({ name: 'suggested_severity', type: 'smallint', nullable: true })
|
|
suggestedSeverity!: number | null;
|
|
|
|
@Column({ type: 'smallint', nullable: true })
|
|
severity!: number | null;
|
|
|
|
@Column({ name: 'correction_due_on', type: 'date', nullable: true })
|
|
correctionDueOn!: string | null;
|
|
|
|
@Column({ name: 'response_due_basis', type: 'varchar', length: 32, nullable: true })
|
|
responseDueBasis!: InspectionFindingResponseDueBasis | null;
|
|
|
|
@Column({ name: 'response_due_days', type: 'integer', nullable: true })
|
|
responseDueDays!: number | null;
|
|
|
|
@Column({ name: 'response_due_base_on', type: 'date', nullable: true })
|
|
responseDueBaseOn!: string | null;
|
|
|
|
@Column({ name: 'report_notified_on', type: 'date', nullable: true })
|
|
reportNotifiedOn!: string | null;
|
|
|
|
@Column({ name: 'company_response', type: 'text', nullable: true })
|
|
companyResponse!: string | null;
|
|
|
|
@Column({ name: 'company_response_received_on', type: 'date', nullable: true })
|
|
companyResponseReceivedOn!: string | null;
|
|
|
|
@Column({ name: 'company_committed_correction_on', type: 'date', nullable: true })
|
|
companyCommittedCorrectionOn!: string | null;
|
|
|
|
@Column({ name: 'next_control_on', type: 'date', nullable: true })
|
|
nextControlOn!: string | null;
|
|
|
|
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
|
currentVersion!: number;
|
|
|
|
@Column({ name: 'closed_at', type: 'timestamptz', nullable: true })
|
|
closedAt!: Date | null;
|
|
|
|
@Column({ name: 'closed_by', type: 'uuid', nullable: true })
|
|
closedBy!: string | null;
|
|
|
|
@Column({ name: 'closure_notes', type: 'text', nullable: true })
|
|
closureNotes!: string | null;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy!: string | null;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
}
|