2009-01-08 16:33:27 +01:00
|
|
|
# == Schema Information
|
|
|
|
# Schema version: 20090102171850
|
|
|
|
#
|
|
|
|
# Table name: financial_transactions
|
|
|
|
#
|
|
|
|
# id :integer(4) not null, primary key
|
|
|
|
# order_group_id :integer(4) default(0), not null
|
|
|
|
# amount :decimal(8, 2) default(0.0), not null
|
|
|
|
# note :text default(""), not null
|
|
|
|
# user_id :integer(4) default(0), not null
|
|
|
|
# created_on :datetime not null
|
|
|
|
#
|
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# financial transactions are the foodcoop internal financial transactions
|
|
|
|
# only order_groups have an account balance and are happy to transfer money
|
|
|
|
class FinancialTransaction < ActiveRecord::Base
|
|
|
|
belongs_to :order_group
|
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
validates_presence_of :note, :user_id, :order_group_id
|
|
|
|
validates_numericality_of :amount
|
2009-01-10 21:28:22 +01:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
|
|
|
def amount=(amount)
|
2009-01-06 15:45:19 +01:00
|
|
|
self[:amount] = String.delocalized_decimal(amount)
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|