[#4551] Change the Budget conversion to convert materials as FixedBudget items
This commit is contained in:
1 parent
c6d43d9149
commit
0ef87e7b9c
2 files changed
+20
-25
No files matched your search
@@ -140,15 +140,15 @@ module RedmineContracts
|
|||||||
total ||= 0
|
total ||= 0
|
||||||
|
|
||||||
if old_deliverable['materials'].present? && old_deliverable['materials'] > 0.0
|
if old_deliverable['materials'].present? && old_deliverable['materials'] > 0.0
|
||||||
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
|
deliverable.fixed_budgets << FixedBudget.new(:deliverable => deliverable,
|
||||||
:budget => old_deliverable['materials'],
|
:budget => old_deliverable['materials'],
|
||||||
:hours => 0)
|
:markup => 0)
|
||||||
|
|
||||||
elsif old_deliverable['materials_percent'].present? && old_deliverable['materials_percent'] > 0.0
|
elsif old_deliverable['materials_percent'].present? && old_deliverable['materials_percent'] > 0.0
|
||||||
materials = total * (old_deliverable['materials_percent'].to_f / 100)
|
materials = total * (old_deliverable['materials_percent'].to_f / 100)
|
||||||
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
|
deliverable.fixed_budgets << FixedBudget.new(:deliverable => deliverable,
|
||||||
:budget => materials,
|
:budget => materials,
|
||||||
:hours => 0)
|
:markup => 0)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "create a new Overhead Budget record for any overhead" do
|
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)
|
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||||
end
|
end
|
||||||
|
|
||||||
d = Deliverable.find_by_title("Deliverable One")
|
d = Deliverable.find_by_title("Deliverable One")
|
||||||
assert_equal 2, d.overhead_budgets.count
|
assert_equal 1, d.overhead_budgets.count
|
||||||
assert_equal 400, d.overhead_budget_total
|
assert_equal 200, d.overhead_budget_total
|
||||||
|
|
||||||
overhead = d.overhead_budgets.first
|
overhead = d.overhead_budgets.first
|
||||||
assert overhead
|
assert overhead
|
||||||
@@ -100,12 +100,12 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "create a new Overhead Budget record for any overhead percent" do
|
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)
|
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||||
end
|
end
|
||||||
|
|
||||||
d = Deliverable.find_by_title("Deliverable 2")
|
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
|
overhead = d.overhead_budgets.first
|
||||||
assert overhead
|
assert overhead
|
||||||
@@ -114,32 +114,27 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a new Overhead Budget record for any materials" do
|
should "create a new Fixed Budget record for any materials" do
|
||||||
assert_difference("OverheadBudget.count", 5) do
|
assert_difference("FixedBudget.count", 2) do
|
||||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||||
end
|
end
|
||||||
|
|
||||||
d = Deliverable.find_by_title("Deliverable One")
|
d = Deliverable.find_by_title("Deliverable One")
|
||||||
assert_equal 2, d.overhead_budgets.count
|
assert_equal 1, d.fixed_budgets.count
|
||||||
assert_equal 400, d.overhead_budget_total
|
assert_equal 200, d.fixed_budget_total
|
||||||
|
|
||||||
materials = d.overhead_budgets.last
|
|
||||||
assert materials
|
|
||||||
assert_equal 200, materials.budget
|
|
||||||
assert_equal 0, materials.hours
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a new Overhead Budget record for any materials percent" do
|
should "create a new Fixed Budget record for any materials percent" do
|
||||||
assert_difference("OverheadBudget.count", 5) do
|
assert_difference("FixedBudget.count", 2) do
|
||||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||||
end
|
end
|
||||||
|
|
||||||
d = Deliverable.find_by_title("Deliverable 2")
|
d = Deliverable.find_by_title("Deliverable 2")
|
||||||
assert_equal 2, d.overhead_budgets.count
|
assert_equal 1, d.fixed_budgets.count
|
||||||
materials = d.overhead_budgets.last
|
materials = d.fixed_budgets.first
|
||||||
assert materials
|
assert materials
|
||||||
assert_equal 12 * 25 * 0.1, materials.budget
|
assert_equal 12 * 25 * 0.1, materials.budget
|
||||||
assert_equal 0, materials.hours
|
assert_equal 0, materials.markup.to_i
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user