[#4183] Implemented Contract#estimated_hour_budget

This commit is contained in:
Eric Davis
2010-07-07 15:25:21 -07:00
parent e48045ab77
commit 26aac777e4
3 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -33,7 +33,7 @@ class Contract < ActiveRecord::Base
: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
:estimated_hour_spent
].each do |mthd|
define_method(mthd) { "TODO" }
end
@@ -48,6 +48,10 @@ class Contract < ActiveRecord::Base
deliverables.inject(0) {|total, deliverable| total += deliverable.overhead_budget_total }
end
def estimated_hour_budget
deliverables.inject(0) {|total, deliverable| total += deliverable.estimated_hour_budget_total }
end
PaymentTerms = {
:net_0 => :text_payment_terms_net_0,
:net_15 => :text_payment_terms_net_15,
+6
View File
@@ -42,6 +42,12 @@ class Deliverable < ActiveRecord::Base
overhead_budgets.sum(:budget)
end
# Total number of hours estimated in the Deliverable's budgets
def estimated_hour_budget_total
(labor_budgets.sum(:hours) || 0.0) +
(overhead_budgets.sum(:hours) || 0.0)
end
if Rails.env.test?
generator_for :title, :method => :next_title
+12
View File
@@ -56,4 +56,16 @@ class ContractTest < ActiveSupport::TestCase
assert_equal 200, contract.overhead_budget
end
end
context "#estimated_hour_budget" do
should "sum all of the labor and overhead budgets of the Deliverables" do
contract = Contract.generate!
contract.deliverables << @deliverable_1 = FixedDeliverable.generate!
LaborBudget.generate!(:deliverable => @deliverable_1, :hours => 50)
contract.deliverables << @deliverable_2 = HourlyDeliverable.generate!
OverheadBudget.generate!(:deliverable => @deliverable_2, :hours => 60)
assert_equal 110, contract.estimated_hour_budget
end
end
end