[#4184] Converted Labor Budget for HourlyDeliverables.
This commit is contained in:
1 parent
70d57ee359
commit
e6ab8ac3ab
2 files changed
+33
No files matched your search
@@ -41,6 +41,12 @@ module RedmineContracts
|
|||||||
@total = deliverable.total = old_deliverable['fixed_cost']
|
@total = deliverable.total = old_deliverable['fixed_cost']
|
||||||
when 'HourlyDeliverable'
|
when 'HourlyDeliverable'
|
||||||
@total = old_deliverable['total_hours'].to_f * old_deliverable['cost_per_hour'].to_f
|
@total = old_deliverable['total_hours'].to_f * old_deliverable['cost_per_hour'].to_f
|
||||||
|
|
||||||
|
if old_deliverable['total_hours'].present? || old_deliverable['cost_per_hour'].present?
|
||||||
|
deliverable.labor_budgets << LaborBudget.new(:deliverable => deliverable,
|
||||||
|
:budget => @total,
|
||||||
|
:hours => old_deliverable['total_hours'])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@total = 0
|
@total = 0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -98,6 +98,33 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
|||||||
assert_equal 30_000, d.total
|
assert_equal 30_000, d.total
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "converting Hourly Deliverables" do
|
||||||
|
should "create a new Labor Budget" do
|
||||||
|
assert_difference("LaborBudget.count", 2) do
|
||||||
|
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||||
|
end
|
||||||
|
|
||||||
|
d1 = Deliverable.find_by_title("Deliverable One")
|
||||||
|
assert_equal 1, d1.labor_budgets.count
|
||||||
|
assert_equal 100.0 * 50.0, d1.labor_budget_total
|
||||||
|
|
||||||
|
labor1 = d1.labor_budgets.first
|
||||||
|
assert labor1
|
||||||
|
assert_equal 5000, labor1.budget
|
||||||
|
assert_equal 100, labor1.hours
|
||||||
|
|
||||||
|
d2 = Deliverable.find_by_title("Deliverable 2")
|
||||||
|
assert_equal 1, d2.labor_budgets.count
|
||||||
|
assert_equal 12 * 25, d2.labor_budget_total
|
||||||
|
|
||||||
|
labor1 = d2.labor_budgets.first
|
||||||
|
assert labor1
|
||||||
|
assert_equal 300, labor1.budget
|
||||||
|
assert_equal 12, labor1.hours
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Reference in new issue
Block a user