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:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "dhv2-api",
|
||||
"version": "0.29.0-1",
|
||||
"version": "0.29.0-2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dhv2-api",
|
||||
"version": "0.29.0-1",
|
||||
"version": "0.29.0-2",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dhv2-api",
|
||||
"version": "0.29.0-1",
|
||||
"version": "0.29.0-2",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,7 +20,7 @@ test('F4 WEB has an explicit LOCKED and SEALED act contract', () => {
|
||||
assert.match(f4Api, /lockedAt: string \| null/);
|
||||
assert.match(f4Api, /lockedSha256: string \| null/);
|
||||
assert.match(f4Api, /sealedAt: string \| null/);
|
||||
assert.match(f4Api, /urgency: InspectionActUrgencyF4/);
|
||||
assert.match(f4Api, /urgency: InspectionActUrgencyF4 \| null/);
|
||||
assert.match(f4Api, /deadlineAt: string \| null/);
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ test('F4 Android uses only lock and seal endpoints for the active Act lifecycle'
|
||||
});
|
||||
|
||||
test('F4 Android ViewModel calls lock and seal directly', () => {
|
||||
assert.match(viewModel, /actsRepository\.lock\(actId\)/);
|
||||
assert.match(viewModel, /actsRepository\.lock\(actId, urgency\)/);
|
||||
assert.match(viewModel, /actsRepository\.seal\(actId\)/);
|
||||
assert.doesNotMatch(viewModel, /actsRepository\.prepare\(/);
|
||||
assert.doesNotMatch(viewModel, /actsRepository\.reopen\(/);
|
||||
|
||||
@@ -10,8 +10,8 @@ function mountedRepoFile(path: string): string {
|
||||
test('F6.3 Android test cut targets production API and has a distinct installable debug version', () => {
|
||||
const gradle = mountedRepoFile('android-app/app/build.gradle.kts');
|
||||
|
||||
assert.match(gradle, /versionCode = 29/);
|
||||
assert.match(gradle, /versionName = "0\.19\.1"/);
|
||||
assert.match(gradle, /versionCode = 30/);
|
||||
assert.match(gradle, /versionName = "0\.19\.2"/);
|
||||
assert.match(gradle, /https:\/\/dhv2\.korexlabs\.com\/api\/v3\//);
|
||||
assert.match(gradle, /applicationIdSuffix = "\.debug"/);
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ test('F6.3 an Acta can start empty and receive Inventory when Hallazgos are adde
|
||||
|
||||
assert.doesNotMatch(dto, /ArrayMinSize\(1\)/);
|
||||
assert.match(service, /if \(assetIds\.length === 0\) return/);
|
||||
assert.match(mobile, /assetIds = listOfNotNull\(assetId\)/);
|
||||
assert.match(mobile, /assetIds = emptyList\(\)/);
|
||||
});
|
||||
|
||||
test('F6.3 every Installation and Subinstallation receives the common field card', () => {
|
||||
@@ -35,15 +35,30 @@ test('F6.3 every Installation and Subinstallation receives the common field card
|
||||
});
|
||||
|
||||
test('F6.3 Android follows Inspección → Acta → Hallazgo → Inventario', () => {
|
||||
const root = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/F3VisitRoot.kt');
|
||||
const acts = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/MobileActsScreen.kt');
|
||||
const root = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernVisitRoot.kt');
|
||||
const acts = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernMobileActsScreen.kt');
|
||||
const vm = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/MainViewModel.kt');
|
||||
|
||||
assert.match(root, /model\.startVisit\(\); onActs\(\)/);
|
||||
assert.match(root, /Text\("Nuevo Hallazgo"/);
|
||||
assert.match(root, /Buscar instalación o subinstalación/);
|
||||
assert.match(acts, /Text\("\+ Agregar Hallazgo"\)/);
|
||||
assert.match(acts, /model\.createAct\(newActUrgency\)/);
|
||||
assert.match(vm, /fun createAct\(urgency: String = "NON_URGENT"\)/);
|
||||
assert.doesNotMatch(root, /Text\("Inventario de campo"/);
|
||||
assert.match(acts, /Text\("Agregar Hallazgo"\)/);
|
||||
assert.match(acts, /model\.createAct\(\)/);
|
||||
assert.match(acts, /model\.prepareSelectedAct\(closingUrgency\)/);
|
||||
assert.match(vm, /fun createAct\(\)/);
|
||||
assert.match(vm, /fun prepareSelectedAct\(urgency: String\)/);
|
||||
assert.match(vm, /repository\.fieldInventory\(currentVisit\.id, search, parentId\)/);
|
||||
});
|
||||
|
||||
test('F6.1 Acta urgency is null while drafting and is persisted atomically at lock', () => {
|
||||
const createDto = source('src/inspection-acts/dto/create-inspection-act.dto.ts');
|
||||
const prepareDto = source('src/inspection-closing/dto/prepare-inspection-act.dto.ts');
|
||||
const actsService = source('src/inspection-acts/inspection-acts.service.ts');
|
||||
const closingService = source('src/inspection-closing/inspection-closing.service.ts');
|
||||
const migration = source('src/database/migrations/1790113800000-f6-1-act-urgency-at-lock.ts');
|
||||
|
||||
assert.doesNotMatch(createDto, /urgency/);
|
||||
assert.match(prepareDto, /urgency!: InspectionActUrgency/);
|
||||
assert.match(actsService, /urgency: null/);
|
||||
assert.match(closingService, /urgency=\$2/);
|
||||
assert.match(migration, /ALTER COLUMN urgency DROP NOT NULL/);
|
||||
});
|
||||
|
||||
@@ -5,21 +5,18 @@ import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { CancelInspectionActDto } from '../../src/inspection-acts/dto/cancel-inspection-act.dto';
|
||||
import { CreateInspectionActDto } from '../../src/inspection-acts/dto/create-inspection-act.dto';
|
||||
import { InspectionActUrgency } from '../../src/database/entities';
|
||||
|
||||
const ASSET_ID = '16e54e65-60cf-4739-b0d1-ccdd904fbfd5';
|
||||
|
||||
test('inspection act DTO accepts urgency, content and selected visit assets', async () => {
|
||||
test('inspection act DTO accepts content and selected visit assets without deciding urgency', async () => {
|
||||
const dto = plainToInstance(CreateInspectionActDto, {
|
||||
occurredAt: '2026-08-14T15:30:00.000Z',
|
||||
urgency: InspectionActUrgency.NON_URGENT,
|
||||
title: ' Verificación de instalación ',
|
||||
summary: ' Se inspeccionó el activo seleccionado. ',
|
||||
observations: ' Sin novedades. ',
|
||||
assetIds: [ASSET_ID],
|
||||
});
|
||||
assert.deepEqual(await validate(dto), []);
|
||||
assert.equal(dto.urgency, InspectionActUrgency.NON_URGENT);
|
||||
assert.equal(dto.title, 'Verificación de instalación');
|
||||
assert.equal(dto.summary, 'Se inspeccionó el activo seleccionado.');
|
||||
assert.equal(dto.observations, 'Sin novedades.');
|
||||
@@ -28,7 +25,6 @@ test('inspection act DTO accepts urgency, content and selected visit assets', as
|
||||
test('inspection act DTO rejects duplicate assets', async () => {
|
||||
const dto = plainToInstance(CreateInspectionActDto, {
|
||||
occurredAt: '2026-08-14T15:30:00.000Z',
|
||||
urgency: InspectionActUrgency.NON_URGENT,
|
||||
title: 'Acta',
|
||||
summary: 'Contenido',
|
||||
assetIds: [ASSET_ID, ASSET_ID],
|
||||
|
||||
@@ -5,6 +5,8 @@ import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { CreateCompanyOutcomeDto } from '../../src/inspection-closing/dto/create-company-outcome.dto';
|
||||
import { CreateInspectionSignatureDto } from '../../src/inspection-closing/dto/create-inspection-signature.dto';
|
||||
import { PrepareInspectionActDto } from '../../src/inspection-closing/dto/prepare-inspection-act.dto';
|
||||
import { InspectionActUrgency } from '../../src/database/entities';
|
||||
import { UpsertInspectionResponsibleDto } from '../../src/inspection-closing/dto/upsert-inspection-responsible.dto';
|
||||
|
||||
test('D5 present responsible requires identity and position', async () => {
|
||||
@@ -54,3 +56,13 @@ test('D5 signature DTO transforms multipart consent and coordinates', async () =
|
||||
assert.equal(dto.consentAccepted, true);
|
||||
assert.equal(dto.latitude, -32.889458);
|
||||
});
|
||||
|
||||
|
||||
test('F6.1 urgency is selected when the Acta is closed, not when it is created', async () => {
|
||||
const urgent = plainToInstance(PrepareInspectionActDto, { urgency: InspectionActUrgency.URGENT });
|
||||
const nonUrgent = plainToInstance(PrepareInspectionActDto, { urgency: InspectionActUrgency.NON_URGENT });
|
||||
const invalid = plainToInstance(PrepareInspectionActDto, { urgency: 'UNKNOWN' });
|
||||
assert.deepEqual(await validate(urgent), []);
|
||||
assert.deepEqual(await validate(nonUrgent), []);
|
||||
assert.equal((await validate(invalid)).some((error) => error.property === 'urgency'), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user