Class: Credit
Instance Method Summary collapse
Methods inherited from Entry
Instance Method Details
#conservation_principle ⇒ Object
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 |
#debit ⇒ Object
12 13 14 |
# File 'app/models/credit.rb', line 12 def debit transaction ? transaction.debit : nil end |
#require_debit ⇒ Object
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_convention ⇒ Object
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 |