Class: GnuCash::Invoice::Entry

Inherits:
Object
  • Object
show all
Includes:
Timestamps
Defined in:
lib/gnucash/invoice/entry.rb

Constant Summary

Constants included from Timestamps

Timestamps::FORMAT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Timestamps

#from_timestamp

Constructor Details

#initialize(data) ⇒ Entry

Returns a new instance of Entry.



10
11
12
13
14
15
16
17
18
# File 'lib/gnucash/invoice/entry.rb', line 10

def initialize data
  @raw          = data

  @date         = from_timestamp(data[:date]).to_date
  @description  = data[:description]
  @action       = data[:action]
  @quantity     = data[:quantity_num].to_f / data[:quantity_denom]
  @price        = data[:i_price_num].to_f / data[:i_price_denom]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/gnucash/invoice/entry.rb', line 7

def action
  @action
end

#dateObject (readonly)

Returns the value of attribute date.



7
8
9
# File 'lib/gnucash/invoice/entry.rb', line 7

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/gnucash/invoice/entry.rb', line 7

def description
  @description
end

#priceObject (readonly)

Returns the value of attribute price.



7
8
9
# File 'lib/gnucash/invoice/entry.rb', line 7

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



7
8
9
# File 'lib/gnucash/invoice/entry.rb', line 7

def quantity
  @quantity
end

#rawObject (readonly)

Returns the value of attribute raw.



7
8
9
# File 'lib/gnucash/invoice/entry.rb', line 7

def raw
  @raw
end

Class Method Details

.find(invoice_guid) ⇒ Object



26
27
28
# File 'lib/gnucash/invoice/entry.rb', line 26

def self.find invoice_guid
  dataset.where(:invoice => invoice_guid).map{ |data| new(data) }
end

Instance Method Details

#totalObject



21
22
23
# File 'lib/gnucash/invoice/entry.rb', line 21

def total
  price * quantity
end