Removed all the duplicate methods that were getting the rate for each TimeEntry

and replaced them with a simple collector that uses the new TimeEntry#cost
method (that wraps the Rate API).

  #1924
This commit is contained in:
Eric Davis committed 2009-01-21 15:20:21 -08:00
1 parent 7fa4f33748
commit 3d8c1ecc5c
6 files changed
+9 -42

No files matched your search

+2 -8
View File
@@ -25,15 +25,9 @@ class MemberSpent
project.members.each do |member|
member_time_entries = time_entries.select { |tl| tl.user_id == member.user.id}
spent = 0.0
hours = 0.0
spent = member_time_entries.collect(&:cost).inject { |sum, n| sum + n}
hours = member_time_entries.collect(&:hours).inject { |sum, n| sum + n}
member_time_entries.each do |time_entry|
rate = Rate.amount_for(time_entry.user, time_entry.project, time_entry.spent_on.to_s)
spent += time_entry.hours.to_f * rate unless rate.nil?
hours += time_entry.hours
end
membership << MemberSpent.new({
:user => member.user,
:hours => hours,