Atualização da dos Arquivos PDF Holerite e relatório

This commit is contained in:
2026-06-17 15:10:56 -03:00
parent 0a12b10acc
commit 69448ddabd
5 changed files with 4297 additions and 6 deletions

View File

@@ -41,17 +41,18 @@ module Pdf
qtd = resumo[tipo] || 0
next if qtd.zero?
valor = @entregas.where(tipo: tipo).sum(:valor_aplicado)
unit = qtd.zero? ? 0 : (valor / qtd)
sinal = tipo == 'desconto' ? '-' : '+'
[cfg[:label], qtd.to_s, "#{sinal} #{moeda(valor)}"]
[cfg[:label], qtd.to_s, moeda(unit), "#{sinal} #{moeda(valor)}"]
end.compact
linhas = [['Descrição', 'Qtd', 'Valor']] + por_tipo
linhas = [['Descrição', 'Qtd', 'Unit.', 'Valor']] + por_tipo
@pdf.table(linhas, header: true, width: @pdf.bounds.width,
cell_style: { size: 10, padding: [6, 8] }) do |t|
t.row(0).background_color = PRETO
t.row(0).text_color = 'FFFFFF'
t.row(0).font_style = :bold
t.columns(1..2).align = :right
t.columns(1..3).align = :right
end
total = @entregas.sum { |e| e.desconto? ? -e.valor_aplicado : e.valor_aplicado }
@@ -67,6 +68,15 @@ module Pdf
at: [16, @pdf.cursor - 24], size: 22, style: :bold
@pdf.move_down 64
# Detalhamento: total de entregas e veículos atendidos no período
total_entregas = @entregas.count
veiculos = @entregas.map { |e| e.entrega_original&.vehicle }.compact.uniq
@pdf.fill_color CINZA
@pdf.text "Total de entregas: #{total_entregas}", size: 9
@pdf.text "Veículos atendidos: #{veiculos.any? ? veiculos.join(', ') : '—'}", size: 9
@pdf.fill_color '000000'
@pdf.move_down 8
# QR Code de login rápido
desenhar_qrcode if @user_motorista&.login_token.present?