Sha256: 484591e71e3c2364e6d0b4893b09e71c60b4e4f7a6fab351695f66812da067bb

Contents?: true

Size: 426 Bytes

Versions: 3

Compression:

Stored size: 426 Bytes

Contents

class WorkDay
  attr_accessor :date, :employment

  def initialize(date, employment)
    @date       = date
    @employment = employment
  end
  
  def hours_due
    case date.wday
      when 6, 0
        0.0
      else
        employment.daily_workload
    end
  end

  def hours_worked
    employment.employee.activities.where(:date => date).to_a.sum(&:duration)
  end

  def overtime
    hours_worked - hours_due
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bookyt_projects-0.11.2 app/models/work_day.rb
bookyt_projects-0.11.1 app/models/work_day.rb
bookyt_projects-0.11.0 app/models/work_day.rb