Sha256: e5b91c27fc9eb2c94be2c8d6fdbb6d990d12d3ebab9fd5ede2713612e1b5fcd9
Contents?: true
Size: 1023 Bytes
Versions: 6
Compression:
Stored size: 1023 Bytes
Contents
# frozen_string_literal: true module BrInvoicesPdf module Cfe module Parser module ProductsData extend Util::XmlLocate 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).force_encoding('UTF-8')] } .to_h end private_class_method :product_by end end end end
Version data entries
6 entries across 6 versions & 1 rubygems