module BrInvoicesPdf::Cfe::Renderer::Header

Public Instance Methods

add_header_config(pdf, data, identificator) click to toggle source
# File lib/br_invoices_pdf/cfe/renderer/header.rb, line 36
def add_header_config(pdf, data, identificator)
  pdf.font('Helvetica', style: :bold)
  pdf.text("Extrato: #{data[:document_number]}", align: :center)
  pdf.text(identificator, align: :center)
  pdf.text('CUPOM FISCAL ELETRONICO - SAT', align: :center)
  pdf.font('Helvetica', style: :normal, align: :center)
end
execute(pdf, data) click to toggle source

:reek: FeatureEnvy

# File lib/br_invoices_pdf/cfe/renderer/header.rb, line 13
def execute(pdf, data)
  pdf_setup(pdf) do
    add_header_config(pdf, data, identificator(data))
  end

  pdf.move_down(5)
end
identificator(data) click to toggle source
# File lib/br_invoices_pdf/cfe/renderer/header.rb, line 21
def identificator(data)
  cpf = data[:cpf]
  cnpj = data[:cnpj]
  if cpf.to_s.empty?
    if cnpj.to_s.empty?
      'CONSUMIDOR NAO IDENTIFICADO'
    else
      'CONSUMIDOR: ' + format_cnpj(cnpj)
    end
  else
    'CONSUMIDOR: ' + format_cpf(cpf)
  end
end