Sha256: 003ba2dd647ae530d26347764095a7dc42be583d6d0a678ef4e415956d3cc1df
Contents?: true
Size: 981 Bytes
Versions: 9
Compression:
Stored size: 981 Bytes
Contents
# frozen_string_literal: true module BrInvoicesPdf module Nfce module Parser module Products extend Util::XmlLocate module_function 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(xml)}/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('WINDOWS-1252').encode('UTF-8')] } .to_h end private_class_method :product_by end end end end
Version data entries
9 entries across 9 versions & 1 rubygems