[#4420] Added OverheadBudget creation for Retainers.
This commit is contained in:
1 parent
fc28f8351f
commit
9a4b4f2b43
2 files changed
+24
-1
No files matched your search
@@ -51,9 +51,15 @@ class RetainerDeliverable < HourlyDeliverable
|
|||||||
undated_labor_budgets.each do |template_budget|
|
undated_labor_budgets.each do |template_budget|
|
||||||
labor_budgets.create(template_budget.attributes.merge(:year => month.year, :month => month.month))
|
labor_budgets.create(template_budget.attributes.merge(:year => month.year, :month => month.month))
|
||||||
end
|
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
|
end
|
||||||
# Destroy origional un-dated budgets
|
# Destroy origional un-dated budgets
|
||||||
labor_budgets.all(:conditions => ["#{LaborBudget.table_name}.year IS NULL AND #{LaborBudget.table_name}.month IS NULL"]).collect(&:destroy)
|
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
|
end
|
||||||
|
|
||||||
def self.frequencies_to_select
|
def self.frequencies_to_select
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
|||||||
@deliverable = RetainerDeliverable.generate!(:start_date => '2010-01-10',
|
@deliverable = RetainerDeliverable.generate!(:start_date => '2010-01-10',
|
||||||
:end_date => '2010-10-10')
|
:end_date => '2010-10-10')
|
||||||
LaborBudget.generate!(:deliverable => @deliverable)
|
LaborBudget.generate!(:deliverable => @deliverable)
|
||||||
|
OverheadBudget.generate!(:deliverable => @deliverable)
|
||||||
|
OverheadBudget.generate!(:deliverable => @deliverable)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a dated labor budget for each month" do
|
should "create a dated labor budget for each month" do
|
||||||
@@ -34,7 +36,22 @@ class RetainerDeliverableTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user