Atualização 2 da dos Arquivos PDF Holerite e relatório
This commit is contained in:
@@ -37,14 +37,15 @@ module Pdf
|
||||
secao "PROVENTOS E DESCONTOS"
|
||||
|
||||
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|
|
||||
qtd = resumo[tipo] || 0
|
||||
next if qtd.zero?
|
||||
valor = @entregas.where(tipo: tipo).sum(:valor_aplicado)
|
||||
valor = qtd.zero? ? 0 : @entregas.where(tipo: tipo).sum(:valor_aplicado)
|
||||
unit = qtd.zero? ? 0 : (valor / qtd)
|
||||
sinal = tipo == 'desconto' ? '-' : '+'
|
||||
[cfg[:label], qtd.to_s, moeda(unit), "#{sinal} #{moeda(valor)}"]
|
||||
end.compact
|
||||
end
|
||||
|
||||
linhas = [['Descrição', 'Qtd', 'Unit.', 'Valor']] + por_tipo
|
||||
@pdf.table(linhas, header: true, width: @pdf.bounds.width,
|
||||
|
||||
Reference in New Issue
Block a user