Class: Project
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Project
- Defined in:
- app/models/project.rb
Instance Method Summary collapse
- #active_tasks ⇒ Object
- #enable_invoicing? ⇒ Boolean
- #first_active_period ⇒ Object
- #recent_tasks ⇒ Object
- #tasks_with_children ⇒ Object
- #total_hours ⇒ Object
- #track_done? ⇒ Boolean
Instance Method Details
#active_tasks ⇒ Object
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
37 38 39 |
# File 'app/models/project.rb', line 37 def enable_invoicing? true end |
#first_active_period ⇒ Object
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_tasks ⇒ Object
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_children ⇒ Object
26 27 28 |
# File 'app/models/project.rb', line 26 def tasks_with_children tasks.map {|t| t.self_with_children}.flatten end |
#total_hours ⇒ Object
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
41 42 43 |
# File 'app/models/project.rb', line 41 def track_done? true end |