feat(database): add Anexo 24C notification date handling in database operations
Some checks failed
Aduanasoft/PANEL_BASES_ANEXO24/pipeline/head There was a failure building this commit

This commit is contained in:
2026-07-09 12:23:41 -05:00
parent 7f9d502cb1
commit 79035002e1
4 changed files with 53 additions and 12 deletions

View File

@@ -172,7 +172,8 @@ const ROW_DATABASE_NODE = `
notification_email AS "CorreoNotificacion",
server_name AS "ServerName",
database_name AS "BDName",
restore_target_id AS "RestoreTargetId"
restore_target_id AS "RestoreTargetId",
anexo24c_aviso_fecha AS "Anexo24CAvisoFecha"
`;
const ROW_PORTAL_USER = `
@@ -377,6 +378,7 @@ export async function insertDatabaseNode(row: {
bdName: string;
activo: number;
restoreTargetId?: number | null;
anexo24CAvisoFecha?: string | null;
}): Promise<void> {
// 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.
@@ -385,12 +387,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
sql_password, anexo24c_aviso_fecha
) 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)
(SELECT sql_password_encrypted FROM ${qRestoreTargets()} WHERE id = $9),
$10
)
`,
[
@@ -402,7 +405,8 @@ export async function insertDatabaseNode(row: {
row.serverName,
row.bdName,
row.activo,
row.restoreTargetId ?? null
row.restoreTargetId ?? null,
row.anexo24CAvisoFecha ?? null
]
);
}
@@ -419,6 +423,7 @@ export async function updateDatabaseNode(
bdName: string;
activo: number;
restoreTargetId?: number | null;
anexo24CAvisoFecha?: string | null;
}
): Promise<void> {
await pgPool.query(
@@ -433,8 +438,9 @@ export async function updateDatabaseNode(
database_name = $7,
is_active = $8,
restore_target_id = $9,
sql_password = (SELECT sql_password_encrypted FROM ${qRestoreTargets()} WHERE id = $9)
WHERE id = $10
sql_password = (SELECT sql_password_encrypted FROM ${qRestoreTargets()} WHERE id = $9),
anexo24c_aviso_fecha = $10
WHERE id = $11
`,
[
row.nodoSubNodo,
@@ -446,6 +452,7 @@ export async function updateDatabaseNode(
row.bdName,
row.activo,
row.restoreTargetId ?? null,
row.anexo24CAvisoFecha ?? null,
id
]
);

View File

@@ -1,7 +1,12 @@
import pkg from 'pg';
const { Pool } = pkg;
const { Pool, types } = pkg;
import { env } from '$env/dynamic/private';
// DATE (OID 1082): devolver el string 'YYYY-MM-DD' crudo. Por default pg lo parsea
// como Date en hora LOCAL del proceso, y un uso posterior de .toISOString() puede
// desfasar el dia segun el timezone del servidor (afecta a24c.database_nodes.anexo24c_aviso_fecha).
types.setTypeParser(1082, (val: string) => val);
// Pool de PostgreSQL para usuarios y permisos
const pgPool = new Pool({
host: env.DB_POSTGRES_HOST || '10.0.20.152',