Completed deliverable.spent calculation. #1136
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -5,4 +5,8 @@ class FixedDeliverable < Deliverable
|
||||
def score
|
||||
0
|
||||
end
|
||||
|
||||
def spent
|
||||
(self.progress.to_f / 100 ) * self.budget
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user