Created
November 20, 2013 16:17
-
-
Save laspluviosillas/7565960 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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