Class: ChargeRate

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/charge_rate.rb

Direct Known Subclasses

VatRate

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current(code, date = nil) ⇒ Object



22
23
24
25
# File 'app/models/charge_rate.rb', line 22

def self.current(code, date = nil)
  date ||= Date.today
  valid_at(date).find_by_code(code)
end

Instance Method Details

#to_s(format = :default) ⇒ Object

String



3
4
5
6
7
8
9
10
11
12
# File 'app/models/charge_rate.rb', line 3

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