Sha256: 0d426c35d001d19fb9a5b57034afeb58edc7a6649d19c8ceb047afa177496482
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
class ChargeRate < ActiveRecord::Base # String def to_s(format = :default) case format when :long from = duration_from.nil? ? "" : I18n::localize(duration_from) to = duration_to.nil? ? "" : I18n::localize(duration_to) "%s: %.2f (%s - %s)" % [title, rate, from, to] else "%s: %.2f" % [code, rate] end end # Sorting default_scope order('duration_from DESC') # Validity scope :valid_at, lambda {|value| where("duration_from <= :date AND (duration_to IS NULL OR duration_to > :date)", :date => value) } scope :valid, lambda { valid_at(Date.today) } scope :latest, group(:code, :person_id) def self.current(code, date = nil) date ||= Date.today valid_at(date).find_by_code(code) end # Person belongs_to :person scope :by_person, lambda {|value| value ? where(:person_id => value) : scoped} end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bookyt-0.0.1 | app/models/charge_rate.rb |