Class: GnuCash::Invoice::Entry
- Inherits:
-
Object
- Object
- GnuCash::Invoice::Entry
- Includes:
- Timestamps
- Defined in:
- lib/gnucash/invoice/entry.rb
Constant Summary
Constants included from Timestamps
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Entry
constructor
A new instance of Entry.
- #total ⇒ Object
Methods included from Timestamps
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 = (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
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/gnucash/invoice/entry.rb', line 7 def action @action end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
7 8 9 |
# File 'lib/gnucash/invoice/entry.rb', line 7 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/gnucash/invoice/entry.rb', line 7 def description @description end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
7 8 9 |
# File 'lib/gnucash/invoice/entry.rb', line 7 def price @price end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
7 8 9 |
# File 'lib/gnucash/invoice/entry.rb', line 7 def quantity @quantity end |
#raw ⇒ Object (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
#total ⇒ Object
21 22 23 |
# File 'lib/gnucash/invoice/entry.rb', line 21 def total price * quantity end |