From 726768bb7878f8fc571ac70814c9a38eb362658c Mon Sep 17 00:00:00 2001 From: enlineawork Date: Fri, 11 Sep 2026 11:50:35 -0300 Subject: [PATCH] fix(android): cerrar ausencia de firma con outcome ABSENT --- .../dhinspeccion/ui/ModernMobileActsScreen.kt | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernMobileActsScreen.kt b/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernMobileActsScreen.kt index 2c0e5b8..137bf9a 100644 --- a/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernMobileActsScreen.kt +++ b/android-app/app/src/main/java/com/korexlabs/dhinspeccion/ui/ModernMobileActsScreen.kt @@ -383,7 +383,7 @@ fun ModernMobileActsScreen( val signatures = closure?.signatures.orEmpty() val inspectorSigned = signatures.any { it.signerType == "INSPECTOR" && it.status == "SIGNED" } val companyOutcome = signatures.firstOrNull { it.signerType == "COMPANY_RESPONSIBLE" } - val companyResolved = companyOutcome?.status == "SIGNED" || companyOutcome?.status == "REFUSED" + val companyResolved = companyOutcome?.status in setOf("SIGNED", "REFUSED", "ABSENT") ElevatedCard(Modifier.fillMaxWidth()) { Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) { @@ -392,7 +392,7 @@ fun ModernMobileActsScreen( Spacer(Modifier.width(8.dp)) Text("Acta pendiente de firma", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold) } - Text("El contenido ya es inmutable. Completá las firmas o dejá asentada la imposibilidad de firma para finalizarla.") + Text("El contenido ya es inmutable. Completá las firmas o dejá asentada la ausencia/negativa correspondiente para finalizarla.") closure?.closure?.preparedSha256?.let { Text("SHA-256 de cierre · $it", style = MaterialTheme.typography.bodySmall) } HorizontalDivider() @@ -413,35 +413,29 @@ fun ModernMobileActsScreen( if (companyOutcome != null && companyResolved) { val detail = when (companyOutcome.status) { "SIGNED" -> if (companyOutcome.companyManifestation == "DISSENT") "Firma en disidencia" else "Firma en conformidad" - "REFUSED" -> "Negativa o imposibilidad de firma registrada" + "REFUSED" -> "Negativa a firmar registrada" + "ABSENT" -> "Ausencia para la firma registrada" else -> "Manifestación registrada" } SuccessLine(detail) companyOutcome.reason?.let { Text(it, style = MaterialTheme.typography.bodySmall) } companyOutcome.companyStatement?.let { Text(it, style = MaterialTheme.typography.bodySmall) } } else if (closure?.responsible?.attendanceStatus == "ABSENT") { - Surface(Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.medium, color = MaterialTheme.colorScheme.errorContainer) { + val savedAbsenceReason = closure.responsible.absenceReason.orEmpty() + Surface(Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.medium, color = MaterialTheme.colorScheme.secondaryContainer) { Row(Modifier.padding(12.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - Icon(Icons.Filled.ErrorOutline, null, tint = MaterialTheme.colorScheme.error) - Text( - "El responsable fue registrado como ausente. Dejá asentado el motivo para resolver la firma de la empresa.", - Modifier.weight(1f), - style = MaterialTheme.typography.bodySmall, - ) + Icon(Icons.Filled.ErrorOutline, null, tint = MaterialTheme.colorScheme.secondary) + Column(Modifier.weight(1f)) { + Text("El responsable fue registrado como ausente.", fontWeight = FontWeight.SemiBold) + if (savedAbsenceReason.isNotBlank()) Text(savedAbsenceReason, style = MaterialTheme.typography.bodySmall) + } } } - OutlinedTextField( - refusalReason, - { refusalReason = it }, - label = { Text("Motivo de imposibilidad de firma *") }, - minLines = 2, - modifier = Modifier.fillMaxWidth(), - ) OutlinedButton( - onClick = { model.recordCompanyOutcome("REFUSED", refusalReason) }, - enabled = !model.busy && inspectorSigned && refusalReason.trim().length >= 10, + onClick = { model.recordCompanyOutcome("ABSENT", savedAbsenceReason) }, + enabled = !model.busy && inspectorSigned && savedAbsenceReason.trim().length >= 10, modifier = Modifier.fillMaxWidth(), - ) { Text("Registrar imposibilidad de firma") } + ) { Text("Registrar ausencia para la firma") } } else { Text(closure?.consents?.company.orEmpty(), style = MaterialTheme.typography.bodySmall) Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) { @@ -485,11 +479,11 @@ fun ModernMobileActsScreen( ) { Icon(Icons.Filled.CheckCircle, null) Spacer(Modifier.width(6.dp)) - Text("Finalizar Acta firmada") + Text("Finalizar Acta") } } else { Text( - "La inspección no puede cerrarse hasta resolver las firmas de esta Acta.", + "La inspección no puede cerrarse hasta resolver la firma, negativa o ausencia de esta Acta.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -503,7 +497,7 @@ fun ModernMobileActsScreen( Row(Modifier.padding(18.dp), horizontalArrangement = Arrangement.spacedBy(10.dp), verticalAlignment = Alignment.Top) { Icon(Icons.Filled.CheckCircle, null, tint = MaterialTheme.colorScheme.primary) Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(5.dp)) { - Text("Acta firmada e inmutable", fontWeight = FontWeight.Bold) + Text("Acta finalizada e inmutable", fontWeight = FontWeight.Bold) Text("Al finalizar se genera el PDF del Acta y el archivo INF editable para el Inspector.") closure?.closure?.finalSha256?.let { Text("SHA-256 final · $it", style = MaterialTheme.typography.bodySmall) } } @@ -526,7 +520,7 @@ fun ModernMobileActsScreen( Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(9.dp)) { Text("Finalizar inspección", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold) if (pendingActs.isEmpty()) { - SuccessLine("Todas las Actas están firmadas y finalizadas") + SuccessLine("Todas las Actas están finalizadas") } else { Text( "Actas pendientes de firma o finalización: ${pendingActs.joinToString { it.code }}", @@ -565,7 +559,7 @@ private fun documentTypeLabel(kind: String): String = when (kind) { private fun modernActStatusLabel(status: String): String = when (status) { "DRAFT" -> "Borrador" "LOCKED" -> "Pendiente de firma" - "SEALED" -> "Firmada" + "SEALED" -> "Finalizada" "CANCELLED" -> "Cancelada" else -> "Estado no reconocido" }