[#4409] Convert contracts with the billable rate of 50.
This commit is contained in:
1 parent
61270c60d5
commit
e734430deb
3 files changed
+24
-2
No files matched your search
@@ -29,7 +29,9 @@ module RedmineContracts
|
|||||||
end
|
end
|
||||||
|
|
||||||
# * old_data - YAML string of deliverables to migrate
|
# * 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)
|
@@data = YAML.load(old_data)
|
||||||
|
|
||||||
# Map old deliverable ids to the new ones
|
# Map old deliverable ids to the new ones
|
||||||
@@ -106,6 +108,7 @@ module RedmineContracts
|
|||||||
c.account_executive = project.users.first
|
c.account_executive = project.users.first
|
||||||
c.start_date ||= Date.today
|
c.start_date ||= Date.today
|
||||||
c.end_date ||= Date.today
|
c.end_date ||= Date.today
|
||||||
|
c.billable_rate = @contract_rate
|
||||||
end
|
end
|
||||||
|
|
||||||
contract.save!
|
contract.save!
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
namespace :redmine_contracts do
|
namespace :redmine_contracts do
|
||||||
desc "Migrate data from the budget_plugin to redmine_contracts"
|
desc "Migrate data from the budget_plugin to redmine_contracts"
|
||||||
task :budget_migration => :environment do
|
task :budget_migration => :environment do
|
||||||
|
options = {}
|
||||||
|
options[:contract_rate] = ENV['contract_rate']
|
||||||
|
|
||||||
RedmineContracts::BudgetPluginMigration.check_for_installed_budget_plugin
|
RedmineContracts::BudgetPluginMigration.check_for_installed_budget_plugin
|
||||||
data = RedmineContracts::BudgetPluginMigration.export_data
|
data = RedmineContracts::BudgetPluginMigration.export_data
|
||||||
RedmineContracts::BudgetPluginMigration.rename_old_tables
|
RedmineContracts::BudgetPluginMigration.rename_old_tables
|
||||||
RedmineContracts::BudgetPluginMigration.migrate_contracts
|
RedmineContracts::BudgetPluginMigration.migrate_contracts
|
||||||
RedmineContracts::BudgetPluginMigration.migrate(data)
|
RedmineContracts::BudgetPluginMigration.migrate(data, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -53,6 +53,22 @@ class BudgetPluginMigrationTest < ActionController::IntegrationTest
|
|||||||
assert_equal 2, @project_two.reload.contracts.first.deliverables.count
|
assert_equal 2, @project_two.reload.contracts.first.deliverables.count
|
||||||
end
|
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
|
should "enable the contracts plugin for each project with a contract" do
|
||||||
@no_deliverables = Project.generate!(:enabled_modules => [])
|
@no_deliverables = Project.generate!(:enabled_modules => [])
|
||||||
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
RedmineContracts::BudgetPluginMigration.migrate(@data)
|
||||||
|
|||||||
Reference in new issue
Block a user