Sha256: ef0e60bad93067d1fb12f2d8e6b20f1d2c362eaf98011f21d28fca387679bb90

Contents?: true

Size: 1.03 KB

Versions: 21

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module BrInvoicesPdf
  module Nfce
    module Parser
      module Customer
        extend Util::XmlLocate
        extend Util::MountParams

        module_function

        def dest_root_path(xml)
          "#{root_path(xml)}/dest"
        end

        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

        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
        private_class_method :identification_type_by
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.24 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.23 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.22 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.21 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.20 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.19 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.18 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.17 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.16 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.15 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.14 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.14.alpha.23 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.13 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.13.alpha.22 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.12.alpha.21 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.12.alpha.20 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.12 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.11 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.10 lib/br_invoices_pdf/nfce/parser/customer.rb
br_invoices_pdf-0.2.9 lib/br_invoices_pdf/nfce/parser/customer.rb