[#6636] Add Deliverable#spent_for_user to get the billable/non-billable cost by user

This commit is contained in:
Eric Davis
2011-10-13 11:07:31 -07:00
parent 19ec0f6c43
commit f972efffbf
2 changed files with 45 additions and 0 deletions
+6
View File
@@ -337,6 +337,12 @@ class Deliverable < ActiveRecord::Base
end
end
def spent_for_user(user, billable_time_only)
time_entries = project.time_entries.all(:conditions => ["#{TimeEntry.table_name}.issue_id IN (?) AND #{TimeEntry.table_name}.user_id IN (?)", issue_ids, user.id])
time_entries.select {|time| time.billable? == billable_time_only }.sum(&:cost)
end
def hours_spent_for_user(user, billable_time_only)
time_entries = project.time_entries.all(:conditions => ["#{TimeEntry.table_name}.issue_id IN (?) AND #{TimeEntry.table_name}.user_id IN (?)", issue_ids, user.id])