Sha256: 25ea5664ca10caef086bdd4810185c28a6b55a7db8b2358d141dfc75feced32c
Contents?: true
Size: 994 Bytes
Versions: 2
Compression:
Stored size: 994 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).force_encoding('UTF-8'.freeze)] } .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.6 | lib/br_invoices_pdf/cfe/parser/products_data.rb |
br_invoices_pdf-0.2.6.alpha.18 | lib/br_invoices_pdf/cfe/parser/products_data.rb |