fix(android): align Acta flow and defer urgency to close
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
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
This commit is contained in:
@@ -71,8 +71,8 @@ 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: 'urgency', type: 'varchar', length: 24, nullable: true })
|
||||
urgency!: InspectionActUrgency | null;
|
||||
|
||||
@Column({ name: 'deadline_days', type: 'integer', nullable: true })
|
||||
deadlineDays!: number | null;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class F61ActUrgencyAtLock1790113800000 implements MigrationInterface {
|
||||
name = 'F61ActUrgencyAtLock1790113800000';
|
||||
|
||||
public async up(q: QueryRunner): Promise<void> {
|
||||
await q.query(`ALTER TABLE inspection_acts ALTER COLUMN urgency DROP DEFAULT`);
|
||||
await q.query(`ALTER TABLE inspection_acts ALTER COLUMN urgency DROP NOT NULL`);
|
||||
}
|
||||
|
||||
public async down(q: QueryRunner): Promise<void> {
|
||||
await q.query(`UPDATE inspection_acts SET urgency='NON_URGENT' WHERE urgency IS NULL`);
|
||||
await q.query(`ALTER TABLE inspection_acts ALTER COLUMN urgency SET NOT NULL`);
|
||||
await q.query(`ALTER TABLE inspection_acts ALTER COLUMN urgency SET DEFAULT 'NON_URGENT'`);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
ArrayMaxSize,
|
||||
ArrayUnique,
|
||||
IsArray,
|
||||
IsEnum,
|
||||
IsISO8601,
|
||||
IsOptional,
|
||||
IsString,
|
||||
@@ -11,15 +10,11 @@ import {
|
||||
MaxLength,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
import { InspectionActUrgency } from '../../database/entities';
|
||||
|
||||
export class CreateInspectionActDto {
|
||||
@IsISO8601({ strict: true })
|
||||
occurredAt!: string;
|
||||
|
||||
@IsEnum(InspectionActUrgency)
|
||||
urgency!: InspectionActUrgency;
|
||||
|
||||
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
ArrayMinSize,
|
||||
ArrayUnique,
|
||||
IsArray,
|
||||
IsEnum,
|
||||
IsISO8601,
|
||||
IsOptional,
|
||||
IsString,
|
||||
@@ -12,17 +11,12 @@ import {
|
||||
MaxLength,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
import { InspectionActUrgency } from '../../database/entities';
|
||||
|
||||
export class UpdateInspectionActDto {
|
||||
@IsOptional()
|
||||
@IsISO8601({ strict: true })
|
||||
occurredAt?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(InspectionActUrgency)
|
||||
urgency?: InspectionActUrgency;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
||||
@IsString()
|
||||
|
||||
@@ -74,7 +74,7 @@ export interface InspectionActListItem {
|
||||
title: string;
|
||||
summary: string;
|
||||
observations: string | null;
|
||||
urgency: InspectionActUrgency;
|
||||
urgency: InspectionActUrgency | null;
|
||||
deadlineDays: number | null;
|
||||
deadlineDayType: InspectionDeadlineDayType | null;
|
||||
deadlineBasis: InspectionDeadlineBasis | null;
|
||||
@@ -314,7 +314,7 @@ export class InspectionActsService {
|
||||
title: dto.title,
|
||||
summary: dto.summary,
|
||||
observations: dto.observations ?? null,
|
||||
urgency: dto.urgency,
|
||||
urgency: null,
|
||||
deadlineDays: null,
|
||||
deadlineDayType: null,
|
||||
deadlineBasis: null,
|
||||
@@ -379,7 +379,6 @@ export class InspectionActsService {
|
||||
await this.assertVisitAssets(manager, visit.id, nextAssetIds);
|
||||
const before = await this.loadView(manager, id);
|
||||
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.summary !== undefined) act.summary = dto.summary;
|
||||
if (dto.observations !== undefined) act.observations = dto.observations;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { IsEnum } from 'class-validator';
|
||||
import { InspectionActUrgency } from '../../database/entities';
|
||||
|
||||
export class PrepareInspectionActDto {
|
||||
@IsEnum(InspectionActUrgency)
|
||||
urgency!: InspectionActUrgency;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import { CurrentAuth } from '../auth/decorators/current-auth.decorator';
|
||||
import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
||||
import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context';
|
||||
import { CloseInspectionActDto } from './dto/close-inspection-act.dto';
|
||||
import { PrepareInspectionActDto } from './dto/prepare-inspection-act.dto';
|
||||
import { CreateCompanyOutcomeDto } from './dto/create-company-outcome.dto';
|
||||
import { CreateInspectionSignatureDto } from './dto/create-inspection-signature.dto';
|
||||
import { CreateCompanySignatureDto } from './dto/create-company-signature.dto';
|
||||
@@ -52,10 +53,11 @@ export class InspectionClosingController {
|
||||
@RequirePermissions('inspection_closure.prepare')
|
||||
lock(
|
||||
@Param('actId', new ParseUUIDPipe({ version: '4' })) actId: string,
|
||||
@Body() dto: PrepareInspectionActDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.closing.prepare(actId, principal, request);
|
||||
return this.closing.prepare(actId, dto, principal, request);
|
||||
}
|
||||
|
||||
@Post('signatures/inspector')
|
||||
|
||||
@@ -35,6 +35,7 @@ import { assertMobileInspector } from '../inspection-operations/mobile-inspector
|
||||
import { InspectionReportsService } from '../inspection-reports/inspection-reports.service';
|
||||
import { sha256CanonicalJson } from './canonical-json';
|
||||
import type { CloseInspectionActDto } from './dto/close-inspection-act.dto';
|
||||
import type { PrepareInspectionActDto } from './dto/prepare-inspection-act.dto';
|
||||
import type { CreateCompanyOutcomeDto } from './dto/create-company-outcome.dto';
|
||||
import type { CreateCompanySignatureDto } from './dto/create-company-signature.dto';
|
||||
import type { CreateInspectionSignatureDto } from './dto/create-inspection-signature.dto';
|
||||
@@ -130,7 +131,7 @@ export interface InspectionClosureView {
|
||||
code: string;
|
||||
status: InspectionActStatus;
|
||||
visitId: string;
|
||||
urgency: InspectionActUrgency;
|
||||
urgency: InspectionActUrgency | null;
|
||||
deadlineDays: number | null;
|
||||
deadlineDayType: InspectionDeadlineDayType | null;
|
||||
deadlineBasis: InspectionDeadlineBasis | null;
|
||||
@@ -268,6 +269,7 @@ export class InspectionClosingService {
|
||||
/** Finaliza el contenido: desde este punto el Acta queda inmutable. */
|
||||
async prepare(
|
||||
actId: string,
|
||||
dto: PrepareInspectionActDto,
|
||||
principal: AuthPrincipal,
|
||||
request: RequestWithContext,
|
||||
): Promise<InspectionClosureView> {
|
||||
@@ -285,16 +287,16 @@ export class InspectionClosingService {
|
||||
}
|
||||
|
||||
const policy = await this.deadlinePolicy(manager);
|
||||
const deadlineDays = act.urgency === InspectionActUrgency.URGENT
|
||||
const deadlineDays = dto.urgency === InspectionActUrgency.URGENT
|
||||
? policy.urgentDays
|
||||
: policy.nonUrgentDays;
|
||||
const deadlineDayType = act.urgency === InspectionActUrgency.URGENT
|
||||
const deadlineDayType = dto.urgency === InspectionActUrgency.URGENT
|
||||
? policy.urgentDayType
|
||||
: policy.nonUrgentDayType;
|
||||
const deadlineBasis = act.urgency === InspectionActUrgency.URGENT
|
||||
const deadlineBasis = dto.urgency === InspectionActUrgency.URGENT
|
||||
? InspectionDeadlineBasis.ACT_DATE
|
||||
: InspectionDeadlineBasis.GEDO_DATE;
|
||||
const deadlineBaseAt = act.urgency === InspectionActUrgency.URGENT
|
||||
const deadlineBaseAt = dto.urgency === InspectionActUrgency.URGENT
|
||||
? act.occurredAt
|
||||
: null;
|
||||
const deadlineAt = deadlineBaseAt
|
||||
@@ -305,20 +307,22 @@ export class InspectionClosingService {
|
||||
const [updated] = (await manager.query(`
|
||||
UPDATE inspection_acts
|
||||
SET status='LOCKED',
|
||||
deadline_days=$2,
|
||||
deadline_day_type=$3,
|
||||
deadline_basis=$4,
|
||||
deadline_base_at=$5,
|
||||
deadline_at=$6,
|
||||
locked_at=$7,
|
||||
locked_by=$8,
|
||||
urgency=$2,
|
||||
deadline_days=$3,
|
||||
deadline_day_type=$4,
|
||||
deadline_basis=$5,
|
||||
deadline_base_at=$6,
|
||||
deadline_at=$7,
|
||||
locked_at=$8,
|
||||
locked_by=$9,
|
||||
current_version=current_version+1,
|
||||
updated_by=$8,
|
||||
updated_at=$7
|
||||
updated_by=$9,
|
||||
updated_at=$8
|
||||
WHERE id=$1
|
||||
RETURNING current_version AS "versionNumber"
|
||||
`, [
|
||||
actId,
|
||||
dto.urgency,
|
||||
deadlineDays,
|
||||
deadlineDayType,
|
||||
deadlineBasis,
|
||||
@@ -1009,7 +1013,7 @@ export class InspectionClosingService {
|
||||
WHERE act.id=$1
|
||||
`, [actId]) as Array<{
|
||||
id: string; code: string; status: InspectionActStatus; visitId: string;
|
||||
urgency: InspectionActUrgency; deadlineDays: number | null;
|
||||
urgency: InspectionActUrgency | null; deadlineDays: number | null;
|
||||
deadlineDayType: InspectionDeadlineDayType | null; deadlineBasis: InspectionDeadlineBasis | null;
|
||||
deadlineBaseAt: Date | null; deadlineAt: Date | null; lockedAt: Date | null;
|
||||
lockedSha256: string | null; sealedAt: Date | null; currentVersion: number;
|
||||
|
||||
Reference in New Issue
Block a user