Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Created October 20, 2010 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannymcc/636066 to your computer and use it in GitHub Desktop.
Save dannymcc/636066 to your computer and use it in GitHub Desktop.
# FreeAgent API Project Create
# Required attribues
# :contact_id
# :name
# :billing_basis # must be 1, 7, 7.5, or 8
# :budget_units # must be Hours, Days, or Monetary
# :status # must be Active or Completed
def create_freeagent_project(current_user)
contact = Freeagent::Contact.find_by_name(company.companyname)
p = Freeagent::Project.create(
:contact_id => contact.id,
:name => "#{jobno} - #{highrisesubject}",
:billing_basis => 1,
:budget_units => 'Hours',
:status => 'Active'
)
Freeagent::Task.create(:project_id => p.id, :name => 'Setup', :billing_rate => 85)
Freeagent::Task.create(:project_id => p.id, :name => 'Telephone Discussions', :billing_rate => 85)
Freeagent::Task.create(:project_id => p.id, :name => 'Investigation', :billing_rate => 65)
Freeagent::Task.create(:project_id => p.id, :name => 'Travel', :billing_rate => 50)
Freeagent::Task.create(:project_id => p.id, :name => 'Survey', :billing_rate => 65)
Freeagent::Task.create(:project_id => p.id, :name => 'Correspondence', :billing_rate => 85)
Freeagent::Task.create(:project_id => p.id, :name => 'Report', :billing_rate => 85)
Freeagent::Task.create(:project_id => p.id, :name => 'Claim Assessment', :billing_rate => 85)
user = Freeagent::User.find_by_email(current_user.email)
Freeagent::Timeslip.create(
:project_id => p.id,
:user_id => user.id,
:hours => 1,
:task_id => '1',
:dated_on => Time.now
)
self.freeagent_id = p.id
self.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment