Sha256: 27dd35f709ce3a2910bea89059cebf7ca875e1b71ab7a6232cec1218dee523c0
Contents?: true
Size: 1.02 KB
Versions: 14
Compression:
Stored size: 1.02 KB
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('WINDOWS-1252').encode('UTF-8')] } .to_h end private_class_method :product_by end end end end
Version data entries
14 entries across 14 versions & 1 rubygems