[#4570] Add an alert message about orphaned time on a project

This commit is contained in:
Eric Davis
2010-09-29 13:50:17 -07:00
parent 15d626b6d8
commit 39c04b9896
5 changed files with 81 additions and 6 deletions
+12
View File
@@ -124,6 +124,18 @@ class Contract < ActiveRecord::Base
end
end
def orphaned_time
cost_of_time_without_issue = project.time_entries.all(:conditions => {:issue_id => nil}).inject(0) do |total, time_entry|
total += time_entry.cost
end
cost_of_time_without_deliverable = project.issues.all(:include => 'time_entries', :conditions => {:deliverable_id => nil}).collect(&:time_entries).flatten.inject(0) do |total, time_entry|
total += time_entry.cost
end
cost_of_time_without_issue + cost_of_time_without_deliverable
end
def to_s
name
end