[#4551] Change the Budget conversion to convert materials as FixedBudget items

This commit is contained in:
Eric Davis
2010-09-22 12:27:52 -07:00
parent c6d43d9149
commit 0ef87e7b9c
2 changed files with 20 additions and 25 deletions
@@ -140,15 +140,15 @@ module RedmineContracts
total ||= 0
if old_deliverable['materials'].present? && old_deliverable['materials'] > 0.0
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
:budget => old_deliverable['materials'],
:hours => 0)
deliverable.fixed_budgets << FixedBudget.new(:deliverable => deliverable,
:budget => old_deliverable['materials'],
:markup => 0)
elsif old_deliverable['materials_percent'].present? && old_deliverable['materials_percent'] > 0.0
materials = total * (old_deliverable['materials_percent'].to_f / 100)
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
:budget => materials,
:hours => 0)
deliverable.fixed_budgets << FixedBudget.new(:deliverable => deliverable,
:budget => materials,
:markup => 0)
end
end
@@ -85,13 +85,13 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
end
should "create a new Overhead Budget record for any overhead" do
assert_difference("OverheadBudget.count", 5) do
assert_difference("OverheadBudget.count", 3) do
RedmineContracts::BudgetPluginMigration.migrate(@data)
end
d = Deliverable.find_by_title("Deliverable One")
assert_equal 2, d.overhead_budgets.count
assert_equal 400, d.overhead_budget_total
assert_equal 1, d.overhead_budgets.count
assert_equal 200, d.overhead_budget_total
overhead = d.overhead_budgets.first
assert overhead
@@ -100,12 +100,12 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
end
should "create a new Overhead Budget record for any overhead percent" do
assert_difference("OverheadBudget.count", 5) do
assert_difference("OverheadBudget.count", 3) do
RedmineContracts::BudgetPluginMigration.migrate(@data)
end
d = Deliverable.find_by_title("Deliverable 2")
assert_equal 2, d.overhead_budgets.count
assert_equal 1, d.overhead_budgets.count
overhead = d.overhead_budgets.first
assert overhead
@@ -114,32 +114,27 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
end
should "create a new Overhead Budget record for any materials" do
assert_difference("OverheadBudget.count", 5) do
should "create a new Fixed Budget record for any materials" do
assert_difference("FixedBudget.count", 2) do
RedmineContracts::BudgetPluginMigration.migrate(@data)
end
d = Deliverable.find_by_title("Deliverable One")
assert_equal 2, d.overhead_budgets.count
assert_equal 400, d.overhead_budget_total
materials = d.overhead_budgets.last
assert materials
assert_equal 200, materials.budget
assert_equal 0, materials.hours
assert_equal 1, d.fixed_budgets.count
assert_equal 200, d.fixed_budget_total
end
should "create a new Overhead Budget record for any materials percent" do
assert_difference("OverheadBudget.count", 5) do
should "create a new Fixed Budget record for any materials percent" do
assert_difference("FixedBudget.count", 2) do
RedmineContracts::BudgetPluginMigration.migrate(@data)
end
d = Deliverable.find_by_title("Deliverable 2")
assert_equal 2, d.overhead_budgets.count
materials = d.overhead_budgets.last
assert_equal 1, d.fixed_budgets.count
materials = d.fixed_budgets.first
assert materials
assert_equal 12 * 25 * 0.1, materials.budget
assert_equal 0, materials.hours
assert_equal 0, materials.markup.to_i
end