class Aloe::Transaction

Public Instance Methods

amount() click to toggle source

Returns the amount of transaction.

@return [Money]

# File lib/aloe/transaction.rb, line 60
def amount
  credit_entry.amount.abs
end
details() click to toggle source

Return transaction details hash.

@return [Hash]

# File lib/aloe/transaction.rb, line 36
def details
  attributes["details"] ||= {}
end
entries() click to toggle source

Return entries of transaction.

@return [Array<Aloe::Entry>]

# File lib/aloe/transaction.rb, line 43
def entries
  [debit_entry, credit_entry]
end
number() click to toggle source
# File lib/aloe/transaction.rb, line 69
def number
  uuid.first(8)
end
rollback() click to toggle source

Rollback transaction by creating balancing entries.

# File lib/aloe/transaction.rb, line 65
def rollback
  Aloe::TransactionRollback.new(self).rollback!
end
type() click to toggle source

Return the type of transaction.

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

@return [Fixnum]

# File lib/aloe/transaction.rb, line 53
def type
  category
end

Protected Instance Methods

assign_uuid() click to toggle source
# File lib/aloe/transaction.rb, line 75
def assign_uuid
  write_attribute :uuid, UUID.new.generate(:compact)
end