Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 5m31s
Android CI / RC / Android · lint, tests, debug APK, release compile (pull_request) Successful in 5m30s
DH V2 CI / API · typecheck, tests, build (pull_request) Successful in 33s
DH V2 CI / WEB · typecheck, build (pull_request) Successful in 18s
Inspection planning smoke / F6.1 · real inspection create (pull_request) Failing after 1m33s
Production dependency audit / API · production dependencies (pull_request) Successful in 9s
Production dependency audit / WEB · production dependencies (pull_request) Successful in 9s
DH V2 CI / Docker / scripts contract (pull_request) Successful in 1m5s
128 lines
4.1 KiB
TypeScript
128 lines
4.1 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum InspectionActStatus {
|
|
DRAFT = 'DRAFT',
|
|
LOCKED = 'LOCKED',
|
|
SEALED = 'SEALED',
|
|
READY = 'READY',
|
|
CLOSED = 'CLOSED',
|
|
CANCELLED = 'CANCELLED',
|
|
RECTIFIED = 'RECTIFIED',
|
|
}
|
|
|
|
export enum InspectionActUrgency {
|
|
URGENT = 'URGENT',
|
|
NON_URGENT = 'NON_URGENT',
|
|
}
|
|
|
|
export enum InspectionDeadlineDayType {
|
|
BUSINESS = 'BUSINESS',
|
|
CALENDAR = 'CALENDAR',
|
|
}
|
|
|
|
export enum InspectionDeadlineBasis {
|
|
ACT_DATE = 'ACT_DATE',
|
|
// La columna F4 temprana usó GEDO_DATE. Se conserva el valor físico por
|
|
// compatibilidad de migración, pero funcionalmente significa "pendiente de
|
|
// fecha de notificación" hasta que el procedimiento defina el evento válido.
|
|
NOTIFICATION_DATE = 'GEDO_DATE',
|
|
GEDO_DATE = 'GEDO_DATE',
|
|
}
|
|
|
|
// Una Inspección puede acumular múltiples Actas. El índice parcial de DRAFT es
|
|
// deliberado: permite el historial multi-Acta y bloquea dos borradores simultáneos.
|
|
@Entity({ name: 'inspection_acts' })
|
|
@Index('uq_inspection_acts_one_draft_per_visit', ['visitId'], { unique: true, where: "status = 'DRAFT'" })
|
|
@Index('uq_inspection_acts_year_number', ['actYear', 'actNumber'], { unique: true })
|
|
@Index('uq_inspection_acts_code', ['code'], { unique: true })
|
|
@Index('idx_inspection_acts_visit_status', ['visitId', 'status'])
|
|
@Index('idx_inspection_acts_occurred_at', ['occurredAt'])
|
|
@Index('idx_inspection_acts_created_by', ['createdBy'])
|
|
@Index('idx_inspection_acts_deadline', ['deadlineAt'])
|
|
export class InspectionAct extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'visit_id', type: 'uuid' })
|
|
visitId!: string;
|
|
|
|
@Column({ name: 'act_year', type: 'integer' })
|
|
actYear!: number;
|
|
|
|
@Column({ name: 'act_number', type: 'integer' })
|
|
actNumber!: number;
|
|
|
|
@Column({ type: 'varchar', length: 40 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'varchar', length: 24, default: InspectionActStatus.DRAFT })
|
|
status!: InspectionActStatus;
|
|
|
|
@Column({ name: 'occurred_at', type: 'timestamptz' })
|
|
occurredAt!: Date;
|
|
|
|
@Column({ type: 'varchar', length: 200 })
|
|
title!: string;
|
|
|
|
@Column({ type: 'text' })
|
|
summary!: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
observations!: string | null;
|
|
|
|
@Column({ name: 'urgency', type: 'varchar', length: 24, nullable: true })
|
|
urgency!: InspectionActUrgency | null;
|
|
|
|
@Column({ name: 'deadline_days', type: 'integer', nullable: true })
|
|
deadlineDays!: number | null;
|
|
|
|
@Column({ name: 'deadline_day_type', type: 'varchar', length: 24, nullable: true })
|
|
deadlineDayType!: InspectionDeadlineDayType | null;
|
|
|
|
@Column({ name: 'deadline_basis', type: 'varchar', length: 24, nullable: true })
|
|
deadlineBasis!: InspectionDeadlineBasis | null;
|
|
|
|
@Column({ name: 'deadline_base_at', type: 'timestamptz', nullable: true })
|
|
deadlineBaseAt!: Date | null;
|
|
|
|
@Column({ name: 'deadline_at', type: 'timestamptz', nullable: true })
|
|
deadlineAt!: Date | null;
|
|
|
|
@Column({ name: 'locked_at', type: 'timestamptz', nullable: true })
|
|
lockedAt!: Date | null;
|
|
|
|
@Column({ name: 'locked_by', type: 'uuid', nullable: true })
|
|
lockedBy!: string | null;
|
|
|
|
@Column({ name: 'locked_sha256', type: 'char', length: 64, nullable: true })
|
|
lockedSha256!: string | null;
|
|
|
|
@Column({ name: 'sealed_at', type: 'timestamptz', nullable: true })
|
|
sealedAt!: Date | null;
|
|
|
|
@Column({ name: 'sealed_by', type: 'uuid', nullable: true })
|
|
sealedBy!: string | null;
|
|
|
|
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
|
currentVersion!: number;
|
|
|
|
@Column({ name: 'cancellation_reason', type: 'text', nullable: true })
|
|
cancellationReason!: string | null;
|
|
|
|
@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_sha256', type: 'char', length: 64, nullable: true })
|
|
closureSha256!: string | null;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy!: string | null;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy!: string | null;
|
|
}
|