Sha256: 078977ba066d8eadb15ef6e9eb9c8053a969fd500ff035f6a393b47d97d743e7

Contents?: true

Size: 638 Bytes

Versions: 15

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

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

        module_function

        def execute(xml)
          node_payments = xml.locate("#{root_path(xml)}/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

15 entries across 15 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.18 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.17 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.16 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.15 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.14 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.14.alpha.23 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.13 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.13.alpha.22 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.12.alpha.21 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.12.alpha.20 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.12 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.11 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.10 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.9 lib/br_invoices_pdf/nfce/parser/payments.rb
br_invoices_pdf-0.2.8 lib/br_invoices_pdf/nfce/parser/payments.rb