Sha256: fd060ff888144e42adc1caf75aeb62e1d8f1caabd7b0206797abc9119888a5d6

Contents?: true

Size: 963 Bytes

Versions: 12

Compression:

Stored size: 963 Bytes

Contents

module BrInvoicesPdf
  module Cfe
    module Parser
      module ProductsData
        extend BaseParser

        module_function

        FIELDS = { code: 'cProd',
                   description: 'xProd',
                   cfop: 'CFOP',
                   quantity: 'qCom',
                   unit_label: 'uCom',
                   total_value: 'vProd',
                   unit_value: 'vUnCom',
                   item_value: 'vItem' }.freeze

        def execute(xml)
          node_products = xml.locate('infCFe/det')
          products_params(node_products) if node_products
        end

        def products_params(node_products)
          node_products.map(&method(:product_by))
        end
        private_class_method :products_params

        def product_by(element)
          FIELDS
            .map { |(key, field)| [key, node_locate(element, field)] }
            .to_h
        end
        private_class_method :product_by
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.5.alpha.17 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.5 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.5.alpha.16 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.4 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.4.alpha.15 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.4.alpha.14 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.3 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.2 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.1 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.0 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.0.alpha.13 lib/br_invoices_pdf/cfe/parser/products_data.rb
br_invoices_pdf-0.2.0.alpha.12 lib/br_invoices_pdf/cfe/parser/products_data.rb