Leonardo e409ba64ef Saldo baixo WhatsApp: trigger dispara notificação ao cruzar threshold
Fecha o loop do Marco B — tenant não zera mais saldo sem aviso.

Nova função fn_whatsapp_low_balance_notify + trigger BEFORE UPDATE em
whatsapp_credits_balance:
- Dispara quando NEW.balance < NEW.low_balance_threshold e
  NEW.low_balance_alerted_at IS NULL
- Insere system_alert pros stakeholders do tenant (owner do canal
  WhatsApp ativo + clinic_admin + tenant_admin, deduplicado via UNION)
- Deeplink direto pra /configuracoes/creditos-whatsapp
- Seta NEW.low_balance_alerted_at = now() pra anti-spam

Reset do anti-spam já existia: add_whatsapp_credits seta
low_balance_alerted_at=NULL ao creditar (purchase/topup/refund).
Assim o ciclo completo funciona: cai abaixo → alerta → compra recrédita
→ cai de novo futuramente → alerta de novo.

Toast no frontend já é sticky vermelho pra type='system_alert'
(commit anterior). Config de threshold já existia na UI em
/configuracoes/creditos-whatsapp.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 09:25:03 -03:00
2024-07-29 10:14:47 +03:00
2024-07-25 16:41:34 +03:00
2026-02-18 22:36:45 -03:00
2026-03-06 06:37:13 -03:00
2024-07-29 10:14:47 +03:00
2024-07-25 16:41:34 +03:00
2026-02-18 22:36:45 -03:00
2026-03-06 06:37:13 -03:00
2024-07-25 16:41:34 +03:00
2022-12-28 14:04:39 +03:00
2024-08-03 11:36:25 +03:00
2026-03-12 08:58:36 -03:00
2024-03-18 10:33:41 +03:00

Sakai is an application template for Vue based on the create-vue, the recommended way to start a Vite-powered Vue projects.

Visit the documentation to get started.

S
Description
No description provided
Readme 56 MiB
Languages
Vue 61.3%
PLpgSQL 17.4%
JavaScript 16%
HTML 2.7%
TypeScript 2.3%
Other 0.3%