module BrInvoicesPdf::Nfce::Parser::Customer

Public Instance Methods

dest_root_path(xml) click to toggle source
# File lib/br_invoices_pdf/nfce/parser/customer.rb, line 12
def dest_root_path(xml)
  "#{root_path(xml)}/dest"
end
execute(xml) click to toggle source
# File lib/br_invoices_pdf/nfce/parser/customer.rb, line 16
def execute(xml)
  identification_type = identification_type_by(xml)
  root_path = dest_root_path(xml)

  {
    identification_type: identification_type,
    identification: locate_element(xml, "#{root_path}/#{identification_type}"),
    address: mount(xml, address_params(xml, root_path, 'Dest'))
  }
end
identification_type_by(xml) click to toggle source
# File lib/br_invoices_pdf/nfce/parser/customer.rb, line 27
def identification_type_by(xml)
  root_path = dest_root_path(xml)

  return 'CNPJ' if locate_element(xml, "#{root_path}/CNPJ")
  return 'CPF' if locate_element(xml, "#{root_path}/CPF")
  return 'idEstrangeiro' if locate_element(xml, "#{root_path}/idEstrangeiro")
end