Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
103ecf2fae | ||
|
|
23880521d9 | ||
|
|
637c28dc2f | ||
|
|
fc0c62c70a | ||
|
|
3ab10b37ea | ||
|
|
c6475c851e | ||
|
|
b757bf7729 | ||
|
|
e30e5d90ea |
@@ -1,15 +1,16 @@
|
|||||||
# Checklist final Android 0.19.1
|
# Checklist final Android 0.19.2
|
||||||
|
|
||||||
La candidata sólo se promueve si el mismo SHA cumple:
|
La candidata sólo se promueve si el mismo SHA cumple:
|
||||||
|
|
||||||
- iniciar Inspección;
|
- iniciar Inspección;
|
||||||
- crear/abrir Acta;
|
- crear/abrir Acta sin pedir urgencia ni Inventario;
|
||||||
- seleccionar o crear Instalación/Subinstalación;
|
- entrar a **Agregar Hallazgo** y recién allí seleccionar o crear Instalación/Subinstalación;
|
||||||
- exigir GPS + fotografía para Inventario nacido en campo antes de Hallazgos;
|
- exigir GPS + fotografía para Inventario nacido en campo antes de Hallazgos;
|
||||||
- registrar Hallazgos sobre el elemento seleccionado;
|
- registrar Hallazgos sobre el elemento seleccionado;
|
||||||
- cerrar contenido del Acta y mostrar **Pendiente de firma**;
|
- al cerrar el contenido, exigir Urgente/No urgente, persistir esa decisión y mostrar **Pendiente de firma**;
|
||||||
- completar firma del Inspector y manifestación/firma o negativa de la empresa;
|
- completar firma del Inspector y manifestación/firma o negativa de la empresa;
|
||||||
- mostrar el Acta como **Firmada y cerrada**;
|
- mostrar el Acta como **Firmada y cerrada**;
|
||||||
- permitir cerrar la Inspección sólo con todas las Actas activas firmadas y cerradas;
|
- permitir cerrar la Inspección sólo con todas las Actas activas firmadas y cerradas;
|
||||||
|
- no mostrar **Inventario de campo** como acción paralela de la Inspección;
|
||||||
- no exponer estados internos en inglés en la interfaz de campo;
|
- no exponer estados internos en inglés en la interfaz de campo;
|
||||||
- Android CI / RC, DH V2 CI y auditoría de dependencias en verde.
|
- Android CI / RC, DH V2 CI y auditoría de dependencias en verde.
|
||||||
|
|||||||
+19
-9
@@ -1,27 +1,28 @@
|
|||||||
# DH Inspección Android · release final de campo 0.19.1
|
# DH Inspección Android · release final de campo 0.19.2
|
||||||
|
|
||||||
## Candidata vigente
|
## Candidata vigente
|
||||||
|
|
||||||
- Fase funcional: **Flujo final de campo · Inspección → Acta → Hallazgos → Firma**.
|
- Fase funcional: **Flujo final de campo · Inspección → Acta → Hallazgos → Firma**.
|
||||||
- `versionName`: **0.19.1**.
|
- `versionName`: **0.19.2**.
|
||||||
- `versionCode`: **29**.
|
- `versionCode`: **30**.
|
||||||
- Application ID release: `com.korexlabs.dhinspeccion`.
|
- Application ID release: `com.korexlabs.dhinspeccion`.
|
||||||
- Application ID debug/QA: `com.korexlabs.dhinspeccion.debug`.
|
- Application ID debug/QA: `com.korexlabs.dhinspeccion.debug`.
|
||||||
- API: `https://dhv2.korexlabs.com/api/v3/`.
|
- API: `https://dhv2.korexlabs.com/api/v3/`.
|
||||||
|
- Servidor compatible de esta candidata: **API 0.29.0-2 / WEB 0.23.0-2**.
|
||||||
|
|
||||||
La variante debug es independiente de la app productiva y puede instalarse para QA/presentación sin sobrescribir una instalación release histórica.
|
La variante debug es independiente de la app productiva y puede instalarse para QA/presentación sin sobrescribir una instalación release histórica.
|
||||||
|
|
||||||
## Procedimiento operativo validado
|
## Procedimiento operativo validado
|
||||||
|
|
||||||
La APK 0.19.1 fija como recorrido principal de campo:
|
La APK 0.19.2 fija como recorrido principal de campo:
|
||||||
|
|
||||||
1. **Iniciar Inspección**. Al iniciarla se habilitan Actas, Hallazgos e Inventario de campo.
|
1. **Iniciar Inspección**. Al iniciarla se habilita el circuito de **Actas y Hallazgos**; Inventario no es una acción independiente de la Inspección.
|
||||||
2. **Crear o abrir un Acta**. Puede haber varias Actas dentro de una misma Inspección, pero sólo una puede permanecer en elaboración al mismo tiempo.
|
2. **Crear o abrir un Acta**. Puede haber varias Actas dentro de una misma Inspección, pero sólo una puede permanecer en elaboración al mismo tiempo. La urgencia todavía no se define.
|
||||||
3. **Agregar Hallazgos** sobre una Instalación o Subinstalación seleccionada.
|
3. **Agregar Hallazgos**. Recién desde esta acción se selecciona la Instalación/Subinstalación afectada.
|
||||||
4. Si el elemento ya existe, se lo selecciona desde el Inventario del Área/Yacimiento de la Inspección.
|
4. Si el elemento ya existe, se lo selecciona desde el Inventario del Área/Yacimiento de la Inspección.
|
||||||
5. Si no existe, se da de alta desde campo sin abandonar el Acta.
|
5. Si no existe, se da de alta desde campo sin abandonar el Acta.
|
||||||
6. Un elemento nuevo debe completar **GPS + fotografía** antes de poder recibir Hallazgos.
|
6. Un elemento nuevo debe completar **GPS + fotografía** antes de poder recibir Hallazgos.
|
||||||
7. Al terminar el contenido del Acta se usa **Cerrar Acta y dejar pendiente de firma**. Desde ese momento el contenido queda inmutable y el estado visible es **Pendiente de firma**.
|
7. Al terminar el contenido del Acta se elige **Urgente / No urgente** y luego se usa **Cerrar Acta y dejar pendiente de firma**. La urgencia queda fijada con el cierre; desde ese momento el contenido queda inmutable y el estado visible es **Pendiente de firma**.
|
||||||
8. La firma del Inspector y la manifestación/firma o negativa de la empresa completan el Acta, que pasa a **Firmada y cerrada**.
|
8. La firma del Inspector y la manifestación/firma o negativa de la empresa completan el Acta, que pasa a **Firmada y cerrada**.
|
||||||
9. La Inspección sólo puede cerrarse cuando todas sus Actas no canceladas están firmadas y cerradas.
|
9. La Inspección sólo puede cerrarse cuando todas sus Actas no canceladas están firmadas y cerradas.
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ La terminología visible se simplifica:
|
|||||||
- `LOCKED` → **Pendiente de firma**;
|
- `LOCKED` → **Pendiente de firma**;
|
||||||
- `SEALED` → **Firmada y cerrada**.
|
- `SEALED` → **Firmada y cerrada**.
|
||||||
|
|
||||||
Cerrar el contenido no cierra automáticamente la Inspección y tampoco obliga a terminar la firma en ese instante: puede continuarse con otra Acta. Una vez cerrado el contenido, el Acta es inmutable.
|
Cerrar el contenido no cierra automáticamente la Inspección y tampoco obliga a terminar la firma en ese instante: puede continuarse con otra Acta. La urgencia se decide en ese cierre, nunca al crear el borrador. Una vez cerrado el contenido, el Acta es inmutable.
|
||||||
|
|
||||||
Después de la firma/cierre definitivo se mantiene el circuito documental existente: PDF del Acta e informe INF editable (DOCX) para oficina.
|
Después de la firma/cierre definitivo se mantiene el circuito documental existente: PDF del Acta e informe INF editable (DOCX) para oficina.
|
||||||
|
|
||||||
@@ -115,3 +116,12 @@ Esta candidata requiere conexión. No implementa trabajo offline ni cola persist
|
|||||||
- Yacimiento seleccionable para Hallazgos y como padre explícito de nuevas Instalaciones. Se elimina el fallback que podía presentar un tipo Yacimiento como alta de Instalación.
|
- Yacimiento seleccionable para Hallazgos y como padre explícito de nuevas Instalaciones. Se elimina el fallback que podía presentar un tipo Yacimiento como alta de Instalación.
|
||||||
- Formulario Datos técnicos sobre el elemento seleccionado: carga y guarda las definiciones/valores por familia mediante los endpoints existentes del Dashboard; valida obligatorios, números, Sí/No, fechas y opciones. Es un paso separado del alta estructural y GPS/foto.
|
- Formulario Datos técnicos sobre el elemento seleccionado: carga y guarda las definiciones/valores por familia mediante los endpoints existentes del Dashboard; valida obligatorios, números, Sí/No, fechas y opciones. Es un paso separado del alta estructural y GPS/foto.
|
||||||
- Se agregan siete pruebas para coordenadas y valores técnicos.
|
- Se agregan siete pruebas para coordenadas y valores técnicos.
|
||||||
|
|
||||||
|
|
||||||
|
## Revisión 0.19.2 · flujo conceptual corregido
|
||||||
|
|
||||||
|
- Se elimina **Inventario de campo** como acción independiente de la pantalla de Inspección.
|
||||||
|
- El alta o selección de Inventario existe únicamente dentro de **Agregar Hallazgo**.
|
||||||
|
- El borrador de Acta nace vacío, sin Inventario y sin urgencia predeterminada.
|
||||||
|
- La urgencia se exige al cerrar el Acta y se persiste en la misma operación que la vuelve inmutable.
|
||||||
|
- `inspection_acts.urgency` puede quedar pendiente durante el borrador; el bloqueo exige la decisión y calcula el vencimiento desde allí.
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId = "com.korexlabs.dhinspeccion"
|
applicationId = "com.korexlabs.dhinspeccion"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 29
|
versionCode = 30
|
||||||
versionName = "0.19.1"
|
versionName = "0.19.2"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -165,40 +165,24 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createActForSelectedInventory(urgency: String = "NON_URGENT") {
|
fun createAct() {
|
||||||
val currentVisit = visit ?: return
|
val currentVisit = visit ?: return
|
||||||
val asset = selectedFieldAsset?.asset
|
|
||||||
if (currentVisit.status != "IN_PROGRESS") {
|
if (currentVisit.status != "IN_PROGRESS") {
|
||||||
error = "La Inspección debe estar en curso para crear un Acta."
|
error = "La Inspección debe estar en curso para crear un Acta."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (urgency !in setOf("URGENT", "NON_URGENT")) {
|
|
||||||
error = "Elegí si el Acta es urgente o no urgente."
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (acts.any { it.status == "DRAFT" }) {
|
if (acts.any { it.status == "DRAFT" }) {
|
||||||
error = "Ya existe un Acta en elaboración. Cerrala o cancelala antes de crear la siguiente."
|
error = "Ya existe un Acta en elaboración. Cerrala o cancelala antes de crear la siguiente."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
launchBusy(mutation = true) {
|
launchBusy(mutation = true) {
|
||||||
val created = actsRepository.create(
|
val created = actsRepository.create(currentVisit.id, currentVisit.code)
|
||||||
currentVisit.id,
|
|
||||||
asset?.id,
|
|
||||||
currentVisit.code,
|
|
||||||
urgency,
|
|
||||||
)
|
|
||||||
selectedAct = created
|
selectedAct = created
|
||||||
actClosure = actsRepository.closure(created.id)
|
actClosure = actsRepository.closure(created.id)
|
||||||
loadActsInternal(currentVisit.id, selectDraft = false)
|
loadActsInternal(currentVisit.id, selectDraft = false)
|
||||||
val urgencyLabel = if (urgency == "URGENT") "urgente" else "no urgente"
|
notice = "${created.code} creada. La urgencia se define recién al cerrar el Acta; los Hallazgos se agregan desde su propio flujo."
|
||||||
notice = "${created.code} creada como $urgencyLabel. Los Hallazgos nuevos quedarán vinculados explícitamente a esta Acta."
|
|
||||||
if (asset != null && selectedFieldAsset?.capture?.readyForFinding == true) {
|
|
||||||
loadFindingOptionsInternal(currentVisit.id, asset.id, created.id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun createAct(urgency: String = "NON_URGENT") = createActForSelectedInventory(urgency)
|
|
||||||
|
|
||||||
fun searchInventory(search: String, parentId: String? = null) {
|
fun searchInventory(search: String, parentId: String? = null) {
|
||||||
val currentVisit = visit ?: return
|
val currentVisit = visit ?: return
|
||||||
@@ -488,12 +472,17 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun prepareSelectedAct() {
|
fun prepareSelectedAct(urgency: String) {
|
||||||
val actId = selectedAct?.id ?: return
|
val actId = selectedAct?.id ?: return
|
||||||
|
if (urgency !in setOf("URGENT", "NON_URGENT")) {
|
||||||
|
error = "Definí la urgencia antes de cerrar el Acta."
|
||||||
|
return
|
||||||
|
}
|
||||||
launchBusy(mutation = true) {
|
launchBusy(mutation = true) {
|
||||||
actClosure = actsRepository.lock(actId)
|
actClosure = actsRepository.lock(actId, urgency)
|
||||||
refreshSelectedActInternal(actId)
|
refreshSelectedActInternal(actId)
|
||||||
notice = "Acta cerrada y pendiente de firma. Su contenido quedó inmutable; las firmas y manifestaciones pueden completarse a continuación."
|
val urgencyLabel = if (urgency == "URGENT") "urgente" else "no urgente"
|
||||||
|
notice = "Acta cerrada como $urgencyLabel y pendiente de firma. Su contenido quedó inmutable."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ data class MobileActSummary(
|
|||||||
val title: String,
|
val title: String,
|
||||||
val summary: String,
|
val summary: String,
|
||||||
val observations: String? = null,
|
val observations: String? = null,
|
||||||
val urgency: String = "NON_URGENT",
|
val urgency: String? = null,
|
||||||
val deadlineDays: Int? = null,
|
val deadlineDays: Int? = null,
|
||||||
val deadlineDayType: String? = null,
|
val deadlineDayType: String? = null,
|
||||||
val deadlineBasis: String? = null,
|
val deadlineBasis: String? = null,
|
||||||
@@ -60,7 +60,7 @@ data class MobileActDetail(
|
|||||||
val title: String,
|
val title: String,
|
||||||
val summary: String,
|
val summary: String,
|
||||||
val observations: String? = null,
|
val observations: String? = null,
|
||||||
val urgency: String = "NON_URGENT",
|
val urgency: String? = null,
|
||||||
val deadlineDays: Int? = null,
|
val deadlineDays: Int? = null,
|
||||||
val deadlineDayType: String? = null,
|
val deadlineDayType: String? = null,
|
||||||
val deadlineBasis: String? = null,
|
val deadlineBasis: String? = null,
|
||||||
@@ -91,13 +91,16 @@ data class MobileActListResponse(
|
|||||||
|
|
||||||
data class CreateMobileActRequest(
|
data class CreateMobileActRequest(
|
||||||
val occurredAt: String,
|
val occurredAt: String,
|
||||||
val urgency: String,
|
|
||||||
val title: String,
|
val title: String,
|
||||||
val summary: String,
|
val summary: String,
|
||||||
val observations: String? = null,
|
val observations: String? = null,
|
||||||
val assetIds: List<String>,
|
val assetIds: List<String>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class PrepareMobileActRequest(
|
||||||
|
val urgency: String,
|
||||||
|
)
|
||||||
|
|
||||||
data class UpdateMobileActRequest(
|
data class UpdateMobileActRequest(
|
||||||
val assetIds: List<String>,
|
val assetIds: List<String>,
|
||||||
)
|
)
|
||||||
@@ -130,7 +133,7 @@ data class MobileActClosureHeader(
|
|||||||
val code: String,
|
val code: String,
|
||||||
val status: String,
|
val status: String,
|
||||||
val visitId: String,
|
val visitId: String,
|
||||||
val urgency: String = "NON_URGENT",
|
val urgency: String? = null,
|
||||||
val deadlineDays: Int? = null,
|
val deadlineDays: Int? = null,
|
||||||
val deadlineDayType: String? = null,
|
val deadlineDayType: String? = null,
|
||||||
val deadlineBasis: String? = null,
|
val deadlineBasis: String? = null,
|
||||||
@@ -249,6 +252,7 @@ private interface MobileActsApi {
|
|||||||
suspend fun lock(
|
suspend fun lock(
|
||||||
@Header("Authorization") authorization: String,
|
@Header("Authorization") authorization: String,
|
||||||
@Path("actId") actId: String,
|
@Path("actId") actId: String,
|
||||||
|
@Body request: PrepareMobileActRequest,
|
||||||
): MobileActClosure
|
): MobileActClosure
|
||||||
|
|
||||||
@Multipart
|
@Multipart
|
||||||
@@ -326,19 +330,16 @@ class MobileActsRepository(context: Context) {
|
|||||||
|
|
||||||
suspend fun create(
|
suspend fun create(
|
||||||
visitId: String,
|
visitId: String,
|
||||||
assetId: String? = null,
|
|
||||||
visitCode: String,
|
visitCode: String,
|
||||||
urgency: String = "NON_URGENT",
|
|
||||||
): MobileActDetail = authorized { session ->
|
): MobileActDetail = authorized { session ->
|
||||||
api.createAct(
|
api.createAct(
|
||||||
"Bearer ${session.accessToken}",
|
"Bearer ${session.accessToken}",
|
||||||
visitId,
|
visitId,
|
||||||
CreateMobileActRequest(
|
CreateMobileActRequest(
|
||||||
occurredAt = Instant.now().toString(),
|
occurredAt = Instant.now().toString(),
|
||||||
urgency = urgency,
|
|
||||||
title = "Acta de inspección $visitCode",
|
title = "Acta de inspección $visitCode",
|
||||||
summary = "Acta de inspección en curso. Los Hallazgos y observaciones se incorporan de forma trazable durante la inspección.",
|
summary = "Acta de inspección en curso. Los Hallazgos y observaciones se incorporan de forma trazable durante la inspección.",
|
||||||
assetIds = listOfNotNull(assetId),
|
assetIds = emptyList(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -360,8 +361,8 @@ class MobileActsRepository(context: Context) {
|
|||||||
api.responsible("Bearer ${session.accessToken}", actId, request)
|
api.responsible("Bearer ${session.accessToken}", actId, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun lock(actId: String): MobileActClosure = authorized { session ->
|
suspend fun lock(actId: String, urgency: String): MobileActClosure = authorized { session ->
|
||||||
api.lock("Bearer ${session.accessToken}", actId)
|
api.lock("Bearer ${session.accessToken}", actId, PrepareMobileActRequest(urgency))
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun signInspector(
|
suspend fun signInspector(
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ fun MobileActsScreen(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
var newActUrgency by rememberSaveable(visit.id) { mutableStateOf("NON_URGENT") }
|
var closingUrgency by rememberSaveable(selected?.id) { mutableStateOf("") }
|
||||||
var attendance by rememberSaveable(selected?.id) {
|
var attendance by rememberSaveable(selected?.id) {
|
||||||
mutableStateOf(closure?.responsible?.attendanceStatus ?: "PRESENT")
|
mutableStateOf(closure?.responsible?.attendanceStatus ?: "PRESENT")
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,11 @@ fun MobileActsScreen(
|
|||||||
}
|
}
|
||||||
model.acts.forEach { act ->
|
model.acts.forEach { act ->
|
||||||
val active = selected?.id == act.id
|
val active = selected?.id == act.id
|
||||||
val urgency = if (act.urgency == "URGENT") "URGENTE" else "No urgente"
|
val urgency = when (act.urgency) {
|
||||||
|
"URGENT" -> "URGENTE"
|
||||||
|
"NON_URGENT" -> "No urgente"
|
||||||
|
else -> "Urgencia pendiente"
|
||||||
|
}
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onClick = { model.selectAct(act.id) },
|
onClick = { model.selectAct(act.id) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
@@ -165,23 +169,8 @@ fun MobileActsScreen(
|
|||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text("Urgencia", fontWeight = FontWeight.Bold)
|
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
||||||
AssistChip(
|
|
||||||
onClick = { newActUrgency = "NON_URGENT" },
|
|
||||||
label = { Text(if (newActUrgency == "NON_URGENT") "✓ No urgente" else "No urgente") },
|
|
||||||
)
|
|
||||||
AssistChip(
|
|
||||||
onClick = { newActUrgency = "URGENT" },
|
|
||||||
label = { Text(if (newActUrgency == "URGENT") "✓ Urgente" else "Urgente") },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Text(
|
Text(
|
||||||
if (newActUrgency == "URGENT") {
|
"La urgencia se define al cerrar el Acta, después de completar los Hallazgos.",
|
||||||
"El plazo urgente se computará desde el Acta según la política institucional vigente al bloquearla."
|
|
||||||
} else {
|
|
||||||
"El plazo no urgente se computará desde la oficialización GEDO según la política institucional vigente al bloquearla."
|
|
||||||
},
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
@@ -189,7 +178,7 @@ fun MobileActsScreen(
|
|||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
)
|
)
|
||||||
Button(
|
Button(
|
||||||
onClick = { model.createAct(newActUrgency) },
|
onClick = { model.createAct() },
|
||||||
enabled = !model.busy,
|
enabled = !model.busy,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) { Text("Crear nueva Acta") }
|
) { Text("Crear nueva Acta") }
|
||||||
@@ -203,7 +192,13 @@ fun MobileActsScreen(
|
|||||||
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(5.dp)) {
|
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(5.dp)) {
|
||||||
Text(selected.code, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
Text(selected.code, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
||||||
Text(actStatusLabel(selected.status))
|
Text(actStatusLabel(selected.status))
|
||||||
Text(if (selected.urgency == "URGENT") "Urgente" else "No urgente")
|
Text(
|
||||||
|
when (selected.urgency) {
|
||||||
|
"URGENT" -> "Urgencia: Urgente"
|
||||||
|
"NON_URGENT" -> "Urgencia: No urgente"
|
||||||
|
else -> "Urgencia: se define al cerrar el Acta"
|
||||||
|
},
|
||||||
|
)
|
||||||
Text("${selected.findingCount} Hallazgo${if (selected.findingCount == 1) "" else "s"} · ${selected.assetCount} elemento${if (selected.assetCount == 1) "" else "s"} de Inventario")
|
Text("${selected.findingCount} Hallazgo${if (selected.findingCount == 1) "" else "s"} · ${selected.assetCount} elemento${if (selected.assetCount == 1) "" else "s"} de Inventario")
|
||||||
selected.deadlineAt?.let { Text("Vencimiento calculado: $it", style = MaterialTheme.typography.bodySmall) }
|
selected.deadlineAt?.let { Text("Vencimiento calculado: $it", style = MaterialTheme.typography.bodySmall) }
|
||||||
if (selected.deadlineAt == null && selected.deadlineBasis == "GEDO_DATE") {
|
if (selected.deadlineAt == null && selected.deadlineBasis == "GEDO_DATE") {
|
||||||
@@ -270,10 +265,20 @@ fun MobileActsScreen(
|
|||||||
|
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
Text("Finalizar contenido", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
Text("Finalizar contenido", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
||||||
Text("Al BLOQUEAR el Acta, el contenido y los Hallazgos quedan inmutables. Esta acción no se puede deshacer.")
|
Text("Al cerrar el Acta, el contenido y los Hallazgos quedan inmutables. Definí ahora la urgencia según lo constatado.")
|
||||||
|
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
|
AssistChip(
|
||||||
|
onClick = { closingUrgency = "NON_URGENT" },
|
||||||
|
label = { Text(if (closingUrgency == "NON_URGENT") "✓ No urgente" else "No urgente") },
|
||||||
|
)
|
||||||
|
AssistChip(
|
||||||
|
onClick = { closingUrgency = "URGENT" },
|
||||||
|
label = { Text(if (closingUrgency == "URGENT") "✓ Urgente" else "Urgente") },
|
||||||
|
)
|
||||||
|
}
|
||||||
Button(
|
Button(
|
||||||
onClick = { model.prepareSelectedAct() },
|
onClick = { model.prepareSelectedAct(closingUrgency) },
|
||||||
enabled = !model.busy && closure?.responsible != null,
|
enabled = !model.busy && closure?.responsible != null && closingUrgency.isNotBlank(),
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) { Text("Finalizar y BLOQUEAR Acta") }
|
) { Text("Finalizar y BLOQUEAR Acta") }
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-32
@@ -75,7 +75,7 @@ fun ModernMobileActsScreen(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
var newActUrgency by rememberSaveable(visit.id) { mutableStateOf("NON_URGENT") }
|
var closingUrgency by rememberSaveable(selected?.id) { mutableStateOf("") }
|
||||||
var attendance by rememberSaveable(selected?.id) { mutableStateOf(closure?.responsible?.attendanceStatus ?: "PRESENT") }
|
var attendance by rememberSaveable(selected?.id) { mutableStateOf(closure?.responsible?.attendanceStatus ?: "PRESENT") }
|
||||||
var fullName by rememberSaveable(selected?.id) { mutableStateOf(closure?.responsible?.fullName.orEmpty()) }
|
var fullName by rememberSaveable(selected?.id) { mutableStateOf(closure?.responsible?.fullName.orEmpty()) }
|
||||||
var documentType by rememberSaveable(selected?.id) { mutableStateOf(closure?.responsible?.documentType ?: "DNI") }
|
var documentType by rememberSaveable(selected?.id) { mutableStateOf(closure?.responsible?.documentType ?: "DNI") }
|
||||||
@@ -195,7 +195,7 @@ fun ModernMobileActsScreen(
|
|||||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
||||||
Text(act.code, fontWeight = FontWeight.Bold)
|
Text(act.code, fontWeight = FontWeight.Bold)
|
||||||
Text(
|
Text(
|
||||||
"${modernActStatusLabel(act.status)} · ${if (act.urgency == "URGENT") "Urgente" else "No urgente"}",
|
"${modernActStatusLabel(act.status)} · ${when (act.urgency) { "URGENT" -> "Urgente"; "NON_URGENT" -> "No urgente"; else -> "Urgencia pendiente" }}",
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
@@ -225,36 +225,13 @@ fun ModernMobileActsScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text("Urgencia", fontWeight = FontWeight.SemiBold)
|
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
||||||
FilterChip(
|
|
||||||
selected = newActUrgency == "NON_URGENT",
|
|
||||||
onClick = { newActUrgency = "NON_URGENT" },
|
|
||||||
label = { Text("No urgente") },
|
|
||||||
)
|
|
||||||
FilterChip(
|
|
||||||
selected = newActUrgency == "URGENT",
|
|
||||||
onClick = { newActUrgency = "URGENT" },
|
|
||||||
label = { Text("Urgente") },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Surface(
|
|
||||||
Modifier.fillMaxWidth(),
|
|
||||||
shape = MaterialTheme.shapes.medium,
|
|
||||||
color = MaterialTheme.colorScheme.surfaceVariant,
|
|
||||||
) {
|
|
||||||
Text(
|
Text(
|
||||||
if (newActUrgency == "URGENT") {
|
"La urgencia se define recién al cerrar el Acta, cuando ya se conoce el resultado de la inspección.",
|
||||||
"El plazo urgente se computará desde el Acta conforme a la política institucional vigente al cerrar su contenido."
|
|
||||||
} else {
|
|
||||||
"El plazo no urgente comienza con la oficialización GEDO, no al crear el Acta."
|
|
||||||
},
|
|
||||||
Modifier.padding(12.dp),
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
Button(
|
Button(
|
||||||
onClick = { model.createAct(newActUrgency) },
|
onClick = { model.createAct() },
|
||||||
enabled = !model.busy,
|
enabled = !model.busy,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) {
|
) {
|
||||||
@@ -278,7 +255,14 @@ fun ModernMobileActsScreen(
|
|||||||
Text(selected.code, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
Text(selected.code, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
||||||
StatusPill(modernActStatusLabel(selected.status))
|
StatusPill(modernActStatusLabel(selected.status))
|
||||||
}
|
}
|
||||||
Text(if (selected.urgency == "URGENT") "Urgente" else "No urgente", color = MaterialTheme.colorScheme.onSurfaceVariant)
|
Text(
|
||||||
|
when (selected.urgency) {
|
||||||
|
"URGENT" -> "Urgencia · Urgente"
|
||||||
|
"NON_URGENT" -> "Urgencia · No urgente"
|
||||||
|
else -> "Urgencia · Se define al cerrar el Acta"
|
||||||
|
},
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
Text("${selected.findingCount} Hallazgos · ${selected.assetCount} elementos de Inventario", style = MaterialTheme.typography.bodySmall)
|
Text("${selected.findingCount} Hallazgos · ${selected.assetCount} elementos de Inventario", style = MaterialTheme.typography.bodySmall)
|
||||||
selected.deadlineAt?.let { Text("Vencimiento · $it", style = MaterialTheme.typography.bodySmall) }
|
selected.deadlineAt?.let { Text("Vencimiento · $it", style = MaterialTheme.typography.bodySmall) }
|
||||||
if (selected.deadlineAt == null && selected.deadlineBasis == "GEDO_DATE") {
|
if (selected.deadlineAt == null && selected.deadlineBasis == "GEDO_DATE") {
|
||||||
@@ -356,12 +340,34 @@ fun ModernMobileActsScreen(
|
|||||||
Text("Cerrar Acta", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
Text("Cerrar Acta", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
"Al cerrar el contenido, el Acta queda inmutable y pasa a Pendiente de firma. Podés firmarla ahora o continuar con otra Acta.",
|
"Al cerrar el contenido, el Acta queda inmutable y pasa a Pendiente de firma. En este momento definí la urgencia según lo constatado en campo.",
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
Text("Urgencia del Acta", fontWeight = FontWeight.SemiBold)
|
||||||
|
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
|
FilterChip(
|
||||||
|
selected = closingUrgency == "NON_URGENT",
|
||||||
|
onClick = { closingUrgency = "NON_URGENT" },
|
||||||
|
label = { Text("No urgente") },
|
||||||
|
)
|
||||||
|
FilterChip(
|
||||||
|
selected = closingUrgency == "URGENT",
|
||||||
|
onClick = { closingUrgency = "URGENT" },
|
||||||
|
label = { Text("Urgente") },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
when (closingUrgency) {
|
||||||
|
"URGENT" -> "El plazo urgente se computará desde el Acta según la política vigente."
|
||||||
|
"NON_URGENT" -> "El plazo no urgente comenzará con la oficialización GEDO."
|
||||||
|
else -> "Elegí una opción para habilitar el cierre."
|
||||||
|
},
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
Button(
|
Button(
|
||||||
onClick = { model.prepareSelectedAct() },
|
onClick = { model.prepareSelectedAct(closingUrgency) },
|
||||||
enabled = !model.busy && closure?.responsible != null,
|
enabled = !model.busy && closure?.responsible != null && closingUrgency.isNotBlank(),
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) { Text("Cerrar Acta y dejar pendiente de firma") }
|
) { Text("Cerrar Acta y dejar pendiente de firma") }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ fun ModernVisitRoot(model: MainViewModel) {
|
|||||||
ModernVisitScreen.OVERVIEW -> ModernVisitOverview(
|
ModernVisitScreen.OVERVIEW -> ModernVisitOverview(
|
||||||
model = model,
|
model = model,
|
||||||
onActs = { screenName = ModernVisitScreen.ACTS.name },
|
onActs = { screenName = ModernVisitScreen.ACTS.name },
|
||||||
onInventory = { screenName = ModernVisitScreen.INVENTORY.name },
|
|
||||||
)
|
)
|
||||||
ModernVisitScreen.ACTS -> ModernMobileActsScreen(
|
ModernVisitScreen.ACTS -> ModernMobileActsScreen(
|
||||||
model = model,
|
model = model,
|
||||||
@@ -124,7 +123,6 @@ fun ModernVisitRoot(model: MainViewModel) {
|
|||||||
private fun ModernVisitOverview(
|
private fun ModernVisitOverview(
|
||||||
model: MainViewModel,
|
model: MainViewModel,
|
||||||
onActs: () -> Unit,
|
onActs: () -> Unit,
|
||||||
onInventory: () -> Unit,
|
|
||||||
) {
|
) {
|
||||||
val visit = model.visit ?: return
|
val visit = model.visit ?: return
|
||||||
Column(
|
Column(
|
||||||
@@ -183,7 +181,7 @@ private fun ModernVisitOverview(
|
|||||||
Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
Text("Listo para iniciar", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
Text("Listo para iniciar", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold)
|
||||||
Text(
|
Text(
|
||||||
"Al iniciar se habilitan Actas, Hallazgos y el Inventario de campo.",
|
"Al iniciar se habilitan Actas y Hallazgos.",
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
Button(
|
Button(
|
||||||
@@ -217,25 +215,6 @@ private fun ModernVisitOverview(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ElevatedCard(onClick = onInventory, modifier = Modifier.fillMaxWidth()) {
|
|
||||||
Row(
|
|
||||||
Modifier.padding(16.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
|
||||||
) {
|
|
||||||
Surface(shape = MaterialTheme.shapes.medium, color = MaterialTheme.colorScheme.secondaryContainer) {
|
|
||||||
Icon(Icons.Filled.Factory, null, Modifier.padding(11.dp), tint = MaterialTheme.colorScheme.secondary)
|
|
||||||
}
|
|
||||||
Column(Modifier.weight(1f)) {
|
|
||||||
Text("Inventario de campo", fontWeight = FontWeight.Bold)
|
|
||||||
Text(
|
|
||||||
"Buscar existente o cargar Instalación / Subinstalación",
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (visit.status == "CLOSED") {
|
} else if (visit.status == "CLOSED") {
|
||||||
OutlinedButton(onClick = onActs, modifier = Modifier.fillMaxWidth()) { Text("Ver Actas") }
|
OutlinedButton(onClick = onActs, modifier = Modifier.fillMaxWidth()) { Text("Ver Actas") }
|
||||||
}
|
}
|
||||||
@@ -533,7 +512,7 @@ private fun ModernFieldInventoryScreen(model: MainViewModel, onBack: () -> Unit)
|
|||||||
ModernInventoryMode.PICK_PARENT -> "Elegir Instalación"
|
ModernInventoryMode.PICK_PARENT -> "Elegir Instalación"
|
||||||
ModernInventoryMode.CREATE_INSTALLATION -> "Nueva Instalación"
|
ModernInventoryMode.CREATE_INSTALLATION -> "Nueva Instalación"
|
||||||
ModernInventoryMode.CREATE_SUBINSTALLATION -> "Nueva Subinstalación"
|
ModernInventoryMode.CREATE_SUBINSTALLATION -> "Nueva Subinstalación"
|
||||||
ModernInventoryMode.BROWSE -> "Inventario de campo"
|
ModernInventoryMode.BROWSE -> "Ubicación del Hallazgo"
|
||||||
},
|
},
|
||||||
subtitle = visit.scopeAsset?.name ?: visit.code,
|
subtitle = visit.scopeAsset?.name ?: visit.code,
|
||||||
onBack = { if (mode == ModernInventoryMode.BROWSE) onBack() else backToBrowse() },
|
onBack = { if (mode == ModernInventoryMode.BROWSE) onBack() else backToBrowse() },
|
||||||
@@ -912,7 +891,7 @@ private fun ModernInventoryBrowse(
|
|||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = search,
|
value = search,
|
||||||
onValueChange = onSearchChange,
|
onValueChange = onSearchChange,
|
||||||
label = { Text("Buscar Inventario") },
|
label = { Text("Buscar Instalación o Subinstalación") },
|
||||||
placeholder = { Text("Nombre, código o dato técnico") },
|
placeholder = { Text("Nombre, código o dato técnico") },
|
||||||
leadingIcon = { Icon(Icons.Filled.Search, null) },
|
leadingIcon = { Icon(Icons.Filled.Search, null) },
|
||||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ class ReleaseMetadataTest {
|
|||||||
@Test
|
@Test
|
||||||
fun debugBuildKeepsSeparateApplicationIdentity() {
|
fun debugBuildKeepsSeparateApplicationIdentity() {
|
||||||
assertEquals("com.korexlabs.dhinspeccion.debug", BuildConfig.APPLICATION_ID)
|
assertEquals("com.korexlabs.dhinspeccion.debug", BuildConfig.APPLICATION_ID)
|
||||||
assertEquals(29, BuildConfig.VERSION_CODE)
|
assertEquals(30, BuildConfig.VERSION_CODE)
|
||||||
assertEquals("0.19.1-debug", BuildConfig.VERSION_NAME)
|
assertEquals("0.19.2-debug", BuildConfig.VERSION_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dhv2-api",
|
"name": "dhv2-api",
|
||||||
"version": "0.29.0-1",
|
"version": "0.29.0-3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dhv2-api",
|
"name": "dhv2-api",
|
||||||
"version": "0.29.0-1",
|
"version": "0.29.0-3",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/common": "^11.0.0",
|
"@nestjs/common": "^11.0.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dhv2-api",
|
"name": "dhv2-api",
|
||||||
"version": "0.29.0-1",
|
"version": "0.29.0-3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ export class InspectionAct extends TimestampedEntity {
|
|||||||
@Column({ type: 'text', nullable: true })
|
@Column({ type: 'text', nullable: true })
|
||||||
observations!: string | null;
|
observations!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'urgency', type: 'varchar', length: 24, default: InspectionActUrgency.NON_URGENT })
|
@Column({ name: 'urgency', type: 'varchar', length: 24, nullable: true })
|
||||||
urgency!: InspectionActUrgency;
|
urgency!: InspectionActUrgency | null;
|
||||||
|
|
||||||
@Column({ name: 'deadline_days', type: 'integer', nullable: true })
|
@Column({ name: 'deadline_days', type: 'integer', nullable: true })
|
||||||
deadlineDays!: number | null;
|
deadlineDays!: number | null;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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`);
|
||||||
|
await q.query(`UPDATE inspection_acts SET urgency=NULL WHERE status='DRAFT'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
ArrayMaxSize,
|
||||||
ArrayUnique,
|
ArrayUnique,
|
||||||
IsArray,
|
IsArray,
|
||||||
IsEnum,
|
|
||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
@@ -11,15 +10,11 @@ import {
|
|||||||
MaxLength,
|
MaxLength,
|
||||||
MinLength,
|
MinLength,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { InspectionActUrgency } from '../../database/entities';
|
|
||||||
|
|
||||||
export class CreateInspectionActDto {
|
export class CreateInspectionActDto {
|
||||||
@IsISO8601({ strict: true })
|
@IsISO8601({ strict: true })
|
||||||
occurredAt!: string;
|
occurredAt!: string;
|
||||||
|
|
||||||
@IsEnum(InspectionActUrgency)
|
|
||||||
urgency!: InspectionActUrgency;
|
|
||||||
|
|
||||||
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
||||||
@IsString()
|
@IsString()
|
||||||
@MinLength(1)
|
@MinLength(1)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
ArrayMinSize,
|
ArrayMinSize,
|
||||||
ArrayUnique,
|
ArrayUnique,
|
||||||
IsArray,
|
IsArray,
|
||||||
IsEnum,
|
|
||||||
IsISO8601,
|
IsISO8601,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
@@ -12,17 +11,12 @@ import {
|
|||||||
MaxLength,
|
MaxLength,
|
||||||
MinLength,
|
MinLength,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { InspectionActUrgency } from '../../database/entities';
|
|
||||||
|
|
||||||
export class UpdateInspectionActDto {
|
export class UpdateInspectionActDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsISO8601({ strict: true })
|
@IsISO8601({ strict: true })
|
||||||
occurredAt?: string;
|
occurredAt?: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsEnum(InspectionActUrgency)
|
|
||||||
urgency?: InspectionActUrgency;
|
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export interface InspectionActListItem {
|
|||||||
title: string;
|
title: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
observations: string | null;
|
observations: string | null;
|
||||||
urgency: InspectionActUrgency;
|
urgency: InspectionActUrgency | null;
|
||||||
deadlineDays: number | null;
|
deadlineDays: number | null;
|
||||||
deadlineDayType: InspectionDeadlineDayType | null;
|
deadlineDayType: InspectionDeadlineDayType | null;
|
||||||
deadlineBasis: InspectionDeadlineBasis | null;
|
deadlineBasis: InspectionDeadlineBasis | null;
|
||||||
@@ -314,7 +314,7 @@ 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,
|
urgency: null,
|
||||||
deadlineDays: null,
|
deadlineDays: null,
|
||||||
deadlineDayType: null,
|
deadlineDayType: null,
|
||||||
deadlineBasis: null,
|
deadlineBasis: null,
|
||||||
@@ -379,7 +379,6 @@ 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;
|
||||||
@@ -729,10 +728,13 @@ export class InspectionActsService {
|
|||||||
principal: AuthPrincipal,
|
principal: AuthPrincipal,
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const [row] = (await manager.query(`
|
const [row] = (await manager.query(`
|
||||||
|
WITH updated AS (
|
||||||
UPDATE inspection_acts
|
UPDATE inspection_acts
|
||||||
SET current_version = current_version + 1
|
SET current_version = current_version + 1
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
RETURNING current_version AS "versionNumber"
|
RETURNING current_version
|
||||||
|
)
|
||||||
|
SELECT current_version AS "versionNumber" FROM updated
|
||||||
`, [act.id])) as Array<{ versionNumber: number }>;
|
`, [act.id])) as Array<{ versionNumber: number }>;
|
||||||
const versionNumber = Number(row.versionNumber);
|
const versionNumber = Number(row.versionNumber);
|
||||||
act.currentVersion = versionNumber;
|
act.currentVersion = versionNumber;
|
||||||
|
|||||||
@@ -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 { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
||||||
import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context';
|
import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context';
|
||||||
import { CloseInspectionActDto } from './dto/close-inspection-act.dto';
|
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 { CreateCompanyOutcomeDto } from './dto/create-company-outcome.dto';
|
||||||
import { CreateInspectionSignatureDto } from './dto/create-inspection-signature.dto';
|
import { CreateInspectionSignatureDto } from './dto/create-inspection-signature.dto';
|
||||||
import { CreateCompanySignatureDto } from './dto/create-company-signature.dto';
|
import { CreateCompanySignatureDto } from './dto/create-company-signature.dto';
|
||||||
@@ -52,10 +53,11 @@ export class InspectionClosingController {
|
|||||||
@RequirePermissions('inspection_closure.prepare')
|
@RequirePermissions('inspection_closure.prepare')
|
||||||
lock(
|
lock(
|
||||||
@Param('actId', new ParseUUIDPipe({ version: '4' })) actId: string,
|
@Param('actId', new ParseUUIDPipe({ version: '4' })) actId: string,
|
||||||
|
@Body() dto: PrepareInspectionActDto,
|
||||||
@CurrentAuth() principal: AuthPrincipal,
|
@CurrentAuth() principal: AuthPrincipal,
|
||||||
@Req() request: RequestWithContext,
|
@Req() request: RequestWithContext,
|
||||||
) {
|
) {
|
||||||
return this.closing.prepare(actId, principal, request);
|
return this.closing.prepare(actId, dto, principal, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('signatures/inspector')
|
@Post('signatures/inspector')
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { assertMobileInspector } from '../inspection-operations/mobile-inspector
|
|||||||
import { InspectionReportsService } from '../inspection-reports/inspection-reports.service';
|
import { InspectionReportsService } from '../inspection-reports/inspection-reports.service';
|
||||||
import { sha256CanonicalJson } from './canonical-json';
|
import { sha256CanonicalJson } from './canonical-json';
|
||||||
import type { CloseInspectionActDto } from './dto/close-inspection-act.dto';
|
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 { CreateCompanyOutcomeDto } from './dto/create-company-outcome.dto';
|
||||||
import type { CreateCompanySignatureDto } from './dto/create-company-signature.dto';
|
import type { CreateCompanySignatureDto } from './dto/create-company-signature.dto';
|
||||||
import type { CreateInspectionSignatureDto } from './dto/create-inspection-signature.dto';
|
import type { CreateInspectionSignatureDto } from './dto/create-inspection-signature.dto';
|
||||||
@@ -130,7 +131,7 @@ export interface InspectionClosureView {
|
|||||||
code: string;
|
code: string;
|
||||||
status: InspectionActStatus;
|
status: InspectionActStatus;
|
||||||
visitId: string;
|
visitId: string;
|
||||||
urgency: InspectionActUrgency;
|
urgency: InspectionActUrgency | null;
|
||||||
deadlineDays: number | null;
|
deadlineDays: number | null;
|
||||||
deadlineDayType: InspectionDeadlineDayType | null;
|
deadlineDayType: InspectionDeadlineDayType | null;
|
||||||
deadlineBasis: InspectionDeadlineBasis | null;
|
deadlineBasis: InspectionDeadlineBasis | null;
|
||||||
@@ -268,6 +269,7 @@ export class InspectionClosingService {
|
|||||||
/** Finaliza el contenido: desde este punto el Acta queda inmutable. */
|
/** Finaliza el contenido: desde este punto el Acta queda inmutable. */
|
||||||
async prepare(
|
async prepare(
|
||||||
actId: string,
|
actId: string,
|
||||||
|
dto: PrepareInspectionActDto,
|
||||||
principal: AuthPrincipal,
|
principal: AuthPrincipal,
|
||||||
request: RequestWithContext,
|
request: RequestWithContext,
|
||||||
): Promise<InspectionClosureView> {
|
): Promise<InspectionClosureView> {
|
||||||
@@ -285,16 +287,16 @@ export class InspectionClosingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const policy = await this.deadlinePolicy(manager);
|
const policy = await this.deadlinePolicy(manager);
|
||||||
const deadlineDays = act.urgency === InspectionActUrgency.URGENT
|
const deadlineDays = dto.urgency === InspectionActUrgency.URGENT
|
||||||
? policy.urgentDays
|
? policy.urgentDays
|
||||||
: policy.nonUrgentDays;
|
: policy.nonUrgentDays;
|
||||||
const deadlineDayType = act.urgency === InspectionActUrgency.URGENT
|
const deadlineDayType = dto.urgency === InspectionActUrgency.URGENT
|
||||||
? policy.urgentDayType
|
? policy.urgentDayType
|
||||||
: policy.nonUrgentDayType;
|
: policy.nonUrgentDayType;
|
||||||
const deadlineBasis = act.urgency === InspectionActUrgency.URGENT
|
const deadlineBasis = dto.urgency === InspectionActUrgency.URGENT
|
||||||
? InspectionDeadlineBasis.ACT_DATE
|
? InspectionDeadlineBasis.ACT_DATE
|
||||||
: InspectionDeadlineBasis.GEDO_DATE;
|
: InspectionDeadlineBasis.GEDO_DATE;
|
||||||
const deadlineBaseAt = act.urgency === InspectionActUrgency.URGENT
|
const deadlineBaseAt = dto.urgency === InspectionActUrgency.URGENT
|
||||||
? act.occurredAt
|
? act.occurredAt
|
||||||
: null;
|
: null;
|
||||||
const deadlineAt = deadlineBaseAt
|
const deadlineAt = deadlineBaseAt
|
||||||
@@ -305,20 +307,22 @@ export class InspectionClosingService {
|
|||||||
const [updated] = (await manager.query(`
|
const [updated] = (await manager.query(`
|
||||||
UPDATE inspection_acts
|
UPDATE inspection_acts
|
||||||
SET status='LOCKED',
|
SET status='LOCKED',
|
||||||
deadline_days=$2,
|
urgency=$2,
|
||||||
deadline_day_type=$3,
|
deadline_days=$3,
|
||||||
deadline_basis=$4,
|
deadline_day_type=$4,
|
||||||
deadline_base_at=$5,
|
deadline_basis=$5,
|
||||||
deadline_at=$6,
|
deadline_base_at=$6,
|
||||||
locked_at=$7,
|
deadline_at=$7,
|
||||||
locked_by=$8,
|
locked_at=$8,
|
||||||
|
locked_by=$9,
|
||||||
current_version=current_version+1,
|
current_version=current_version+1,
|
||||||
updated_by=$8,
|
updated_by=$9,
|
||||||
updated_at=$7
|
updated_at=$8
|
||||||
WHERE id=$1
|
WHERE id=$1
|
||||||
RETURNING current_version AS "versionNumber"
|
RETURNING current_version AS "versionNumber"
|
||||||
`, [
|
`, [
|
||||||
actId,
|
actId,
|
||||||
|
dto.urgency,
|
||||||
deadlineDays,
|
deadlineDays,
|
||||||
deadlineDayType,
|
deadlineDayType,
|
||||||
deadlineBasis,
|
deadlineBasis,
|
||||||
@@ -1009,7 +1013,7 @@ export class InspectionClosingService {
|
|||||||
WHERE act.id=$1
|
WHERE act.id=$1
|
||||||
`, [actId]) as Array<{
|
`, [actId]) as Array<{
|
||||||
id: string; code: string; status: InspectionActStatus; visitId: string;
|
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;
|
deadlineDayType: InspectionDeadlineDayType | null; deadlineBasis: InspectionDeadlineBasis | null;
|
||||||
deadlineBaseAt: Date | null; deadlineAt: Date | null; lockedAt: Date | null;
|
deadlineBaseAt: Date | null; deadlineAt: Date | null; lockedAt: Date | null;
|
||||||
lockedSha256: string | null; sealedAt: Date | null; currentVersion: number;
|
lockedSha256: string | null; sealedAt: Date | null; currentVersion: number;
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export const API_VERSION = '0.29.0-1';
|
export const API_VERSION = '0.29.0-3';
|
||||||
export const API_PHASE = 'F6.1';
|
export const API_PHASE = 'F6.1';
|
||||||
@@ -20,7 +20,7 @@ test('F4 WEB has an explicit LOCKED and SEALED act contract', () => {
|
|||||||
assert.match(f4Api, /lockedAt: string \| null/);
|
assert.match(f4Api, /lockedAt: string \| null/);
|
||||||
assert.match(f4Api, /lockedSha256: string \| null/);
|
assert.match(f4Api, /lockedSha256: string \| null/);
|
||||||
assert.match(f4Api, /sealedAt: 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/);
|
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', () => {
|
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.match(viewModel, /actsRepository\.seal\(actId\)/);
|
||||||
assert.doesNotMatch(viewModel, /actsRepository\.prepare\(/);
|
assert.doesNotMatch(viewModel, /actsRepository\.prepare\(/);
|
||||||
assert.doesNotMatch(viewModel, /actsRepository\.reopen\(/);
|
assert.doesNotMatch(viewModel, /actsRepository\.reopen\(/);
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { resolve } from 'node:path';
|
||||||
import { API_PHASE, API_VERSION } from '../../src/version';
|
import { API_PHASE, API_VERSION } from '../../src/version';
|
||||||
|
|
||||||
test('health metadata reports the current F6.1 release', () => {
|
test('health metadata reports the current F6.1 release', () => {
|
||||||
assert.equal(API_PHASE, 'F6.1');
|
assert.equal(API_PHASE, 'F6.1');
|
||||||
assert.equal(API_VERSION, '0.29.0-1');
|
const pkg = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8')) as { version: string };
|
||||||
|
assert.equal(API_VERSION, pkg.version);
|
||||||
|
assert.equal(API_VERSION, '0.29.0-3');
|
||||||
});
|
});
|
||||||
@@ -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', () => {
|
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');
|
const gradle = mountedRepoFile('android-app/app/build.gradle.kts');
|
||||||
|
|
||||||
assert.match(gradle, /versionCode = 29/);
|
assert.match(gradle, /versionCode = 30/);
|
||||||
assert.match(gradle, /versionName = "0\.19\.1"/);
|
assert.match(gradle, /versionName = "0\.19\.2"/);
|
||||||
assert.match(gradle, /https:\/\/dhv2\.korexlabs\.com\/api\/v3\//);
|
assert.match(gradle, /https:\/\/dhv2\.korexlabs\.com\/api\/v3\//);
|
||||||
assert.match(gradle, /applicationIdSuffix = "\.debug"/);
|
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.doesNotMatch(dto, /ArrayMinSize\(1\)/);
|
||||||
assert.match(service, /if \(assetIds\.length === 0\) return/);
|
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', () => {
|
test('F6.3 every Installation and Subinstallation receives the common field card', () => {
|
||||||
@@ -35,15 +35,40 @@ test('F6.3 every Installation and Subinstallation receives the common field card
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('F6.3 Android follows Inspección → Acta → Hallazgo → Inventario', () => {
|
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 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/MobileActsScreen.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');
|
const vm = source('../android-app/app/src/main/java/com/korexlabs/dhinspeccion/MainViewModel.kt');
|
||||||
|
|
||||||
assert.match(root, /model\.startVisit\(\); onActs\(\)/);
|
assert.match(root, /model\.startVisit\(\); onActs\(\)/);
|
||||||
assert.match(root, /Text\("Nuevo Hallazgo"/);
|
assert.doesNotMatch(root, /Text\("Inventario de campo"/);
|
||||||
assert.match(root, /Buscar instalación o subinstalación/);
|
assert.match(acts, /Text\("Agregar Hallazgo"\)/);
|
||||||
assert.match(acts, /Text\("\+ Agregar Hallazgo"\)/);
|
assert.match(acts, /model\.createAct\(\)/);
|
||||||
assert.match(acts, /model\.createAct\(newActUrgency\)/);
|
assert.match(acts, /model\.prepareSelectedAct\(closingUrgency\)/);
|
||||||
assert.match(vm, /fun createAct\(urgency: String = "NON_URGENT"\)/);
|
assert.match(vm, /fun createAct\(\)/);
|
||||||
|
assert.match(vm, /fun prepareSelectedAct\(urgency: String\)/);
|
||||||
assert.match(vm, /repository\.fieldInventory\(currentVisit\.id, search, parentId\)/);
|
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/);
|
||||||
|
assert.match(migration, /SET urgency=NULL WHERE status='DRAFT'/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('F6.3 Acta version capture uses a SELECT-shaped CTE so TypeORM never turns the version into NaN', () => {
|
||||||
|
const service = source('src/inspection-acts/inspection-acts.service.ts');
|
||||||
|
|
||||||
|
assert.match(service, /WITH updated AS \(/);
|
||||||
|
assert.match(service, /RETURNING current_version/);
|
||||||
|
assert.match(service, /SELECT current_version AS "versionNumber" FROM updated/);
|
||||||
|
assert.match(service, /const versionNumber = Number\(row\.versionNumber\)/);
|
||||||
|
});
|
||||||
|
|||||||
@@ -5,21 +5,18 @@ import { plainToInstance } from 'class-transformer';
|
|||||||
import { validate } from 'class-validator';
|
import { validate } from 'class-validator';
|
||||||
import { CancelInspectionActDto } from '../../src/inspection-acts/dto/cancel-inspection-act.dto';
|
import { CancelInspectionActDto } from '../../src/inspection-acts/dto/cancel-inspection-act.dto';
|
||||||
import { CreateInspectionActDto } from '../../src/inspection-acts/dto/create-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';
|
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, {
|
const dto = plainToInstance(CreateInspectionActDto, {
|
||||||
occurredAt: '2026-08-14T15:30:00.000Z',
|
occurredAt: '2026-08-14T15:30:00.000Z',
|
||||||
urgency: InspectionActUrgency.NON_URGENT,
|
|
||||||
title: ' Verificación de instalación ',
|
title: ' Verificación de instalación ',
|
||||||
summary: ' Se inspeccionó el activo seleccionado. ',
|
summary: ' Se inspeccionó el activo seleccionado. ',
|
||||||
observations: ' Sin novedades. ',
|
observations: ' Sin novedades. ',
|
||||||
assetIds: [ASSET_ID],
|
assetIds: [ASSET_ID],
|
||||||
});
|
});
|
||||||
assert.deepEqual(await validate(dto), []);
|
assert.deepEqual(await validate(dto), []);
|
||||||
assert.equal(dto.urgency, InspectionActUrgency.NON_URGENT);
|
|
||||||
assert.equal(dto.title, 'Verificación de instalación');
|
assert.equal(dto.title, 'Verificación de instalación');
|
||||||
assert.equal(dto.summary, 'Se inspeccionó el activo seleccionado.');
|
assert.equal(dto.summary, 'Se inspeccionó el activo seleccionado.');
|
||||||
assert.equal(dto.observations, 'Sin novedades.');
|
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 () => {
|
test('inspection act DTO rejects duplicate assets', async () => {
|
||||||
const dto = plainToInstance(CreateInspectionActDto, {
|
const dto = plainToInstance(CreateInspectionActDto, {
|
||||||
occurredAt: '2026-08-14T15:30:00.000Z',
|
occurredAt: '2026-08-14T15:30:00.000Z',
|
||||||
urgency: InspectionActUrgency.NON_URGENT,
|
|
||||||
title: 'Acta',
|
title: 'Acta',
|
||||||
summary: 'Contenido',
|
summary: 'Contenido',
|
||||||
assetIds: [ASSET_ID, ASSET_ID],
|
assetIds: [ASSET_ID, ASSET_ID],
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { plainToInstance } from 'class-transformer';
|
|||||||
import { validate } from 'class-validator';
|
import { validate } from 'class-validator';
|
||||||
import { CreateCompanyOutcomeDto } from '../../src/inspection-closing/dto/create-company-outcome.dto';
|
import { CreateCompanyOutcomeDto } from '../../src/inspection-closing/dto/create-company-outcome.dto';
|
||||||
import { CreateInspectionSignatureDto } from '../../src/inspection-closing/dto/create-inspection-signature.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';
|
import { UpsertInspectionResponsibleDto } from '../../src/inspection-closing/dto/upsert-inspection-responsible.dto';
|
||||||
|
|
||||||
test('D5 present responsible requires identity and position', async () => {
|
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.consentAccepted, true);
|
||||||
assert.equal(dto.latitude, -32.889458);
|
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);
|
||||||
|
});
|
||||||
|
|||||||
@@ -126,11 +126,20 @@ INSERT INTO auth_sessions(
|
|||||||
SQL
|
SQL
|
||||||
|
|
||||||
docker compose --env-file .env.example up -d api
|
docker compose --env-file .env.example up -d api
|
||||||
|
|
||||||
|
# Gitea Actions runs Docker through DinD: the job container's 127.0.0.1 is
|
||||||
|
# not the Docker daemon host. Probe the API from inside its own container,
|
||||||
|
# matching the main CI contract instead of relying on the published host port.
|
||||||
|
api_health() {
|
||||||
|
docker compose --env-file .env.example exec -T api \
|
||||||
|
node -e 'fetch(`http://127.0.0.1:${process.env.API_PORT}/api/v3/health`).then(async r => { const t = await r.text(); if (!r.ok) { console.error(t); process.exit(1); } }).catch(() => process.exit(1))'
|
||||||
|
}
|
||||||
|
|
||||||
for _ in $(seq 1 30); do
|
for _ in $(seq 1 30); do
|
||||||
curl -fsS http://127.0.0.1:3101/api/v3/health >/dev/null 2>&1 && break
|
if api_health >/dev/null 2>&1; then break; fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
curl -fsS http://127.0.0.1:3101/api/v3/health >/dev/null
|
api_health >/dev/null
|
||||||
|
|
||||||
TOKEN="$(docker compose --env-file .env.example exec -T api node - <<'NODE'
|
TOKEN="$(docker compose --env-file .env.example exec -T api node - <<'NODE'
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
@@ -164,28 +173,29 @@ CONTEXT="$(docker compose --env-file .env.example exec -T db \
|
|||||||
IFS='|' read -r DEPARTMENT_ID AREA_ID YACIMIENTO_ID COMPANY_ID <<< "$CONTEXT"
|
IFS='|' read -r DEPARTMENT_ID AREA_ID YACIMIENTO_ID COMPANY_ID <<< "$CONTEXT"
|
||||||
test -n "$DEPARTMENT_ID" && test -n "$AREA_ID" && test -n "$YACIMIENTO_ID" && test -n "$COMPANY_ID"
|
test -n "$DEPARTMENT_ID" && test -n "$AREA_ID" && test -n "$YACIMIENTO_ID" && test -n "$COMPANY_ID"
|
||||||
|
|
||||||
curl -fsS -H "Authorization: Bearer $TOKEN" \
|
api_get() {
|
||||||
http://127.0.0.1:3101/api/v3/inspection-visits/planning-context/departments \
|
local request_path="$1"
|
||||||
>/tmp/dhv2-departments.json
|
docker compose --env-file .env.example exec -T \
|
||||||
|
-e REQUEST_TOKEN="$TOKEN" -e REQUEST_PATH="$request_path" api \
|
||||||
|
node -e 'fetch(`http://127.0.0.1:${process.env.API_PORT}${process.env.REQUEST_PATH}`, {headers:{Authorization:`Bearer ${process.env.REQUEST_TOKEN}`}}).then(async r => { const t=await r.text(); process.stdout.write(t); if (!r.ok) process.exit(1); }).catch(e => { console.error(e); process.exit(1); })'
|
||||||
|
}
|
||||||
|
|
||||||
|
api_get '/api/v3/inspection-visits/planning-context/departments' >/tmp/dhv2-departments.json
|
||||||
grep -Fq "$DEPARTMENT_ID" /tmp/dhv2-departments.json
|
grep -Fq "$DEPARTMENT_ID" /tmp/dhv2-departments.json
|
||||||
|
|
||||||
curl -fsS -H "Authorization: Bearer $TOKEN" \
|
api_get "/api/v3/inspection-visits/planning-context/departments/$DEPARTMENT_ID/areas" >/tmp/dhv2-areas.json
|
||||||
"http://127.0.0.1:3101/api/v3/inspection-visits/planning-context/departments/$DEPARTMENT_ID/areas" \
|
|
||||||
>/tmp/dhv2-areas.json
|
|
||||||
grep -Fq "$AREA_ID" /tmp/dhv2-areas.json
|
grep -Fq "$AREA_ID" /tmp/dhv2-areas.json
|
||||||
|
|
||||||
curl -fsS -H "Authorization: Bearer $TOKEN" \
|
api_get "/api/v3/inspection-visits/planning-context/areas/$AREA_ID/yacimientos" >/tmp/dhv2-yacimientos.json
|
||||||
"http://127.0.0.1:3101/api/v3/inspection-visits/planning-context/areas/$AREA_ID/yacimientos" \
|
|
||||||
>/tmp/dhv2-yacimientos.json
|
|
||||||
grep -Fq "$YACIMIENTO_ID" /tmp/dhv2-yacimientos.json
|
grep -Fq "$YACIMIENTO_ID" /tmp/dhv2-yacimientos.json
|
||||||
|
|
||||||
START_AT="$(date -u -d '+1 day' +'%Y-%m-%dT%H:%M:%S.000Z')"
|
START_AT="$(date -u -d '+1 day' +'%Y-%m-%dT%H:%M:%S.000Z')"
|
||||||
HTTP_CODE="$(curl -sS -o /tmp/dhv2-created.json -w '%{http_code}' \
|
REQUEST_BODY="{\"operationalAreaId\":\"$AREA_ID\",\"scopeAssetId\":\"$YACIMIENTO_ID\",\"operatorCompanyId\":\"$COMPANY_ID\",\"plannedStartAt\":\"$START_AT\",\"leadInspectorUserId\":\"22222222-2222-4222-8222-222222222222\"}"
|
||||||
-X POST \
|
POST_RESULT="$(docker compose --env-file .env.example exec -T \
|
||||||
-H "Authorization: Bearer $TOKEN" \
|
-e REQUEST_TOKEN="$TOKEN" -e REQUEST_BODY="$REQUEST_BODY" api \
|
||||||
-H 'Content-Type: application/json' \
|
node -e 'fetch(`http://127.0.0.1:${process.env.API_PORT}/api/v3/inspection-visits`, {method:"POST",headers:{Authorization:`Bearer ${process.env.REQUEST_TOKEN}`,"Content-Type":"application/json"},body:process.env.REQUEST_BODY}).then(async r => process.stdout.write(JSON.stringify({status:r.status,body:await r.text()}))).catch(e => { console.error(e); process.exit(1); })')"
|
||||||
-d "{\"operationalAreaId\":\"$AREA_ID\",\"scopeAssetId\":\"$YACIMIENTO_ID\",\"operatorCompanyId\":\"$COMPANY_ID\",\"plannedStartAt\":\"$START_AT\",\"leadInspectorUserId\":\"22222222-2222-4222-8222-222222222222\"}" \
|
HTTP_CODE="$(printf '%s' "$POST_RESULT" | python -c 'import json,sys; print(json.load(sys.stdin)["status"])')"
|
||||||
http://127.0.0.1:3101/api/v3/inspection-visits)"
|
printf '%s' "$POST_RESULT" | python -c 'import json,sys; sys.stdout.write(json.load(sys.stdin)["body"])' >/tmp/dhv2-created.json
|
||||||
if [ "$HTTP_CODE" != 201 ]; then
|
if [ "$HTTP_CODE" != 201 ]; then
|
||||||
echo "ERROR: real inspection create returned HTTP $HTTP_CODE" >&2
|
echo "ERROR: real inspection create returned HTTP $HTTP_CODE" >&2
|
||||||
cat /tmp/dhv2-created.json >&2
|
cat /tmp/dhv2-created.json >&2
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dhv2-web",
|
"name": "dhv2-web",
|
||||||
"version": "0.23.0-1",
|
"version": "0.23.0-2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dhv2-web",
|
"name": "dhv2-web",
|
||||||
"version": "0.23.0-1",
|
"version": "0.23.0-2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"maplibre-gl": "6.4.1",
|
"maplibre-gl": "6.4.1",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dhv2-web",
|
"name": "dhv2-web",
|
||||||
"version": "0.23.0-1",
|
"version": "0.23.0-2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export const APP_VERSION = '0.23.0-1';
|
export const APP_VERSION = '0.23.0-2';
|
||||||
export const APP_PHASE = 'F6.1 · Contexto operativo Área–Operadora consolidado';
|
export const APP_PHASE = 'F6.1 · Contexto operativo Área–Operadora consolidado';
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export function InspectionClosurePanel({ act }: { act: InspectionActF4 }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="responsible-summary">
|
<div className="responsible-summary">
|
||||||
<div><small>Urgencia</small><strong>{closure.act.urgency === 'URGENT' ? 'Urgente' : 'No urgente'}</strong></div>
|
<div><small>Urgencia</small><strong>{closure.act.urgency === 'URGENT' ? 'Urgente' : closure.act.urgency === 'NON_URGENT' ? 'No urgente' : 'Pendiente de cierre'}</strong></div>
|
||||||
<div><small>Plazo configurado</small><strong>{closure.act.deadlineDays ? `${closure.act.deadlineDays} días ${closure.act.deadlineDayType === 'BUSINESS' ? 'hábiles' : 'corridos'}` : 'Pendiente'}</strong></div>
|
<div><small>Plazo configurado</small><strong>{closure.act.deadlineDays ? `${closure.act.deadlineDays} días ${closure.act.deadlineDayType === 'BUSINESS' ? 'hábiles' : 'corridos'}` : 'Pendiente'}</strong></div>
|
||||||
<div><small>Inicio del plazo</small><strong>{closure.act.deadlineBaseAt ? formatDate(closure.act.deadlineBaseAt) : 'Pendiente de evento válido'}</strong></div>
|
<div><small>Inicio del plazo</small><strong>{closure.act.deadlineBaseAt ? formatDate(closure.act.deadlineBaseAt) : 'Pendiente de evento válido'}</strong></div>
|
||||||
<div><small>Vencimiento</small><strong>{closure.act.deadlineAt ? formatDate(closure.act.deadlineAt) : 'Todavía no iniciado'}</strong></div>
|
<div><small>Vencimiento</small><strong>{closure.act.deadlineAt ? formatDate(closure.act.deadlineAt) : 'Todavía no iniciado'}</strong></div>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export interface InspectionActListItemF4 {
|
|||||||
title: string;
|
title: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
observations: string | null;
|
observations: string | null;
|
||||||
urgency: InspectionActUrgencyF4;
|
urgency: InspectionActUrgencyF4 | null;
|
||||||
deadlineDays: number | null;
|
deadlineDays: number | null;
|
||||||
deadlineDayType: InspectionDeadlineDayTypeF4 | null;
|
deadlineDayType: InspectionDeadlineDayTypeF4 | null;
|
||||||
deadlineBasis: InspectionDeadlineBasisF4 | null;
|
deadlineBasis: InspectionDeadlineBasisF4 | null;
|
||||||
@@ -107,7 +107,7 @@ export interface InspectionClosureF4 {
|
|||||||
code: string;
|
code: string;
|
||||||
status: InspectionActStatusF4;
|
status: InspectionActStatusF4;
|
||||||
visitId: string;
|
visitId: string;
|
||||||
urgency: InspectionActUrgencyF4;
|
urgency: InspectionActUrgencyF4 | null;
|
||||||
deadlineDays: number | null;
|
deadlineDays: number | null;
|
||||||
deadlineDayType: InspectionDeadlineDayTypeF4 | null;
|
deadlineDayType: InspectionDeadlineDayTypeF4 | null;
|
||||||
deadlineBasis: InspectionDeadlineBasisF4 | null;
|
deadlineBasis: InspectionDeadlineBasisF4 | null;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export function InspectionActEditorPage() {
|
|||||||
<div className="responsible-summary">
|
<div className="responsible-summary">
|
||||||
<div><small>Fecha y hora</small><strong>{formatDate(act.occurredAt)}</strong></div>
|
<div><small>Fecha y hora</small><strong>{formatDate(act.occurredAt)}</strong></div>
|
||||||
<div><small>Título</small><strong>{act.title}</strong></div>
|
<div><small>Título</small><strong>{act.title}</strong></div>
|
||||||
<div><small>Urgencia</small><strong>{act.urgency === 'URGENT' ? 'Urgente' : 'No urgente'}</strong></div>
|
<div><small>Urgencia</small><strong>{act.urgency === 'URGENT' ? 'Urgente' : act.urgency === 'NON_URGENT' ? 'No urgente' : 'Pendiente de cierre'}</strong></div>
|
||||||
<div><small>Hallazgos</small><strong>{act.findingCount}</strong></div>
|
<div><small>Hallazgos</small><strong>{act.findingCount}</strong></div>
|
||||||
</div>
|
</div>
|
||||||
<div className="closure-section"><span className="eyebrow">DESCRIPCIÓN DE LO ACTUADO</span><p>{act.summary}</p>{act.observations && <><span className="eyebrow">OBSERVACIONES</span><p>{act.observations}</p></>}</div>
|
<div className="closure-section"><span className="eyebrow">DESCRIPCIÓN DE LO ACTUADO</span><p>{act.summary}</p>{act.observations && <><span className="eyebrow">OBSERVACIONES</span><p>{act.observations}</p></>}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user