[#4183] Implemented Contract#total_spent
This commit is contained in:
@@ -38,7 +38,7 @@ class Contract < ActiveRecord::Base
|
||||
define_method(mthd) { "TODO in later release" }
|
||||
end
|
||||
|
||||
[:total_spent,
|
||||
[
|
||||
:profit_spent
|
||||
].each do |mthd|
|
||||
define_method(mthd) { "TODO" }
|
||||
@@ -81,6 +81,11 @@ class Contract < ActiveRecord::Base
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.total }
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def total_spent
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.total_spent }
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def profit_budget
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.profit_budget }
|
||||
|
||||
Reference in New Issue
Block a user