Subversion Repositories SmartDukaan

Rev

Rev 8859 | Rev 13521 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8859 Rev 13247
Line 163... Line 163...
163
def apply_coupon(coupon_code, cart_id):
163
def apply_coupon(coupon_code, cart_id):
164
    coupon = Coupon.get_by(coupon_code = coupon_code)
164
    coupon = Coupon.get_by(coupon_code = coupon_code)
165
    
165
    
166
    if coupon:
166
    if coupon:
167
        todate = datetime.datetime.now()
167
        todate = datetime.datetime.now()
168
        if not (coupon.promotion.start_on <=  todate and coupon.promotion.end_on >= todate):
168
        if not coupon.promotion.start_on <=  todate:
-
 
169
            raise PromotionException(101, 'Invalid coupon')
-
 
170
        if not coupon.promotion.end_on >= todate:
169
            raise PromotionException(101, 'Promotion has expired')
171
            raise PromotionException(101, 'Promotion has expired')
-
 
172
            
170
    
173
    
171
        user_client = UserClient().get_client()
174
        user_client = UserClient().get_client()
172
        cart = user_client.getCart(cart_id)
175
        cart = user_client.getCart(cart_id)
173
        
176
        
174
        coupon_module = coupon.promotion.rule_execution_src.strip()
177
        coupon_module = coupon.promotion.rule_execution_src.strip()