feat(f4): align act numbering and urgency contract
This commit is contained in:
@@ -14,6 +14,9 @@ import {
|
|||||||
DocumentSequenceType,
|
DocumentSequenceType,
|
||||||
InspectionAct,
|
InspectionAct,
|
||||||
InspectionActStatus,
|
InspectionActStatus,
|
||||||
|
InspectionActUrgency,
|
||||||
|
InspectionDeadlineBasis,
|
||||||
|
InspectionDeadlineDayType,
|
||||||
InspectionActVersionEvent,
|
InspectionActVersionEvent,
|
||||||
InspectionVisit,
|
InspectionVisit,
|
||||||
InspectionVisitStatus,
|
InspectionVisitStatus,
|
||||||
@@ -72,6 +75,17 @@ export interface InspectionActListItem {
|
|||||||
title: string;
|
title: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
observations: string | null;
|
observations: string | null;
|
||||||
|
urgency: InspectionActUrgency;
|
||||||
|
deadlineDays: number | null;
|
||||||
|
deadlineDayType: InspectionDeadlineDayType | null;
|
||||||
|
deadlineBasis: InspectionDeadlineBasis | null;
|
||||||
|
deadlineBaseAt: Date | null;
|
||||||
|
deadlineAt: Date | null;
|
||||||
|
lockedAt: Date | null;
|
||||||
|
lockedBy: string | null;
|
||||||
|
lockedSha256: string | null;
|
||||||
|
sealedAt: Date | null;
|
||||||
|
sealedBy: string | null;
|
||||||
currentVersion: number;
|
currentVersion: number;
|
||||||
cancellationReason: string | null;
|
cancellationReason: string | null;
|
||||||
closedAt: Date | null;
|
closedAt: Date | null;
|
||||||
@@ -313,13 +327,16 @@ export class InspectionActsService {
|
|||||||
const occurredAt = new Date(dto.occurredAt);
|
const occurredAt = new Date(dto.occurredAt);
|
||||||
const actYear = await this.yearAtProjectTimezone(manager, occurredAt);
|
const actYear = await this.yearAtProjectTimezone(manager, occurredAt);
|
||||||
const actNumber = await this.allocateNumber(manager, actYear);
|
const actNumber = await this.allocateNumber(manager, actYear);
|
||||||
if (actNumber > 999999) {
|
if (actNumber > 99999) {
|
||||||
throw new ConflictException({
|
throw new ConflictException({
|
||||||
code: 'INSPECTION_ACT_SEQUENCE_EXHAUSTED',
|
code: 'INSPECTION_ACT_SEQUENCE_EXHAUSTED',
|
||||||
message: 'La numeración anual de actas agotó su rango disponible',
|
message: 'La numeración anual de actas agotó su rango disponible',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const code = `ACTA-${actYear}-${String(actNumber).padStart(6, '0')}`;
|
const [dateRow] = (await manager.query(`
|
||||||
|
SELECT TO_CHAR($1::timestamptz AT TIME ZONE 'America/Argentina/Mendoza', 'DD-MM-YY') AS date_part
|
||||||
|
`, [occurredAt])) as Array<{ date_part: string }>;
|
||||||
|
const code = `ACT-${String(actNumber).padStart(5, '0')}-${dateRow.date_part}`;
|
||||||
const act = manager.getRepository(InspectionAct).create({
|
const act = manager.getRepository(InspectionAct).create({
|
||||||
visitId,
|
visitId,
|
||||||
actYear,
|
actYear,
|
||||||
@@ -330,6 +347,17 @@ export class InspectionActsService {
|
|||||||
title: dto.title,
|
title: dto.title,
|
||||||
summary: dto.summary,
|
summary: dto.summary,
|
||||||
observations: dto.observations ?? null,
|
observations: dto.observations ?? null,
|
||||||
|
urgency: dto.urgency,
|
||||||
|
deadlineDays: null,
|
||||||
|
deadlineDayType: null,
|
||||||
|
deadlineBasis: null,
|
||||||
|
deadlineBaseAt: null,
|
||||||
|
deadlineAt: null,
|
||||||
|
lockedAt: null,
|
||||||
|
lockedBy: null,
|
||||||
|
lockedSha256: null,
|
||||||
|
sealedAt: null,
|
||||||
|
sealedBy: null,
|
||||||
currentVersion: 0,
|
currentVersion: 0,
|
||||||
cancellationReason: null,
|
cancellationReason: null,
|
||||||
createdBy: principal.userId,
|
createdBy: principal.userId,
|
||||||
@@ -384,6 +412,7 @@ export class InspectionActsService {
|
|||||||
await this.assertVisitAssets(manager, visit.id, nextAssetIds);
|
await this.assertVisitAssets(manager, visit.id, nextAssetIds);
|
||||||
const before = await this.loadView(manager, id);
|
const before = await this.loadView(manager, id);
|
||||||
if (dto.occurredAt !== undefined) act.occurredAt = nextOccurredAt;
|
if (dto.occurredAt !== undefined) act.occurredAt = nextOccurredAt;
|
||||||
|
if (dto.urgency !== undefined) act.urgency = dto.urgency;
|
||||||
if (dto.title !== undefined) act.title = dto.title;
|
if (dto.title !== undefined) act.title = dto.title;
|
||||||
if (dto.summary !== undefined) act.summary = dto.summary;
|
if (dto.summary !== undefined) act.summary = dto.summary;
|
||||||
if (dto.observations !== undefined) act.observations = dto.observations;
|
if (dto.observations !== undefined) act.observations = dto.observations;
|
||||||
@@ -474,6 +503,17 @@ export class InspectionActsService {
|
|||||||
act.title,
|
act.title,
|
||||||
act.summary,
|
act.summary,
|
||||||
act.observations,
|
act.observations,
|
||||||
|
act.urgency,
|
||||||
|
act.deadline_days AS "deadlineDays",
|
||||||
|
act.deadline_day_type AS "deadlineDayType",
|
||||||
|
act.deadline_basis AS "deadlineBasis",
|
||||||
|
act.deadline_base_at AS "deadlineBaseAt",
|
||||||
|
act.deadline_at AS "deadlineAt",
|
||||||
|
act.locked_at AS "lockedAt",
|
||||||
|
act.locked_by AS "lockedBy",
|
||||||
|
act.locked_sha256 AS "lockedSha256",
|
||||||
|
act.sealed_at AS "sealedAt",
|
||||||
|
act.sealed_by AS "sealedBy",
|
||||||
act.current_version AS "currentVersion",
|
act.current_version AS "currentVersion",
|
||||||
act.cancellation_reason AS "cancellationReason",
|
act.cancellation_reason AS "cancellationReason",
|
||||||
act.closed_at AS "closedAt",
|
act.closed_at AS "closedAt",
|
||||||
@@ -645,7 +685,7 @@ export class InspectionActsService {
|
|||||||
if (rows.length > 0) {
|
if (rows.length > 0) {
|
||||||
throw new ConflictException({
|
throw new ConflictException({
|
||||||
code: 'INSPECTION_VISIT_DRAFT_ACT_ALREADY_EXISTS',
|
code: 'INSPECTION_VISIT_DRAFT_ACT_ALREADY_EXISTS',
|
||||||
message: 'La inspección ya tiene un acta en borrador; preparala o cancelala antes de crear otra',
|
message: 'La inspección ya tiene un acta en borrador; finalizala o cancelala antes de crear otra',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -665,7 +705,7 @@ export class InspectionActsService {
|
|||||||
if (assetIds.length < 1 || Number(row?.count ?? 0) !== assetIds.length) {
|
if (assetIds.length < 1 || Number(row?.count ?? 0) !== assetIds.length) {
|
||||||
throw new BadRequestException({
|
throw new BadRequestException({
|
||||||
code: 'INSPECTION_ACT_ASSET_INVALID',
|
code: 'INSPECTION_ACT_ASSET_INVALID',
|
||||||
message: 'Cada activo del acta debe estar incluido en la visita',
|
message: 'Cada inventario del acta debe estar incluido en la inspección',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -758,6 +798,15 @@ export class InspectionActsService {
|
|||||||
'title', act.title,
|
'title', act.title,
|
||||||
'summary', act.summary,
|
'summary', act.summary,
|
||||||
'observations', act.observations,
|
'observations', act.observations,
|
||||||
|
'urgency', act.urgency,
|
||||||
|
'deadlineDays', act.deadline_days,
|
||||||
|
'deadlineDayType', act.deadline_day_type,
|
||||||
|
'deadlineBasis', act.deadline_basis,
|
||||||
|
'deadlineBaseAt', act.deadline_base_at,
|
||||||
|
'deadlineAt', act.deadline_at,
|
||||||
|
'lockedAt', act.locked_at,
|
||||||
|
'lockedSha256', act.locked_sha256,
|
||||||
|
'sealedAt', act.sealed_at,
|
||||||
'currentVersion', act.current_version,
|
'currentVersion', act.current_version,
|
||||||
'cancellationReason', act.cancellation_reason,
|
'cancellationReason', act.cancellation_reason,
|
||||||
'createdBy', act.created_by,
|
'createdBy', act.created_by,
|
||||||
@@ -804,6 +853,15 @@ export class InspectionActsService {
|
|||||||
title: act.title,
|
title: act.title,
|
||||||
summary: act.summary,
|
summary: act.summary,
|
||||||
observations: act.observations,
|
observations: act.observations,
|
||||||
|
urgency: act.urgency,
|
||||||
|
deadlineDays: act.deadlineDays,
|
||||||
|
deadlineDayType: act.deadlineDayType,
|
||||||
|
deadlineBasis: act.deadlineBasis,
|
||||||
|
deadlineBaseAt: act.deadlineBaseAt,
|
||||||
|
deadlineAt: act.deadlineAt,
|
||||||
|
lockedAt: act.lockedAt,
|
||||||
|
lockedSha256: act.lockedSha256,
|
||||||
|
sealedAt: act.sealedAt,
|
||||||
currentVersion: act.currentVersion,
|
currentVersion: act.currentVersion,
|
||||||
cancellationReason: act.cancellationReason,
|
cancellationReason: act.cancellationReason,
|
||||||
closedAt: act.closedAt,
|
closedAt: act.closedAt,
|
||||||
|
|||||||
Reference in New Issue
Block a user