Skip to content

Instantly share code, notes, and snippets.

@laspluviosillas
Created November 20, 2013 16:17
Show Gist options
  • Save laspluviosillas/7565960 to your computer and use it in GitHub Desktop.
Save laspluviosillas/7565960 to your computer and use it in GitHub Desktop.
class Product
belongs_to :course
end
class Variant
belongs_to :course
end
class InventoryOrder
def process
order.line_items.each do |line_item|
generic_course = line_item.product.course
variant_course = line_item.variant.course || generic_course
# Find all units for distributor based on the generic product
OleCore::Unit.active.not_expired
.where(course_id: generic_course.id, account_id: from_account.id)
.limit(qty)
.update_all(
account_id: to_account.id
course_id: variant_course.id
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment