[#4420] Added OverheadBudget creation for Retainers.
This commit is contained in:
@@ -51,9 +51,15 @@ class RetainerDeliverable < HourlyDeliverable
|
||||
undated_labor_budgets.each do |template_budget|
|
||||
labor_budgets.create(template_budget.attributes.merge(:year => month.year, :month => month.month))
|
||||
end
|
||||
|
||||
undated_overhead_budgets = overhead_budgets.all(:conditions => ["#{OverheadBudget.table_name}.year IS NULL AND #{OverheadBudget.table_name}.month IS NULL"])
|
||||
undated_overhead_budgets.each do |template_budget|
|
||||
overhead_budgets.create(template_budget.attributes.merge(:year => month.year, :month => month.month))
|
||||
end
|
||||
end
|
||||
# Destroy origional un-dated budgets
|
||||
labor_budgets.all(:conditions => ["#{LaborBudget.table_name}.year IS NULL AND #{LaborBudget.table_name}.month IS NULL"]).collect(&:destroy)
|
||||
overhead_budgets.all(:conditions => ["#{OverheadBudget.table_name}.year IS NULL AND #{OverheadBudget.table_name}.month IS NULL"]).collect(&:destroy)
|
||||
end
|
||||
|
||||
def self.frequencies_to_select
|
||||
|
||||
@@ -15,6 +15,8 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
||||
@deliverable = RetainerDeliverable.generate!(:start_date => '2010-01-10',
|
||||
:end_date => '2010-10-10')
|
||||
LaborBudget.generate!(:deliverable => @deliverable)
|
||||
OverheadBudget.generate!(:deliverable => @deliverable)
|
||||
OverheadBudget.generate!(:deliverable => @deliverable)
|
||||
end
|
||||
|
||||
should "create a dated labor budget for each month" do
|
||||
@@ -34,7 +36,22 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
||||
|
||||
end
|
||||
|
||||
should "create a dated overhead budget for each month"
|
||||
should "create a dated overhead budget for each month" do
|
||||
assert_equal 2, @deliverable.overhead_budgets.count
|
||||
|
||||
@deliverable.reload.create_budgets_for_periods
|
||||
|
||||
assert_equal 20, @deliverable.overhead_budgets.count
|
||||
overhead_budgets = @deliverable.overhead_budgets
|
||||
overhead_budgets.each do |budget|
|
||||
assert_equal 2010, budget.year
|
||||
end
|
||||
|
||||
(1..10).each do |month_number|
|
||||
assert_equal 2, overhead_budgets.select {|b| b.month == month_number}.length
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user