Completed deliverable.spent calculation. #1136

This commit is contained in:
Eric Davis
2008-05-28 12:55:02 -07:00
parent 9df51da8f8
commit 65da8e7594
6 changed files with 64 additions and 1 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ class Deliverable < ActiveRecord::Base
# TODO: mocked
def spent
0
0
end
# TODO LATER: Shouldn't require the default_done_ratio patch
+4
View File
@@ -5,4 +5,8 @@ class FixedDeliverable < Deliverable
def score
0
end
def spent
(self.progress.to_f / 100 ) * self.budget
end
end
+17
View File
@@ -1,3 +1,20 @@
class HourlyDeliverable < Deliverable
unloadable
def spent
return 0 unless self.issues.size > 0
total = 0.0
# Get all timelogs assigned
time_logs = self.issues.collect(&:time_entries).flatten
# Find each Member for their rate
time_logs.each do |time_log|
member = Member.find_by_user_id_and_project_id(time_log.user_id, time_log.project_id)
total += (member.rate * time_log.hours) unless member.nil? || member.rate.nil?
end
return total
end
end