Class: Transaction

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/transaction.rb

Direct Known Subclasses

InvoicePayment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#account_fromObject

Returns the value of attribute account_from.



11
12
13
# File 'app/models/transaction.rb', line 11

def 
  @account_from
end

#account_toObject

Returns the value of attribute account_to.



11
12
13
# File 'app/models/transaction.rb', line 11

def 
  @account_to
end

#amountObject

Returns the value of attribute amount.



11
12
13
# File 'app/models/transaction.rb', line 11

def amount
  @amount
end

Class Method Details

.belongs_to_auxilliary_model(model) ⇒ Object



13
14
15
16
# File 'app/models/transaction.rb', line 13

def self.belongs_to_auxilliary_model(model)
  klass = model.to_s.classify
  belongs_to klass.underscore.to_sym, :foreign_key => :auxilliary_model_id
end

.required_auxilliary_model(model) ⇒ Object



18
19
20
21
# File 'app/models/transaction.rb', line 18

def self.required_auxilliary_model(model)
  belongs_to_auxilliary_model(model)
  validates_presence_of model.to_s.classify.underscore.to_sym
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/transaction.rb', line 23

def completed?
  !debit.nil? and !credit.nil?
end

#readonly?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/transaction.rb', line 43

def readonly?
  !new_record?
end

#transaction_dateObject



39
40
41
# File 'app/models/transaction.rb', line 39

def transaction_date
  super or created_at
end