2009-01-08 16:33:27 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: financial_transactions
|
|
|
|
#
|
2009-02-02 16:35:43 +01:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# ordergroup_id :integer default(0), not null
|
2009-01-14 12:46:01 +01:00
|
|
|
# amount :decimal(8, 2) default(0.0), not null
|
2009-02-02 16:35:43 +01:00
|
|
|
# note :text not null
|
|
|
|
# user_id :integer default(0), not null
|
2009-01-14 12:46:01 +01:00
|
|
|
# created_on :datetime not null
|
2009-01-08 16:33:27 +01:00
|
|
|
#
|
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# financial transactions are the foodcoop internal financial transactions
|
2009-01-14 12:46:01 +01:00
|
|
|
# only ordergroups have an account balance and are happy to transfer money
|
2009-01-06 11:49:19 +01:00
|
|
|
class FinancialTransaction < ActiveRecord::Base
|
2009-01-14 12:46:01 +01:00
|
|
|
belongs_to :ordergroup
|
2009-01-06 11:49:19 +01:00
|
|
|
belongs_to :user
|
|
|
|
|
2009-01-14 12:46:01 +01:00
|
|
|
validates_presence_of :note, :user_id, :ordergroup_id
|
2009-01-06 11:49:19 +01:00
|
|
|
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
|