Skip to content

Instantly share code, notes, and snippets.

@jetsgit
Last active August 29, 2015 14:02
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 jetsgit/1bfe868ef6dcac9878b2 to your computer and use it in GitHub Desktop.
Save jetsgit/1bfe868ef6dcac9878b2 to your computer and use it in GitHub Desktop.
Spree::Order.class_eval do
self.state_machine.after_transition :to => :payment, :do => :lookup_tax_cloud, :if => :tax_cloud_eligible?
def lookup_tax_cloud
unless tax_cloud_transaction.nil?
tax_cloud_transaction.lookup
else
create_tax_cloud_transaction
tax_cloud_transaction.lookup
tax_cloud_adjustment
end
end
def tax_cloud_adjustment
line_items.each do |line_item|
line_item.adjustments.create({
source: self.tax_cloud_transaction,
label: 'Tax from TaxCloud',
mandatory: true,
eligible: true,
amount: line_item.tax_cloud_cart_item.amount,
order_id: self.id
})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment