[#4477] Added the amounts spent for FixedBudgets
This commit is contained in:
+11
-3
@@ -36,8 +36,6 @@ class Contract < ActiveRecord::Base
|
||||
named_scope :by_name, {:order => "#{Contract.table_name}.name ASC"}
|
||||
|
||||
[:status, :contract_type,
|
||||
:fixed_spent,
|
||||
:fixed_markup_spent,
|
||||
:discount_spent, :discount_budget
|
||||
].each do |mthd|
|
||||
define_method(mthd) { "TODO in later release" }
|
||||
@@ -100,12 +98,22 @@ class Contract < ActiveRecord::Base
|
||||
def fixed_budget
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.fixed_budget_total }
|
||||
end
|
||||
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def fixed_spent
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.fixed_budget_total_spent }
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def fixed_markup_budget
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.fixed_markup_budget_total }
|
||||
end
|
||||
|
||||
# OPTIMIZE: N+1
|
||||
def fixed_markup_spent
|
||||
deliverables.inject(0) {|total, deliverable| total += deliverable.fixed_markup_budget_total_spent }
|
||||
end
|
||||
|
||||
def after_initialize
|
||||
self.executed = false unless self.executed.present?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user