diff --git a/src/lib/server/controldesk-pg.ts b/src/lib/server/controldesk-pg.ts index 3d6c258..a2a2726 100644 --- a/src/lib/server/controldesk-pg.ts +++ b/src/lib/server/controldesk-pg.ts @@ -173,7 +173,8 @@ const ROW_DATABASE_NODE = ` server_name AS "ServerName", database_name AS "BDName", restore_target_id AS "RestoreTargetId", - anexo24c_aviso_fecha AS "Anexo24CAvisoFecha" + anexo24c_aviso_fecha AS "Anexo24CAvisoFecha", + anexo24c_cambio_sistema AS "Anexo24CCambioSistema" `; const ROW_PORTAL_USER = ` @@ -378,6 +379,7 @@ export async function insertDatabaseNode(row: { activo: number; restoreTargetId?: number | null; anexo24CAvisoFecha?: string | null; + anexo24CCambioSistema?: boolean; }): Promise { // server_name y sql_password se derivan del servidor de restauración asignado (su IP y su // credencial SQL cifrada); si el target aún no tiene IP, se conserva el serverName recibido. @@ -386,13 +388,13 @@ export async function insertDatabaseNode(row: { INSERT INTO ${qNodes()} ( node_subnode_key, rfc, legal_name, branch_name, notification_email, server_name, database_name, is_active, restore_target_id, - sql_password, anexo24c_aviso_fecha + sql_password, anexo24c_aviso_fecha, anexo24c_cambio_sistema ) VALUES ( $1, $2, $3, $4, $5, COALESCE((SELECT server_ip FROM ${qRestoreTargets()} WHERE id = $9), $6), $7, $8, $9, (SELECT sql_password_encrypted FROM ${qRestoreTargets()} WHERE id = $9), - $10 + $10, $11 ) `, [ @@ -405,7 +407,8 @@ export async function insertDatabaseNode(row: { row.bdName, row.activo, row.restoreTargetId ?? null, - row.anexo24CAvisoFecha ?? null + row.anexo24CAvisoFecha ?? null, + row.anexo24CCambioSistema ?? false ] ); } @@ -423,6 +426,7 @@ export async function updateDatabaseNode( activo: number; restoreTargetId?: number | null; anexo24CAvisoFecha?: string | null; + anexo24CCambioSistema?: boolean; } ): Promise { await pgPool.query( @@ -438,8 +442,9 @@ export async function updateDatabaseNode( is_active = $8, restore_target_id = $9, sql_password = (SELECT sql_password_encrypted FROM ${qRestoreTargets()} WHERE id = $9), - anexo24c_aviso_fecha = $10 - WHERE id = $11 + anexo24c_aviso_fecha = $10, + anexo24c_cambio_sistema = $11 + WHERE id = $12 `, [ row.nodoSubNodo, @@ -452,6 +457,7 @@ export async function updateDatabaseNode( row.activo, row.restoreTargetId ?? null, row.anexo24CAvisoFecha ?? null, + row.anexo24CCambioSistema ?? false, id ] ); diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 79c3400..54892af 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -49,6 +49,12 @@ function parseActivoField(formData: FormData): number { return v === 'true' || v === '1' ? 1 : 0; } +/** Si el cliente presento aviso de cambio de sistema apartado C (T2026-06-111). */ +function parseAnexo24CCambioSistemaField(formData: FormData): boolean { + const v = formData.get('Anexo24CCambioSistema'); + return v === 'true' || v === '1'; +} + /** Lee el id del servidor de restauración elegido (radio); null si no se asignó. */ function parseRestoreTargetId(formData: FormData): number | null { const v = formData.get('restore_target_id'); @@ -498,6 +504,7 @@ export const actions: Actions = { // Fecha de aviso SAT Anexo 24C (T2026-06-111), opcional: vacio = sin fecha. const anexo24CAvisoFechaRaw = String(formData.get('Anexo24CAvisoFecha') || '').trim(); const anexo24CAvisoFecha = anexo24CAvisoFechaRaw || null; + const anexo24CCambioSistema = parseAnexo24CCambioSistemaField(formData); if (!nodoSubNodo || !rfc || !nombre || !correo) { return { success: false, message: 'Faltan campos requeridos' }; @@ -513,7 +520,8 @@ export const actions: Actions = { bdName, activo, restoreTargetId, - anexo24CAvisoFecha + anexo24CAvisoFecha, + anexo24CCambioSistema }); return { success: true }; @@ -543,6 +551,7 @@ export const actions: Actions = { // Fecha de aviso SAT Anexo 24C (T2026-06-111), opcional: vacio = sin fecha. const anexo24CAvisoFechaRaw = String(formData.get('Anexo24CAvisoFecha') || '').trim(); const anexo24CAvisoFecha = anexo24CAvisoFechaRaw || null; + const anexo24CCambioSistema = parseAnexo24CCambioSistemaField(formData); if (!id || !nodoSubNodo || !rfc || !nombre || !correo) { return { success: false, message: 'Faltan campos requeridos' }; @@ -558,7 +567,8 @@ export const actions: Actions = { bdName, activo, restoreTargetId, - anexo24CAvisoFecha + anexo24CAvisoFecha, + anexo24CCambioSistema }); return { success: true }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0c0be20..c8687f4 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -504,7 +504,8 @@ BDName: '', Activo: true, RestoreTargetId: null, - Anexo24CAvisoFecha: '' + Anexo24CAvisoFecha: '', + Anexo24CCambioSistema: false }); const openCreateDbModal = () => { @@ -522,7 +523,8 @@ BDName: suggestedNodo, Activo: true, RestoreTargetId: null, - Anexo24CAvisoFecha: '' + Anexo24CAvisoFecha: '', + Anexo24CCambioSistema: false }; showDbCrudModal = true; }; @@ -544,7 +546,8 @@ BDName: bd.BDName ?? '', Activo: !!bd.Activo, RestoreTargetId: bd.RestoreTargetId ?? null, - Anexo24CAvisoFecha: bd.Anexo24CAvisoFecha ?? '' + Anexo24CAvisoFecha: bd.Anexo24CAvisoFecha ?? '', + Anexo24CCambioSistema: !!bd.Anexo24CCambioSistema }; showDbCrudModal = true; }; @@ -572,6 +575,7 @@ form.append('restore_target_id', String(formDb.RestoreTargetId)); } form.append('Anexo24CAvisoFecha', formDb.Anexo24CAvisoFecha ?? ''); + form.append('Anexo24CCambioSistema', formDb.Anexo24CCambioSistema ? '1' : '0'); try { const res = await fetch(`?/${action}`, { @@ -2510,7 +2514,20 @@ - + +
+ + +
+ +