Class: FE::Document::Summary

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/facturacr/document/summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Summary

Returns a new instance of Summary.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/facturacr/document/summary.rb', line 14

def initialize(args={})
  @currency = args[:currency]
  @exchange_rate = args[:exchange_rate]
  @services_taxable_total = args[:services_taxable_total].to_f
  @services_exent_total = args[:services_exent_total].to_f
  @goods_taxable_total = args[:goods_taxable_total].to_f
  @goods_exent_total = args[:goods_exent_total].to_f
  @taxable_total = args[:taxable_total].to_f
  @exent_total = args[:exent_total].to_f
  @subtotal = args[:subtotal].to_f
  @discount_total = args[:discount_total].to_f
  @gross_total = args[:gross_total].to_f
  @tax_total = args[:tax_total].to_f
  @net_total = args[:net_total].to_f
end

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def currency
  @currency
end

#discount_totalObject

Returns the value of attribute discount_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def discount_total
  @discount_total
end

#exchange_rateObject

Returns the value of attribute exchange_rate.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def exchange_rate
  @exchange_rate
end

#exent_totalObject

Returns the value of attribute exent_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def exent_total
  @exent_total
end

#goods_exent_totalObject

Returns the value of attribute goods_exent_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def goods_exent_total
  @goods_exent_total
end

#goods_taxable_totalObject

Returns the value of attribute goods_taxable_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def goods_taxable_total
  @goods_taxable_total
end

#gross_totalObject

Returns the value of attribute gross_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def gross_total
  @gross_total
end

#net_totalObject

Returns the value of attribute net_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def net_total
  @net_total
end

#services_exent_totalObject

Returns the value of attribute services_exent_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def services_exent_total
  @services_exent_total
end

#services_taxable_totalObject

Returns the value of attribute services_taxable_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def services_taxable_total
  @services_taxable_total
end

#subtotalObject

Returns the value of attribute subtotal.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def subtotal
  @subtotal
end

#tax_totalObject

Returns the value of attribute tax_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def tax_total
  @tax_total
end

#taxable_totalObject

Returns the value of attribute taxable_total.



6
7
8
# File 'lib/facturacr/document/summary.rb', line 6

def taxable_total
  @taxable_total
end

Instance Method Details

#build_xml(node) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/facturacr/document/summary.rb', line 30

def build_xml(node)
  unless valid?
    raise "Summary invalid: #{errors.messages}" 
  end        
  node = Nokogiri::XML::Builder.new if node.nil?
  
  node.ResumenFactura do |xml|
    xml.CodigoMoneda @currency if @currency.present?
    xml.TipoCambio @exchange_rate if @exchange_rate.present?
    xml.TotalServGravados @services_taxable_total
    xml.TotalServExentos @services_exent_total
    xml.TotalMercanciasGravadas @goods_taxable_total
    xml.TotalMercanciasExentas @goods_exent_total
    xml.TotalGravado @taxable_total
    xml.TotalExento @exent_total
    xml.TotalVenta @subtotal
    xml.TotalDescuentos @discount_total
    xml.TotalVentaNeta @gross_total
    xml.TotalImpuesto @tax_total
    xml.TotalComprobante @net_total
  end
end