module BrInvoicesPdf::Nfce::Renderer::CustomerIdentification

Public Instance Methods

add_customer_identification(pdf, data, identificator) click to toggle source

:reek: FeatureEnvy

# File lib/br_invoices_pdf/nfce/renderer/customer_identification.rb, line 37
def add_customer_identification(pdf, data, identificator)
  address = data[:customer][:address]
  pdf.text("Consumidor\n\n", style: :italic)
  pdf.text(identificator, align: :center)
  pdf.text(format_address(address), align: :center) if address[:streetname]
end
execute(pdf, data) click to toggle source
# File lib/br_invoices_pdf/nfce/renderer/customer_identification.rb, line 12
def execute(pdf, data)
  box(pdf, [0, pdf.cursor], page_content_width(pdf)) do
    customer = data[:customer]
    add_customer_identification(pdf, data, identificator(customer[:identification_type],
                                                         customer[:identification]))
  end
end
identificator(identification, number) click to toggle source
# File lib/br_invoices_pdf/nfce/renderer/customer_identification.rb, line 20
def identificator(identification, number)
  id = identification

  case id
  when 'CPF'
    "CPF DO CONSUMIDOR: #{format_cpf(number)}"
  when 'CNPJ'
    "CNPJ DO CONSUMIDOR: #{format_cnpj(number)}"
  when 'idEstrangeiro'
    "ID. ESTRANGEIRO: #{number}"
  else
    'CONSUMIDOR NÃO IDENTIFICADO'
  end
end