Correção do QR do holerite entre outras coisas

This commit is contained in:
2026-06-16 17:01:36 -03:00
parent 80c068c798
commit cf896de165
7 changed files with 106 additions and 24 deletions

View File

@@ -55,6 +55,40 @@ module Pdf
"R$ #{format('%.2f', v.to_f)}".gsub('.', ',')
end
# Bloco de assinaturas lado a lado: motorista (esquerda) e administrador
# (direita). Garante espaço criando nova página se o rodapé estiver perto.
def assinaturas(motorista: nil)
@pdf.start_new_page if @pdf.cursor < 120
@pdf.move_down 60
metade = (@pdf.bounds.width - 40) / 2.0
topo = @pdf.cursor
@pdf.stroke_color '000000'
@pdf.line_width 0.7
@pdf.stroke_horizontal_line 0, metade, at: topo
@pdf.stroke_horizontal_line metade + 40, @pdf.bounds.width, at: topo
@pdf.move_down 8
linha_nome = @pdf.cursor
@pdf.fill_color '000000'
@pdf.text_box(motorista.presence || 'Motorista',
at: [0, linha_nome], width: metade, size: 9, style: :bold, align: :center)
@pdf.text_box('Reem Transporte',
at: [metade + 40, linha_nome], width: metade, size: 9, style: :bold, align: :center)
@pdf.move_down 14
linha_rotulo = @pdf.cursor
@pdf.fill_color CINZA
@pdf.text_box('Assinatura do Motorista',
at: [0, linha_rotulo], width: metade, size: 8, align: :center)
@pdf.text_box('Assinatura do Administrador',
at: [metade + 40, linha_rotulo], width: metade, size: 8, align: :center)
@pdf.fill_color '000000'
@pdf.move_down 24
end
def secao(titulo)
@pdf.move_down 14
@pdf.fill_color LARANJA

View File

@@ -69,10 +69,22 @@ module Pdf
# QR Code de login rápido
desenhar_qrcode if @user_motorista&.login_token.present?
assinaturas(motorista: @motorista)
end
# Monta a URL respeitando o esquema do APP_HOST. Se vier sem http(s)://
# (ex.: "100.75.222.23:3000") assume http — produção em IP:porta normalmente
# não tem TLS. Defina APP_HOST com "https://" se o servidor usar HTTPS.
def url_acesso
raw = @app_host.to_s.strip
protocolo = raw.start_with?('https://') ? 'https' : 'http'
host = raw.sub(%r{\Ahttps?://}, '').chomp('/')
"#{protocolo}://#{host}/motorista/acesso/#{@user_motorista.login_token}"
end
def desenhar_qrcode
url = "https://#{@app_host}/motorista/acesso/#{@user_motorista.login_token}"
url = url_acesso
qr = RQRCode::QRCode.new(url)
png = qr.as_png(size: 220, border_modules: 2)
@@ -86,7 +98,7 @@ module Pdf
@pdf.move_up 95
@pdf.text_box "Escaneie este QR Code com a câmera do celular para entrar\n" \
"no seu painel e acompanhar seus pagamentos.\n\n" \
"Ou acesse: #{@app_host}/motorista\ne use seu PIN de 4 dígitos.",
"Ou acesse: #{@app_host.to_s.sub(%r{\Ahttps?://}, '').chomp('/')}/motorista\ne use seu PIN de 4 dígitos.",
at: [130, @pdf.cursor], width: @pdf.bounds.width - 130, size: 9
@pdf.move_down 100
ensure

View File

@@ -29,12 +29,12 @@ module Pdf
secao "ENTREGAS (#{@entregas.size})"
if @entregas.any?
linhas = [['#', 'Tracking', 'NF', 'Endereço', 'Tipo', 'Valor']]
linhas = [['#', 'Veículo', 'NF', 'Endereço', 'Tipo', 'Valor']]
@entregas.each_with_index do |e, i|
original = e.entrega_original
linhas << [
(i + 1).to_s,
e.tracking_id.to_s.first(14),
original&.vehicle.presence || '—',
original ? "NF #{original.numero_nf}" : '—',
original ? original.address.to_s.first(45) : '—',
e.tipo_cor[:label],
@@ -79,6 +79,8 @@ module Pdf
@pdf.fill_color LARANJA
@pdf.text "TOTAL A PAGAR: #{moeda(total)}", size: 16, style: :bold
@pdf.fill_color '000000'
assinaturas(motorista: @motorista)
end
end
end