Class: Interfactura::Ruby::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/interfactura/ruby/invoice.rb

Constant Summary collapse

IVA =
0.16

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Invoice

Returns a new instance of Invoice.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/interfactura/ruby/invoice.rb', line 10

def initialize(attributes = {})
  @id = attributes[:id]
  @total = attributes[:total]
  @zipcode = attributes[:zipcode]
  @state = attributes[:state]
  @colony = attributes[:colony]
  @rfc = attributes[:rfc]
  @name = attributes[:name]
  @phone = attributes[:phone]
  @email = attributes[:email]
  @city = attributes[:city]
  @municipality = attributes[:municipality]
  @street = attributes[:street]
  @number = attributes[:number]
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def city
  @city
end

#colonyObject

Returns the value of attribute colony.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def colony
  @colony
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def email
  @email
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def id
  @id
end

#municipalityObject

Returns the value of attribute municipality.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def municipality
  @municipality
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def name
  @name
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def number
  @number
end

#phoneObject

Returns the value of attribute phone.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def phone
  @phone
end

#rfcObject

Returns the value of attribute rfc.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def rfc
  @rfc
end

#stateObject

Returns the value of attribute state.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def state
  @state
end

#streetObject

Returns the value of attribute street.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def street
  @street
end

#totalObject

Returns the value of attribute total.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def total
  @total
end

#zipcodeObject

Returns the value of attribute zipcode.



4
5
6
# File 'lib/interfactura/ruby/invoice.rb', line 4

def zipcode
  @zipcode
end

Instance Method Details

#get_bindingObject



39
40
41
# File 'lib/interfactura/ruby/invoice.rb', line 39

def get_binding
  binding()
end

#ivaObject



30
31
32
# File 'lib/interfactura/ruby/invoice.rb', line 30

def iva
  (total - subtotal).round(2)
end

#subtotalObject



26
27
28
# File 'lib/interfactura/ruby/invoice.rb', line 26

def subtotal
  (total / 1.16).round(2)
end

#to_xmlObject



34
35
36
37
# File 'lib/interfactura/ruby/invoice.rb', line 34

def to_xml
  path = "#{File.dirname(__FILE__)}/templates/message_template.xml.erb"
  ERB.new(File.read(path), nil, '-').result(self.get_binding)
end