[#4184] Convert materials and materials % to OverheadBudgets.
This commit is contained in:
@@ -84,6 +84,18 @@ module RedmineContracts
|
||||
|
||||
end
|
||||
|
||||
if old_deliverable['materials'].present? && old_deliverable['materials'] > 0.0
|
||||
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
|
||||
:budget => old_deliverable['materials'],
|
||||
:hours => 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)
|
||||
|
||||
end
|
||||
|
||||
deliverable.notes += "Converted data:\n<pre>" + old_deliverable.pretty_inspect + "</pre>"
|
||||
|
||||
deliverable.save!
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
profit:
|
||||
overhead_percent: 150
|
||||
description: ""
|
||||
materials_percent:
|
||||
materials_percent: 10
|
||||
due: 2008-06-18
|
||||
budget: 900.0
|
||||
client_signoff: false
|
||||
|
||||
@@ -60,13 +60,13 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
||||
end
|
||||
|
||||
should "create a new Overhead Budget record for any overhead" do
|
||||
assert_difference("OverheadBudget.count", 3) do
|
||||
assert_difference("OverheadBudget.count", 5) do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
end
|
||||
|
||||
d = Deliverable.find_by_title("Deliverable One")
|
||||
assert_equal 1, d.overhead_budgets.count
|
||||
assert_equal 200, d.overhead_budget_total
|
||||
assert_equal 2, d.overhead_budgets.count
|
||||
assert_equal 400, d.overhead_budget_total
|
||||
|
||||
overhead = d.overhead_budgets.first
|
||||
assert overhead
|
||||
@@ -75,7 +75,7 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
||||
end
|
||||
|
||||
should "create a new Overhead Budget record for any overhead percent" do
|
||||
assert_difference("OverheadBudget.count", 3) do
|
||||
assert_difference("OverheadBudget.count", 5) do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
end
|
||||
|
||||
@@ -90,6 +90,35 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
||||
|
||||
end
|
||||
|
||||
should "create a new Overhead Budget record for any materials" do
|
||||
assert_difference("OverheadBudget.count", 5) 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
|
||||
end
|
||||
|
||||
should "create a new Overhead Budget record for any overhead percent" do
|
||||
assert_difference("OverheadBudget.count", 5) 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 materials
|
||||
assert_equal 12 * 25 * 0.1, materials.budget
|
||||
assert_equal 0, materials.hours
|
||||
|
||||
end
|
||||
|
||||
should "append the YAML dump of the old object to the notes" do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
d = Deliverable.find_by_title("Deliverable One")
|
||||
|
||||
Reference in New Issue
Block a user