From 48bbe293d94a68be8addb951ac8cdb90e4d7b8ee Mon Sep 17 00:00:00 2001 From: enlineawork Date: Mon, 7 Sep 2026 20:43:40 -0300 Subject: [PATCH] feat(f4): extend act lifecycle and deadline snapshot --- .../entities/inspection-act.entity.ts | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/api-v3/src/database/entities/inspection-act.entity.ts b/api-v3/src/database/entities/inspection-act.entity.ts index d7e57be..3e9021f 100644 --- a/api-v3/src/database/entities/inspection-act.entity.ts +++ b/api-v3/src/database/entities/inspection-act.entity.ts @@ -3,12 +3,29 @@ 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', + GEDO_DATE = 'GEDO_DATE', +} + @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 }) @@ -16,6 +33,7 @@ export enum InspectionActStatus { @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; @@ -29,7 +47,7 @@ export class InspectionAct extends TimestampedEntity { @Column({ name: 'act_number', type: 'integer' }) actNumber!: number; - @Column({ type: 'varchar', length: 24 }) + @Column({ type: 'varchar', length: 40 }) code!: string; @Column({ type: 'varchar', length: 24, default: InspectionActStatus.DRAFT }) @@ -47,6 +65,39 @@ export class InspectionAct extends TimestampedEntity { @Column({ type: 'text', nullable: true }) observations!: string | null; + @Column({ name: 'urgency', type: 'varchar', length: 24, default: InspectionActUrgency.NON_URGENT }) + urgency!: InspectionActUrgency; + + @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;