53bb096046
For now this is only usefull for plugins, since there is no UI.
18 lines
612 B
Ruby
18 lines
612 B
Ruby
# financial transactions are the foodcoop internal financial transactions
|
|
# only ordergroups have an account balance and are happy to transfer money
|
|
class FinancialTransaction < ActiveRecord::Base
|
|
belongs_to :ordergroup
|
|
belongs_to :user
|
|
belongs_to :financial_link
|
|
|
|
validates_presence_of :amount, :note, :user_id, :ordergroup_id
|
|
validates_numericality_of :amount, greater_then: -100_000,
|
|
less_than: 100_000
|
|
|
|
localize_input_of :amount
|
|
|
|
# Use this save method instead of simple save and after callback
|
|
def add_transaction!
|
|
ordergroup.add_financial_transaction! amount, note, user
|
|
end
|
|
end
|