Class: Aloe::Transaction

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/aloe/transaction.rb

Instance Method Summary collapse

Instance Method Details

#amountMoney

Returns the amount of transaction.

Returns:

  • (Money)


60
61
62
# File 'lib/aloe/transaction.rb', line 60

def amount
  credit_entry.amount.abs
end

#detailsHash

Return transaction details hash.

Returns:

  • (Hash)


36
37
38
# File 'lib/aloe/transaction.rb', line 36

def details
  attributes["details"] ||= {}
end

#entriesArray<Aloe::Entry>

Return entries of transaction.

Returns:



43
44
45
# File 'lib/aloe/transaction.rb', line 43

def entries
  [debit_entry, credit_entry]
end

#numberObject



69
70
71
# File 'lib/aloe/transaction.rb', line 69

def number
  uuid.first(8)
end

#rollbackObject

Rollback transaction by creating balancing entries.



65
66
67
# File 'lib/aloe/transaction.rb', line 65

def rollback
  Aloe::TransactionRollback.new(self).rollback!
end

#typeFixnum

Return the type of transaction.

Type of transaction is stored in category attribute internally because AR uses type for STI.

Returns:

  • (Fixnum)


53
54
55
# File 'lib/aloe/transaction.rb', line 53

def type
  category
end