[#4184] Convert overhead percents.
This commit is contained in:
@@ -45,6 +45,23 @@ module RedmineContracts
|
||||
case old_deliverable['type']
|
||||
when 'FixedDeliverable'
|
||||
deliverable.total = old_deliverable['fixed_cost']
|
||||
if old_deliverable['overhead_percent'].present?
|
||||
budget = old_deliverable['fixed_cost'] * (old_deliverable['overhead_percent'].to_f / 100)
|
||||
|
||||
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
|
||||
:budget => budget,
|
||||
:hours => 0)
|
||||
end
|
||||
when 'HourlyDeliverable'
|
||||
if old_deliverable['overhead_percent'].present?
|
||||
budget = old_deliverable['total_hours'].to_f * old_deliverable['cost_per_hour'].to_f *
|
||||
(old_deliverable['overhead_percent'].to_f / 100)
|
||||
|
||||
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
|
||||
:budget => budget,
|
||||
:hours => 0)
|
||||
end
|
||||
|
||||
else
|
||||
# no-op
|
||||
end
|
||||
|
||||
@@ -60,7 +60,7 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
||||
end
|
||||
|
||||
should "create a new Overhead Budget record for any overhead" do
|
||||
assert_difference("OverheadBudget.count", 1) do
|
||||
assert_difference("OverheadBudget.count", 3) do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
end
|
||||
|
||||
@@ -74,6 +74,22 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
||||
assert_equal 0, overhead.hours
|
||||
end
|
||||
|
||||
should "create a new Overhead Budget record for any overhead percent" do
|
||||
assert_difference("OverheadBudget.count", 3) do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
end
|
||||
|
||||
d = Deliverable.find_by_title("Deliverable 2")
|
||||
assert_equal 1, d.overhead_budgets.count
|
||||
assert_equal 12 * 25 * 1.5, d.overhead_budget_total # hourly
|
||||
|
||||
overhead = d.overhead_budgets.first
|
||||
assert overhead
|
||||
assert_equal 450, overhead.budget
|
||||
assert_equal 0, overhead.hours
|
||||
|
||||
end
|
||||
|
||||
context "converting Fixed Deliverables" do
|
||||
should "convert fixed_cost to total" do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
|
||||
Reference in New Issue
Block a user