Module: BrInvoicesPdf::Nfce::Parser::Totals

Extended by:
Util::XmlLocate
Defined in:
lib/br_invoices_pdf/nfce/parser/totals.rb

Class Method Summary collapse

Methods included from Util::XmlLocate

locate_element, node_locate, root_path

Class Method Details

.execute(xml) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/br_invoices_pdf/nfce/parser/totals.rb', line 15

def execute(xml)
  root_path = total_root_path(xml)

  {
    items: Products.execute(xml).count,
    subtotal: locate_element(xml, "#{root_path}/vProd"),
    discounts: locate_element(xml, "#{root_path}/vDesc"),
    total: locate_element(xml, "#{root_path}/vNF"),
    cashback: '0.00'
  }
end

.total_root_path(xml) ⇒ Object



11
12
13
# File 'lib/br_invoices_pdf/nfce/parser/totals.rb', line 11

def total_root_path(xml)
  "#{root_path(xml)}/total/ICMSTot"
end