class Economic::Invoice
Public Instance Methods
attention()
click to toggle source
# File lib/economic/invoice.rb, line 23 def attention return nil if attention_handle.nil? @attention ||= session.contacts.find(attention_handle) end
attention=(contact)
click to toggle source
# File lib/economic/invoice.rb, line 28 def attention=(contact) self.attention_handle = contact.handle @attention = contact end
attention_handle=(handle)
click to toggle source
# File lib/economic/invoice.rb, line 33 def attention_handle=(handle) @attention = nil unless handle == @attention_handle @attention_handle = handle end
days_past_due()
click to toggle source
# File lib/economic/invoice.rb, line 57 def days_past_due days = Date.today - due_date.to_date days > 0 ? days : 0 end
debtor()
click to toggle source
# File lib/economic/invoice.rb, line 38 def debtor return nil if debtor_handle.nil? @debtor ||= session.debtors.find(debtor_handle) end
debtor=(debtor)
click to toggle source
# File lib/economic/invoice.rb, line 43 def debtor=(debtor) self.debtor_handle = debtor.handle @debtor = debtor end
debtor_handle=(handle)
click to toggle source
# File lib/economic/invoice.rb, line 48 def debtor_handle=(handle) @debtor = nil unless handle == @debtor_handle @debtor_handle = handle end
past_due?()
click to toggle source
Returns true if the due date has expired, and there is a remainder left on the invoice
# File lib/economic/invoice.rb, line 64 def past_due? days_past_due > 0 && remainder > 0 end
pdf()
click to toggle source
Returns the PDF version of Invoice
as a String.
To get it as a file you can do:
File.open("invoice.pdf", 'wb') do |file| file << invoice.pdf end
# File lib/economic/invoice.rb, line 75 def pdf response = request(:get_pdf, "invoiceHandle" => handle.to_hash) Base64.decode64(response) end
remainder()
click to toggle source
# File lib/economic/invoice.rb, line 53 def remainder @remainder ||= request(:get_remainder, "invoiceHandle" => handle.to_hash).to_f end