Refactor: extract method
This commit is contained in:
1 parent
d778201eff
commit
7bc31d6be0
2 files changed
+11
-8
No files matched your search
@@ -32,10 +32,7 @@ class HourlyDeliverable < Deliverable
|
|||||||
return 0 unless self.issues.count > 0
|
return 0 unless self.issues.count > 0
|
||||||
|
|
||||||
time_logs = self.issues.collect(&:time_entries).flatten
|
time_logs = self.issues.collect(&:time_entries).flatten
|
||||||
hours = time_logs.inject(0) {|total, time_entry|
|
hours = billable_hours_on_time_entries(time_logs)
|
||||||
total += time_entry.hours if time_entry.billable?
|
|
||||||
total
|
|
||||||
}
|
|
||||||
|
|
||||||
fixed_budget_amount = fixed_budget_total_spent(date) + fixed_markup_budget_total_spent(date)
|
fixed_budget_amount = fixed_budget_total_spent(date) + fixed_markup_budget_total_spent(date)
|
||||||
return (hours * contract.billable_rate) + fixed_budget_amount
|
return (hours * contract.billable_rate) + fixed_budget_amount
|
||||||
@@ -49,4 +46,13 @@ class HourlyDeliverable < Deliverable
|
|||||||
def clear_total
|
def clear_total
|
||||||
write_attribute(:total, nil)
|
write_attribute(:total, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def billable_hours_on_time_entries(time_entries)
|
||||||
|
time_entries.inject(0) {|total, time_entry|
|
||||||
|
total += time_entry.hours if time_entry.billable?
|
||||||
|
total
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -193,10 +193,7 @@ class RetainerDeliverable < HourlyDeliverable
|
|||||||
issue_ids = self.issues.collect(&:id)
|
issue_ids = self.issues.collect(&:id)
|
||||||
time_logs = time_entries_for_date_and_issue_ids(date, issue_ids)
|
time_logs = time_entries_for_date_and_issue_ids(date, issue_ids)
|
||||||
|
|
||||||
hours = time_logs.inject(0) {|total, time_entry|
|
hours = billable_hours_on_time_entries(time_logs)
|
||||||
total += time_entry.hours if time_entry.billable?
|
|
||||||
total
|
|
||||||
}
|
|
||||||
|
|
||||||
fixed_budget_amount = fixed_budget_total_spent(date) + fixed_markup_budget_total_spent(date)
|
fixed_budget_amount = fixed_budget_total_spent(date) + fixed_markup_budget_total_spent(date)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user