[#4409] Convert contracts with the billable rate of 50.
This commit is contained in:
@@ -29,7 +29,9 @@ module RedmineContracts
|
||||
end
|
||||
|
||||
# * old_data - YAML string of deliverables to migrate
|
||||
def self.migrate(old_data)
|
||||
def self.migrate(old_data, options={})
|
||||
@contract_rate = options[:contract_rate] ? options[:contract_rate].to_f : 150.0
|
||||
|
||||
@@data = YAML.load(old_data)
|
||||
|
||||
# Map old deliverable ids to the new ones
|
||||
@@ -106,6 +108,7 @@ module RedmineContracts
|
||||
c.account_executive = project.users.first
|
||||
c.start_date ||= Date.today
|
||||
c.end_date ||= Date.today
|
||||
c.billable_rate = @contract_rate
|
||||
end
|
||||
|
||||
contract.save!
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
namespace :redmine_contracts do
|
||||
desc "Migrate data from the budget_plugin to redmine_contracts"
|
||||
task :budget_migration => :environment do
|
||||
options = {}
|
||||
options[:contract_rate] = ENV['contract_rate']
|
||||
|
||||
RedmineContracts::BudgetPluginMigration.check_for_installed_budget_plugin
|
||||
data = RedmineContracts::BudgetPluginMigration.export_data
|
||||
RedmineContracts::BudgetPluginMigration.rename_old_tables
|
||||
RedmineContracts::BudgetPluginMigration.migrate_contracts
|
||||
RedmineContracts::BudgetPluginMigration.migrate(data)
|
||||
RedmineContracts::BudgetPluginMigration.migrate(data, options)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,6 +53,22 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
||||
assert_equal 2, @project_two.reload.contracts.first.deliverables.count
|
||||
end
|
||||
|
||||
context "on new Contracts" do
|
||||
should "default the contract billable rate to $150" do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
|
||||
assert_equal 150, @project_one.reload.contracts.first.billable_rate
|
||||
assert_equal 150, @project_two.reload.contracts.first.billable_rate
|
||||
end
|
||||
|
||||
should "allow overriding the contract billable rate" do
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data, :contract_rate => '100.50')
|
||||
|
||||
assert_equal 100.5, @project_one.reload.contracts.first.billable_rate
|
||||
assert_equal 100.5, @project_two.reload.contracts.first.billable_rate
|
||||
end
|
||||
end
|
||||
|
||||
should "enable the contracts plugin for each project with a contract" do
|
||||
@no_deliverables = Project.generate!(:enabled_modules => [])
|
||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||
|
||||
Reference in New Issue
Block a user