Sha256: 1f81d611e307ff9780cecbf590fd786007c4a02b95c79932c7a08fe2103e3105

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true

module BrInvoicesPdf
  module Nfce
    module Parser
      module Payments
        extend Util::XmlLocate

        module_function

        ROOT_PATH = Util::XmlLocate::ROOT_PATH

        def execute(xml)
          node_payments = xml.locate("#{ROOT_PATH}/pag")

          node_payments.map(&method(:payment_by))
        end

        def payment_by(element)
          {
            type: Util::Enum::PAYMENT_TYPES[locate_element(element, 'tPag')],
            amount: locate_element(element, 'vPag'),
            cashback: locate_element(element, 'vTroco')
          }
        end
        private_class_method :payment_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/payments.rb
br_invoices_pdf-0.2.6.alpha.19 lib/br_invoices_pdf/nfce/parser/payments.rb