%# app/views/motorista/dashboard/totais.html.erb — Meu total no período %>
<% content_for :title, 'Meu total no período' %>
Meu total no período
<%= link_to rotulo(:voltar, 'Voltar', cor: nil), motorista_dashboard_path,
class: 'text-gray-300 hover:text-white border border-[#2a2a2a] px-4 py-3 rounded-xl min-h-[48px] flex items-center' %>
<%# ── Período ──────────────────────────────────────────── %>
<%= form_with url: motorista_totais_path, method: :get,
class: 'bg-[#1a1a1a] border border-[#2a2a2a] rounded-2xl p-4 mb-5 flex flex-wrap items-end gap-3' do |f| %>
De
<%= f.date_field :inicio, value: @inicio.strftime('%Y-%m-%d'),
class: 'w-full bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-xl px-3 py-3 text-base' %>
Até
<%= f.date_field :fim, value: @fim.strftime('%Y-%m-%d'),
class: 'w-full bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-xl px-3 py-3 text-base' %>
<%= f.submit 'Ver', class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold rounded-xl cursor-pointer px-6 py-3 min-h-[48px]' %>
<% end %>
<%# ── Total fechado ────────────────────────────────────── %>
<%= icone :sucesso, cor: 'text-green-600', espaco: false %> Total fechado no período
<%= icone :calendario, cor: 'text-gray-500' %> <%= l @inicio, format: :short %> a <%= l @fim, format: :short %>
<%= moeda(@totais.total_geral) %>
<%= icone :dinheiro, cor: 'text-green-700' %> Já pago: <%= moeda(@totais.total_pago) %>
<%= icone :parcial, cor: 'text-amber-700' %> A receber: <%= moeda(@totais.total_pendente) %>
Soma de <%= @consolidacoes.size %> fechamento(s) da empresa neste período.
<%= link_to rotulo(:baixar, 'Baixar relatório em PDF', cor: nil),
motorista_totais_pdf_path(inicio: @inicio, fim: @fim),
data: { turbo: false },
class: 'w-full bg-orange-500 hover:bg-orange-600 text-black font-bold text-base px-6 py-4 rounded-xl min-h-[52px] flex items-center justify-center mb-6' %>
<%# ── O que compõe o valor ─────────────────────────────── %>
<%= icone :composicao, espaco: false %> O que forma esse valor
Cada fechamento abaixo entra na soma acima.
<% if @consolidacoes.any? %>
<% @consolidacoes.each do |cm| %>
<% c = cm.consolidacao %>
<%= c.nome %>
<%= badge_pagamento(cm.pago? ? :pago : :pendente) %>
<%= icone :calendario %> <%= l c.data_inicio, format: :short %> a <%= l c.data_fim, format: :short %>
<%= moeda(cm.valor_total) %>
<% if cm.pago? %>
<%= icone :dinheiro, cor: 'text-green-400' %> Pago em <%= l cm.pago_em.to_date, format: :short %>
<% if cm.forma_pagamento.present? %>via <%= cm.forma_pagamento.humanize %><% end %>
<% if cm.nota_fiscal.present? %>
<%= icone :nota_fiscal %> Nota Fiscal: <%= cm.nota_fiscal %>
<% end %>
<% else %>
<%= icone :parcial, cor: 'text-amber-400' %> Ainda não pago
<% end %>
<%= link_to rotulo(:baixar, 'Extrato deste fechamento', cor: nil),
gerar_pdf_extrato_consolidacao_path(c, motorista: current_user.nome),
data: { turbo: false },
class: 'w-full md:w-auto bg-[#0a0a0a] border border-[#2a2a2a] hover:border-orange-500 text-white font-bold text-base px-5 py-4 rounded-xl min-h-[52px] flex items-center justify-center text-center' %>
<% end %>
<% else %>
<%= icone :vazio, tamanho: 'w-12 h-12', cor: 'text-gray-600', espaco: false %>
Nenhum fechamento neste período.
Escolha outro período acima — o fechamento aparece aqui quando a empresa finaliza a consolidação.
<% end %>