Correção Dash board e implantação Relaório de ADM

This commit is contained in:
2026-06-22 17:11:53 -03:00
parent e23ca0f10d
commit 94d8420bbd
16 changed files with 453 additions and 39 deletions

View File

@@ -12,6 +12,44 @@ class DashboardController < ApplicationController
carregar_dados_dashboard
end
# GET /dashboard/relatorio_financeiro?inicio=&fim=&operacoes[]=
# Relatório financeiro do período (PDF) — mesmos números da tela.
def relatorio_financeiro
skip_authorization
return redirect_to(motorista_dashboard_path) if current_user.motorista?
@periodo_inicio, @periodo_fim = periodo_selecionado
carregar_dados_dashboard
op_label = @operacao_filtro.present? ? @operacao_filtro.map { |t| Operacao.label(t) }.join(', ') : 'Todas'
dados = {
custo_total: @fin_custo_total,
ticket_medio: @fin_ticket_medio,
pago: @fin_pago,
pendente: @fin_pendente,
por_operacao: @fin_por_operacao,
por_motorista: @fin_por_motorista,
por_tipo: @fin_por_tipo,
pagamentos_feitos: @pagamentos_feitos,
pagamentos_pendentes: @pagamentos_pendentes,
pag_pago_valor: @pag_pago_valor,
pag_pago_qtd: @pag_pago_qtd,
pag_pend_valor: @pag_pend_valor,
pag_pend_qtd: @pag_pend_qtd
}
pdf = Pdf::RelatorioFinanceiroPeriodoPdf.new(
periodo_inicio: @periodo_inicio, periodo_fim: @periodo_fim,
operacao_label: op_label, dados: dados
)
send_data pdf.render,
filename: "financeiro_#{@periodo_inicio.strftime('%Y%m%d')}_#{@periodo_fim.strftime('%Y%m%d')}.pdf",
type: 'application/pdf',
disposition: 'attachment'
end
private
# Faixa de datas vinda do filtro de calendário (params inicio/fim).