Created
November 3, 2011 22:12
-
-
Save fahim/1337950 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
def used_promotion_credits(order) | |
p = PromotionCredit.arel_table | |
o = Order.arel_table | |
if order.user.anonymous? | |
user_condition = o[:email].eq order.email | |
else | |
user_condition = o[:user_id].eq order.user_id | |
end | |
PromotionCredit.includes(:order).where(p[:source_id].eq(promotion_id), o[:state].eq(Order::FINALIZED_STATES), user_condition) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment