[#4183] Implemented Contract#labor_budget

This commit is contained in:
Eric Davis
2010-07-07 15:19:46 -07:00
parent 3d4e71ff93
commit 4703583a50
2 changed files with 18 additions and 2 deletions
+6 -1
View File
@@ -29,7 +29,7 @@ class Contract < ActiveRecord::Base
attr_accessible :po_number
attr_accessible :details
[:status, :contract_type, :labor_spent, :labor_budget, :overhead_spent,
[:status, :contract_type, :labor_spent, :overhead_spent,
:overhead_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,
@@ -37,6 +37,11 @@ class Contract < ActiveRecord::Base
].each do |mthd|
define_method(mthd) { "TODO" }
end
# OPTIMIZE: N+1
def labor_budget
deliverables.inject(0) {|total, deliverable| total += deliverable.labor_budget_total }
end
PaymentTerms = {
:net_0 => :text_payment_terms_net_0,
+12 -1
View File
@@ -32,5 +32,16 @@ class ContractTest < ActiveSupport::TestCase
assert_equal false, @contract.executed
end
context "#labor_budget" do
should "sum all of the labor budgets of the Deliverables" do
contract = Contract.generate!
contract.deliverables << @deliverable_1 = FixedDeliverable.generate!
LaborBudget.generate!(:deliverable => @deliverable_1, :budget => 100)
contract.deliverables << @deliverable_2 = FixedDeliverable.generate!
LaborBudget.generate!(:deliverable => @deliverable_2, :budget => 100)
assert_equal 200, contract.labor_budget
end
end
end