Class: Aloe::Transaction
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Aloe::Transaction
- Defined in:
- lib/aloe/transaction.rb
Instance Method Summary collapse
-
#amount ⇒ Money
Returns the amount of transaction.
-
#details ⇒ Hash
Return transaction details hash.
-
#entries ⇒ Array<Aloe::Entry>
Return entries of transaction.
- #number ⇒ Object
-
#rollback ⇒ Object
Rollback transaction by creating balancing entries.
-
#type ⇒ Fixnum
Return the type of transaction.
Instance Method Details
#amount ⇒ Money
Returns the amount of transaction.
60 61 62 |
# File 'lib/aloe/transaction.rb', line 60 def amount credit_entry.amount.abs end |
#details ⇒ Hash
Return transaction details hash.
36 37 38 |
# File 'lib/aloe/transaction.rb', line 36 def details attributes["details"] ||= {} end |
#entries ⇒ Array<Aloe::Entry>
Return entries of transaction.
43 44 45 |
# File 'lib/aloe/transaction.rb', line 43 def entries [debit_entry, credit_entry] end |
#number ⇒ Object
69 70 71 |
# File 'lib/aloe/transaction.rb', line 69 def number uuid.first(8) end |
#rollback ⇒ Object
Rollback transaction by creating balancing entries.
65 66 67 |
# File 'lib/aloe/transaction.rb', line 65 def rollback Aloe::TransactionRollback.new(self).rollback! end |
#type ⇒ Fixnum
Return the type of transaction.
Type of transaction is stored in category
attribute internally because AR uses type
for STI.
53 54 55 |
# File 'lib/aloe/transaction.rb', line 53 def type category end |