Sha256: 17b999ba18bc23e4c8a581b219707d7e56584912366eb473c934cc8d56fd4351
Contents?: true
Size: 1001 Bytes
Versions: 2
Compression:
Stored size: 1001 Bytes
Contents
# frozen_string_literal: true module BrInvoicesPdf module Nfce module Parser module Products extend Util::XmlLocate module_function ROOT_PATH = Util::XmlLocate::ROOT_PATH FIELDS = { code: 'cProd', description: 'xProd', quantity: 'qCom', unit_label: 'uCom', unit_value: 'vUnCom', total_value: 'vProd' }.freeze def execute(xml) node_products = xml.locate("#{ROOT_PATH}/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).force_encoding('UTF-8')] } .to_h end private_class_method :product_by end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
br_invoices_pdf-0.2.7 | lib/br_invoices_pdf/nfce/parser/products.rb |
br_invoices_pdf-0.2.6.alpha.19 | lib/br_invoices_pdf/nfce/parser/products.rb |