From 198ec471cdc9f1fbee6c1db36d768d30a74f0721 Mon Sep 17 00:00:00 2001 From: Sidney Date: Fri, 8 May 2026 10:43:32 -0300 Subject: [PATCH] =?UTF-8?q?docs:=20oficializadas=20regras=20de=20integrida?= =?UTF-8?q?de=20num=C3=A9rica=20e=20sincronia=20em=20tempo=20real=20no=20G?= =?UTF-8?q?EMINI=20e=20MEMORY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GEMINI.md | 2 ++ MEMORY.md | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/GEMINI.md b/GEMINI.md index af79304..7a48aa9 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -57,3 +57,5 @@ 28. **Frequency Parity Rule**: The Portal MUST mirror the Manager's attendance matching logic exactly, including time windows (30m before) and end-of-day fallbacks (23:59), to ensure data consistency between Admin and Student views. 29. **Hybrid Identity Lookup**: Automated messaging services MUST implement a hybrid lookup for students: first check the legacy `school_data` JSON, then fallback to the PostgreSQL `alunos` table. This ensures support for both migrated and newly created students. 30. **Financial Data Integrity**: Automation routines MUST prioritize `school_data.payments` (JSON) as the trigger source while using `alunos_cobrancas` (SQL) for tracking notification counters (spam control), ensuring 100% parity with the management UI. +31. **Real-Time Bidirectional Sync**: Asaas webhooks MUST update both the PostgreSQL `alunos_cobrancas` table and the legacy `school_data.json` file in real-time to ensure immediate UI feedback in the administrative panel. +32. **Numerical Type Enforcement**: When serving data from PostgreSQL `NUMERIC` columns, the backend MUST map the result to ensure amounts are sent as `Number` (not String) to prevent string concatenation bugs in the frontend. diff --git a/MEMORY.md b/MEMORY.md index ba9fb1f..946ef84 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -107,10 +107,13 @@ - **Melhoria:** O build agora ocorre diretamente na arquitetura de destino, sem emulação QEMU, garantindo velocidade e estabilidade total. ### 📅 08/05/2026 - Estabilização Crítica de Automação e Sincronia Financeira -- **Fonte de Disparos:** A rotina de cobranças agora utiliza o `school_data.payments` (JSON) como fonte primária para garantir 100% de paridade com o painel financeiro, eliminando falhas de "tabela vazia". -- **Sincronização Financeira:** Implementado o espelhamento automático de `data.payments` (JSON) para a tabela `alunos_cobrancas` (SQL) com trava de unicidade no `asaas_payment_id`. -- **Busca Híbrida de Alunos:** O envio de WhatsApp agora busca o aluno primeiro no JSON e, caso não encontre, faz o fallback para a tabela SQL `alunos`. -- **Resiliência de Telefone:** Implementada lógica de "Melhor Esforço" para seleção de telefone (Responsável vs Aluno) e proteção contra erro de `NaN` na formatação de valores. +- 30. **Financial Data Integrity**: Automation routines MUST prioritize `school_data.payments` (JSON) as the trigger source while using `alunos_cobrancas` (SQL) for tracking notification counters (spam control), ensuring 100% parity with the management UI. +- 31. **Real-Time Bidirectional Sync**: Asaas webhooks MUST update both the PostgreSQL `alunos_cobrancas` table and the legacy `school_data.json` file in real-time to ensure immediate UI feedback in the administrative panel. +- 32. **Numerical Type Enforcement**: When serving data from PostgreSQL `NUMERIC` columns, the backend MUST map the result to ensure amounts are sent as `Number` (not String) to prevent string concatenation bugs in the frontend. +- **Sincronização Bidirecional (Webhook):** O webhook do Asaas agora atualiza o SQL **e** o arquivo `school_data.json` em tempo real, garantindo que o status "Pago" apareça instantaneamente no painel. +- **Integridade Numérica:** Resolvido bug de exibição de valores (concatenação de strings) através de casting explícito para `Number()` no backend e frontend. +- **Busca Híbrida de Alunos:** O envio de WhatsApp agora busca o aluno no JSON e faz fallback no SQL. +- **Resiliência de Telefone:** Lógica de "Melhor Esforço" para seleção de telefone (Responsável vs Aluno). ### 📢 Automação de Mensagens - [x] **Estabilização de Lembretes (V2):** Resolvido bug de deslocamento de fuso horário (-1 dia) nas datas de vencimento. Implementadas ferramentas de debug (ignorar trava diária e reset de contadores) e **controle manual de delay para disparos em massa** para facilitar testes e garantir segurança contra banimento.