Class: Credit

Inherits:
Entry
  • Object
show all
Defined in:
app/models/credit.rb

Instance Method Summary collapse

Methods inherited from Entry

#readonly?

Instance Method Details

#conservation_principleObject



20
21
22
23
# File 'app/models/credit.rb', line 20

def conservation_principle
  errors.add(:base, "Credit and debit amounts must add up to zero") unless
    (debit.nil? or amount + debit.amount == 0)
end

#debitObject



12
13
14
# File 'app/models/credit.rb', line 12

def debit
  transaction ? transaction.debit : nil
end

#require_debitObject



16
17
18
# File 'app/models/credit.rb', line 16

def require_debit
  errors.add(:base, "Debit must be saved before credit") unless !debit.nil?
end

#sign_conventionObject



8
9
10
# File 'app/models/credit.rb', line 8

def sign_convention
  errors.add(:amount, "Credit must be non-negative") unless amount >= 0
end