Subversion Repositories SmartDukaan

Rev

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

Rev 4642 Rev 4668
Line 502... Line 502...
502
    session.commit()
502
    session.commit()
503
    return True
503
    return True
504
 
504
 
505
def get_carts_with_coupon_count(coupon_code):
505
def get_carts_with_coupon_count(coupon_code):
506
    return Cart.query.filter_by(coupon_code = coupon_code).count()
506
    return Cart.query.filter_by(coupon_code = coupon_code).count()
-
 
507
 
-
 
508
def show_cod_option(cartId, sourceId, pincode):
-
 
509
    cart = Cart.get_by(id = cartId)
-
 
510
    cod_option = True
-
 
511
    COD_MIN_AMOUNT = 100
-
 
512
    COD_MAX_AMOUNT = 10000
-
 
513
    inventory_client = CatalogClient().get_client()
-
 
514
    logistics_client = LogisticsClient().get_client()
-
 
515
    
-
 
516
    if cart:
-
 
517
        if cart.coupon_code and cart.coupon_code.lower() == 'sh911':
-
 
518
            cod_option = False 
-
 
519
    
-
 
520
        elif cart.lines:
-
 
521
            for line in cart.lines:
-
 
522
                item = inventory_client.getItemForSource(line.item_id, sourceId)
-
 
523
            
-
 
524
                if item and (item.sellingPrice < COD_MIN_AMOUNT or item.sellingPrice > COD_MAX_AMOUNT):
-
 
525
                    cod_option = False
-
 
526
                    break
-
 
527
    
-
 
528
    if pincode and cod_option:
-
 
529
        cod_option = logistics_client.isCodAllowed(pincode)
-
 
530
    
-
 
531
    return cod_option
507
    
532
    
508
def close_session():
533
def close_session():
509
    if session.is_active:
534
    if session.is_active:
510
        print "session is active. closing it."
535
        print "session is active. closing it."
511
        session.close()
536
        session.close()