[#4183] Implemented Contract#estimated_hour_spent and Deliverable#hours_spent_total.
This commit is contained in:
1 parent
af99dc4042
commit
b24ab65792
3 files changed
+31
-2
No files matched your search
@@ -41,8 +41,7 @@ class Contract < ActiveRecord::Base
|
||||
[:labor_spent,
|
||||
:overhead_spent,
|
||||
:total_spent,
|
||||
:profit_spent,
|
||||
:estimated_hour_spent
|
||||
:profit_spent
|
||||
].each do |mthd|
|
||||
define_method(mthd) { "TODO" }
|
||||
end
|
||||
@@ -62,6 +61,11 @@ class Contract < ActiveRecord::Base
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.estimated_hour_budget_total }
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def estimated_hour_spent
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.hours_spent_total }
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def total_budget
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.total }
|
||||
|
||||
@@ -48,6 +48,11 @@ class Deliverable < ActiveRecord::Base
|
||||
(overhead_budgets.sum(:hours) || 0.0)
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def hours_spent_total
|
||||
issues.inject(0) {|total, issue| total += issue.spent_hours }
|
||||
end
|
||||
|
||||
if Rails.env.test?
|
||||
generator_for :title, :method => :next_title
|
||||
|
||||
|
||||
Reference in new issue
Block a user