Class: Project

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

Instance Method Summary collapse

Instance Method Details

#active_tasksObject



18
19
20
# File 'app/models/project.rb', line 18

def active_tasks
  tasks.find(:all, :conditions => "finished_at IS NULL", :order => "position")
end

#enable_invoicing?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/project.rb', line 37

def enable_invoicing?
  true
end

#first_active_periodObject



30
31
32
33
34
35
# File 'app/models/project.rb', line 30

def first_active_period
  t = active_tasks
  periods = t.map {|t| t.period}.compact.uniq
  periods = periods.select {|p| p.active?}
  periods.sort_by {|p| p.end_on}.first
end

#recent_tasksObject



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

def recent_tasks
  Task.find(:all, :conditions => "period_id = #{periods.first.id} AND (position IS NOT NULL OR finished_at >= '#{1.week.ago.iso8601}')", :order => "position, finished_at")
end

#tasks_with_childrenObject



26
27
28
# File 'app/models/project.rb', line 26

def tasks_with_children
  tasks.map {|t| t.self_with_children}.flatten
end

#total_hoursObject



45
46
47
# File 'app/models/project.rb', line 45

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

#track_done?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/project.rb', line 41

def track_done?
  true
end