[#4183] Implemented HourlyDeliverable#total_spent.

This commit is contained in:
Eric Davis
2010-07-13 18:11:02 -07:00
parent 597062fdf8
commit cd3ba5e5e5
2 changed files with 36 additions and 0 deletions
+16
View File
@@ -21,6 +21,22 @@ class HourlyDeliverable < Deliverable
return contract.billable_rate * labor_budgets.sum(:hours)
end
# Total amount to be billed on the deliverable, using the total time logged
# and the contract rate
def total_spent
return 0 if contract.nil?
return 0 if contract.billable_rate.blank?
return 0 unless self.issues.count > 0
time_logs = self.issues.collect(&:time_entries).flatten
hours = time_logs.inject(0) {|total, time_entry|
total += time_entry.hours if time_entry.billable?
total
}
return hours * contract.billable_rate
end
# Block setting the total on HourlyDeliverables
def total=(v)