[#4184] Got the most basic objects ported from Budget to Contracts.

This commit is contained in:
Eric Davis
2010-07-13 14:58:11 -07:00
parent b787d4adbe
commit 5c01a0709d
2 changed files with 67 additions and 2 deletions
@@ -9,6 +9,36 @@ module RedmineContracts
def self.migrate(old_data)
@@data = old_data
ActiveRecord::Base.transaction do
@@data.each do |old_deliverable|
deliverable = Deliverable.new(
:title => old_deliverable['subject'],
:end_date => old_deliverable['due'],
:notes => old_deliverable['description']
)
deliverable.type = old_deliverable['type']
project = Project.find(old_deliverable['project_id'])
contract = Contract.find_by_project_id(project.id)
if contract.nil?
contract = Contract.new(:name => 'Converted Contract',
:start_date => old_deliverable['due'],
:end_date => old_deliverable['due'])
contract.project = project
contract.account_executive = project.users.first
contract.save!
end
deliverable.contract = contract
deliverable.manager = project.users.first
deliverable.save!
end
end
end
def self.data