docs: oficializadas regras de integridade numérica e sincronia em tempo real no GEMINI e MEMORY

This commit is contained in:
Sidney 2026-05-08 10:43:32 -03:00
parent 839b3ca4eb
commit 198ec471cd
2 changed files with 9 additions and 4 deletions

View File

@ -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.

View File

@ -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.