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

This commit is contained in:
2026-06-17 15:21:29 -03:00
parent 69448ddabd
commit 5b2de23cfe
3 changed files with 1811 additions and 1368 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -43,11 +43,16 @@ module Pdf
end end
def rodape def rodape
# canvas usa coordenadas absolutas da página, então o rodapé é desenhado
# DENTRO da margem inferior (y=36), abaixo da área de conteúdo. Antes ele
# ficava em y=20 do bounds — dentro do fluxo do conteúdo — e o texto da
# tabela acabava sobrepondo o "documento interno".
@pdf.repeat(:all) do @pdf.repeat(:all) do
@pdf.bounding_box [0, 20], width: @pdf.bounds.width do @pdf.canvas do
@pdf.fill_color CINZA @pdf.fill_color CINZA
@pdf.text "Gerado em #{Time.current.strftime('%d/%m/%Y %H:%M')} · Reem Transporte — documento interno", @pdf.text_box "Gerado em #{Time.current.strftime('%d/%m/%Y %H:%M')} · Reem Transporte — documento interno",
size: 8, align: :center at: [40, 36], width: @pdf.bounds.width - 80,
size: 8, align: :center
@pdf.fill_color '000000' @pdf.fill_color '000000'
end end
end end

View File

@@ -37,14 +37,15 @@ module Pdf
secao "PROVENTOS E DESCONTOS" secao "PROVENTOS E DESCONTOS"
resumo = @entregas.group(:tipo).count resumo = @entregas.group(:tipo).count
# Lista os quatro pilares sempre (Normal, Retirada, Bônus, Desconto),
# mesmo zerados, para o motorista ver o descritivo completo.
por_tipo = ConsolidacaoEntrega::TIPO_CORES.map do |tipo, cfg| por_tipo = ConsolidacaoEntrega::TIPO_CORES.map do |tipo, cfg|
qtd = resumo[tipo] || 0 qtd = resumo[tipo] || 0
next if qtd.zero? valor = qtd.zero? ? 0 : @entregas.where(tipo: tipo).sum(:valor_aplicado)
valor = @entregas.where(tipo: tipo).sum(:valor_aplicado)
unit = qtd.zero? ? 0 : (valor / qtd) unit = qtd.zero? ? 0 : (valor / qtd)
sinal = tipo == 'desconto' ? '-' : '+' sinal = tipo == 'desconto' ? '-' : '+'
[cfg[:label], qtd.to_s, moeda(unit), "#{sinal} #{moeda(valor)}"] [cfg[:label], qtd.to_s, moeda(unit), "#{sinal} #{moeda(valor)}"]
end.compact end
linhas = [['Descrição', 'Qtd', 'Unit.', 'Valor']] + por_tipo linhas = [['Descrição', 'Qtd', 'Unit.', 'Valor']] + por_tipo
@pdf.table(linhas, header: true, width: @pdf.bounds.width, @pdf.table(linhas, header: true, width: @pdf.bounds.width,