Skip to content

Instantly share code, notes, and snippets.

@henkm
Created September 9, 2011 14:04
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 henkm/1206305 to your computer and use it in GitHub Desktop.
Save henkm/1206305 to your computer and use it in GitHub Desktop.
# user.rb
after_create :create_money_bird_user
def create_money_bird_user
contact = MoneyBirdContact.new
contact.customer_id = "sjamar_#{self.id}"
contact.first_name = self.first_name
contact.last_name = self.first_name
contact.email = self.email
if contact.save
logger.info "Contact saved"
else
logger.info contact.errors.inspect
end
invoice = MoneyBirdRecurringTemplate.new
invoice.frequency = 1 #number of times per period
invoice.contact_id = contact.id
invoice.frequency_type= 5 #1 for weekly, 2 for monthly, 3 for quarterly, 4 for half_yearly or 5 for yearly
invoice.details_attributes = [
{ :description => "my_description", :price => 100.00 }
]
invoice.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment