Class: Harvestime::Invoice
- Inherits:
-
Object
- Object
- Harvestime::Invoice
- Defined in:
- lib/harvestime/invoice.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_key ⇒ Object
Returns the value of attribute client_key.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#currency_type ⇒ Object
Returns the value of attribute currency_type.
-
#discount_amount ⇒ Object
Returns the value of attribute discount_amount.
-
#due_amount ⇒ Object
Returns the value of attribute due_amount.
-
#due_date ⇒ Object
Returns the value of attribute due_date.
-
#estimate_id ⇒ Object
Returns the value of attribute estimate_id.
-
#human_due_date ⇒ Object
Returns the value of attribute human_due_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#number ⇒ Object
Returns the value of attribute number.
-
#period_end ⇒ Object
Returns the value of attribute period_end.
-
#period_start ⇒ Object
Returns the value of attribute period_start.
-
#purchase_order ⇒ Object
Returns the value of attribute purchase_order.
-
#recurring_invoice_id ⇒ Object
Returns the value of attribute recurring_invoice_id.
-
#retainer_invoice_id ⇒ Object
Returns the value of attribute retainer_invoice_id.
-
#state ⇒ Object
Returns the value of attribute state.
-
#tax_1 ⇒ Object
Returns the value of attribute tax_1.
-
#tax_1_amount ⇒ Object
Returns the value of attribute tax_1_amount.
-
#tax_2 ⇒ Object
Returns the value of attribute tax_2.
-
#tax_2_amount ⇒ Object
Returns the value of attribute tax_2_amount.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def amount @amount end |
#client_id ⇒ Object
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def client_id @client_id end |
#client_key ⇒ Object
Returns the value of attribute client_key.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def client_key @client_key end |
#created_at ⇒ Object
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def created_at @created_at end |
#created_by ⇒ Object
Returns the value of attribute created_by.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def created_by @created_by end |
#currency_type ⇒ Object
Returns the value of attribute currency_type.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def currency_type @currency_type end |
#discount_amount ⇒ Object
Returns the value of attribute discount_amount.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def discount_amount @discount_amount end |
#due_amount ⇒ Object
Returns the value of attribute due_amount.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def due_amount @due_amount end |
#due_date ⇒ Object
Returns the value of attribute due_date.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def due_date @due_date end |
#estimate_id ⇒ Object
Returns the value of attribute estimate_id.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def estimate_id @estimate_id end |
#human_due_date ⇒ Object
Returns the value of attribute human_due_date.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def human_due_date @human_due_date end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def id @id end |
#notes ⇒ Object
Returns the value of attribute notes.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def notes @notes end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def number @number end |
#period_end ⇒ Object
Returns the value of attribute period_end.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def period_end @period_end end |
#period_start ⇒ Object
Returns the value of attribute period_start.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def period_start @period_start end |
#purchase_order ⇒ Object
Returns the value of attribute purchase_order.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def purchase_order @purchase_order end |
#recurring_invoice_id ⇒ Object
Returns the value of attribute recurring_invoice_id.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def recurring_invoice_id @recurring_invoice_id end |
#retainer_invoice_id ⇒ Object
Returns the value of attribute retainer_invoice_id.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def retainer_invoice_id @retainer_invoice_id end |
#state ⇒ Object
Returns the value of attribute state.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def state @state end |
#tax_1 ⇒ Object
Returns the value of attribute tax_1.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def tax_1 @tax_1 end |
#tax_1_amount ⇒ Object
Returns the value of attribute tax_1_amount.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def tax_1_amount @tax_1_amount end |
#tax_2 ⇒ Object
Returns the value of attribute tax_2.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def tax_2 @tax_2 end |
#tax_2_amount ⇒ Object
Returns the value of attribute tax_2_amount.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def tax_2_amount @tax_2_amount end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
6 7 8 |
# File 'lib/harvestime/invoice.rb', line 6 def updated_at @updated_at end |
Instance Method Details
#instantiate_values ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/harvestime/invoice.rb', line 21 def instantiate_values @id = @invoice.xpath('//id').text.to_i @amount = @invoice.xpath('//amount').text.to_f @due_amount = @invoice.xpath('//due-amount').text.to_f @due_date = parse_date(@invoice.xpath('//due-at').text) @human_due_date = @invoice.xpath('//due-at-human-format').text @period_end = parse_date(@invoice.xpath('//period-end').text) @period_start = parse_date(@invoice.xpath('//period-start').text) @client_id = @invoice.xpath('//client-id').text.to_i @currency_type = @invoice.xpath('//currency').text @number = @invoice.xpath('//number').text.to_i @purchase_order = @invoice.xpath('//purchase-order').text @client_key = @invoice.xpath('//client-key').text @state = @invoice.xpath('//state').text @tax_1 = @invoice.xpath('//tax').text.to_f @tax_2 = @invoice.xpath('//tax2').text.to_f @tax_1_amount = @invoice.xpath('//tax-amount').text.to_f @tax_2_amount = @invoice.xpath('//tax-amount2').text.to_f @discount_amount = @invoice.xpath('//discount-amount').text.to_f @discount = @invoice.xpath('//discount').text.to_f @recurring_invoice_id = @invoice.xpath('//recurring-invoice-id').text.to_i @retainer_invoice_id = @invoice.xpath('//retainer-id').text.to_i @updated_at = parse_date(@invoice.xpath('//updated-at').text) @created_at = parse_date(@invoice.xpath('//created-at').text) @created_by = @invoice.xpath('//created-by-id').text.to_i @notes = @invoice.xpath('//notes').text @estimate_id = @invoice.xpath('//estimate-id').text.to_i end |
#parse_date(string) ⇒ Object
50 51 52 53 54 |
# File 'lib/harvestime/invoice.rb', line 50 def parse_date(string) Date.parse(string) rescue Time.new("").to_date end |
#retrieve(path) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/harvestime/invoice.rb', line 14 def retrieve(path) file = File.open(path.to_s) @invoice = Nokogiri::XML(file) instantiate_values return :success end |