[#4183] Implemented Contract#overhead_budget

This commit is contained in:
Eric Davis
2010-07-07 15:21:23 -07:00
parent 4703583a50
commit e48045ab77
2 changed files with 19 additions and 2 deletions
+7 -2
View File
@@ -30,7 +30,7 @@ class Contract < ActiveRecord::Base
attr_accessible :details
[:status, :contract_type, :labor_spent, :overhead_spent,
:overhead_budget, :fixed_spent, :fixed_budget, :total_spent, :total_budget,
:fixed_spent, :fixed_budget, :total_spent, :total_budget,
:markup_spent, :markup_budget, :profit_spent, :profit_budget,
:discount_spent, :discount_budget, :client_point_of_contact,
:estimated_hour_spent, :estimated_hour_budget
@@ -42,7 +42,12 @@ class Contract < ActiveRecord::Base
def labor_budget
deliverables.inject(0) {|total, deliverable| total += deliverable.labor_budget_total }
end
# OPTIMIZE: N+1
def overhead_budget
deliverables.inject(0) {|total, deliverable| total += deliverable.overhead_budget_total }
end
PaymentTerms = {
:net_0 => :text_payment_terms_net_0,
:net_15 => :text_payment_terms_net_15,
+12
View File
@@ -44,4 +44,16 @@ class ContractTest < ActiveSupport::TestCase
assert_equal 200, contract.labor_budget
end
end
context "#overhead_budget" do
should "sum all of the overhead budgets of the Deliverables" do
contract = Contract.generate!
contract.deliverables << @deliverable_1 = FixedDeliverable.generate!
OverheadBudget.generate!(:deliverable => @deliverable_1, :budget => 100)
contract.deliverables << @deliverable_2 = FixedDeliverable.generate!
OverheadBudget.generate!(:deliverable => @deliverable_2, :budget => 100)
assert_equal 200, contract.overhead_budget
end
end
end