foodsoft/app/models/financial_transaction.rb

18 lines
561 B
Ruby
Raw Normal View History

2009-01-06 11:49:19 +01:00
# financial transactions are the foodcoop internal financial transactions
# only ordergroups have an account balance and are happy to transfer money
2009-01-06 11:49:19 +01:00
class FinancialTransaction < ActiveRecord::Base
belongs_to :ordergroup, :with_deleted => true
2009-01-06 11:49:19 +01:00
belongs_to :user
validates_presence_of :amount, :note, :user_id, :ordergroup_id
2009-01-06 11:49:19 +01:00
validates_numericality_of :amount
localize_input_of :amount
2009-01-06 11:49:19 +01:00
# Use this save method instead of simple save and after callback
def add_transaction!
ordergroup.add_financial_transaction! amount, note, user
end
2009-01-06 11:49:19 +01:00
end