2 # This file is part of SMR.
4 # SMR is free software: you can redistribute it and/or modify it under the
5 # terms of the GNU General Public License as published by the Free Software
6 # Foundation, either version 3 of the License, or (at your option) any later
9 # SMR is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # SMR. If not, see <http://www.gnu.org/licenses/>.
16 class Dividend < ActiveRecord::Base
17 include Smr::Extensions::DateTimeWrapper
19 belongs_to :Security, :foreign_key=>:id_security
20 has_many :Position, :foreign_key=>:id_security, :primary_key=>:id_security
21 has_one :Position, :foreign_key=>:id, :primary_key=>:id_position
22 has_one :Order, :foreign_key=>:id, :primary_key=>:id_order
25 validates :id_security, :date_exdate, :paid, :id_position, :id_order, presence: true
26 validates :id_security, :date_exdate, :paid, numericality: { greater_than_or_equal_to: 0 }
27 validates :id_position, :id_order, numericality: { greater_than_or_equal_to: 1 }