class Interfactura::Ruby::Invoice

Constants

IVA

Attributes

city[RW]
colony[RW]
email[RW]
id[RW]
municipality[RW]
name[RW]
number[RW]
order_id[RW]
phone[RW]
rfc[RW]
state[RW]
street[RW]
total[RW]
zipcode[RW]

Public Class Methods

new(attributes = {}) click to toggle source
# 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]
  @order_id = attributes[:order_id]
end

Public Instance Methods

get_binding() click to toggle source
# File lib/interfactura/ruby/invoice.rb, line 40
def get_binding
  binding()
end
iva() click to toggle source
# File lib/interfactura/ruby/invoice.rb, line 31
def iva
  (total - subtotal).round(2)
end
subtotal() click to toggle source
# File lib/interfactura/ruby/invoice.rb, line 27
def subtotal
  (total / 1.16).round(2)
end
to_xml() click to toggle source
# File lib/interfactura/ruby/invoice.rb, line 35
def to_xml
  path = "#{File.dirname(__FILE__)}/templates/message_template.xml.erb"
  ERB.new(File.read(path), nil, '-').result(self.get_binding)
end