Sha256: d2f29d29b5bbfa9f976fe8a017312e6de385497bc759583972813cfdf7424730

Contents?: true

Size: 521 Bytes

Versions: 2

Compression:

Stored size: 521 Bytes

Contents

class WorkAccount < ActiveRecord::Base
  has_many :backlogs, :dependent => :nullify
  has_many :works, :dependent => :destroy

  validates_inclusion_of :track_times, :in => [true, false], :allow_nil => true, :message => ActiveRecord::Errors.default_error_messages[:blank]
  validates_length_of :invoice_code, :allow_nil => true, :maximum => 255

  def enable_invoicing?
    invoice_code && invoice_code.length > 0
  end

  def total_hours
    works.inject(BigDecimal('0')) {|total, work| total + work.hours}
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backlog-0.17.6 app/models/work_account.rb
backlog-0.18.0 app/models/work_account.rb