Implantação Gráficos novos (Chart.js, padrão IIFE)

️ Custo por operação
This commit is contained in:
2026-06-17 17:03:22 -03:00
parent 50166686f8
commit a01af23691
3 changed files with 224 additions and 2 deletions

View File

@@ -48,6 +48,16 @@ class Consolidacao < ApplicationRecord
.select(:consolidacao_id))
}
# Consolidações que contêm QUALQUER das operações informadas (jsonb).
# SEGURANÇA: os nomes passam por whitelist (Operacao.sanitizar) e por quote.
scope :com_operacoes, ->(ops) {
validas = Operacao.sanitizar(ops)
next all if validas.empty?
lista = validas.map { |o| connection.quote(o) }.join(',')
where("EXISTS (SELECT 1 FROM jsonb_array_elements_text(COALESCE(operacoes, '[]'::jsonb)) e WHERE e IN (#{lista}))")
}
# ── Métodos ─────────────────────────────────────────────────
def arquivar!(user)