Subversion Repositories SmartDukaan

Rev

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

Rev 4668 Rev 4866
Line 506... Line 506...
506
    return Cart.query.filter_by(coupon_code = coupon_code).count()
506
    return Cart.query.filter_by(coupon_code = coupon_code).count()
507
 
507
 
508
def show_cod_option(cartId, sourceId, pincode):
508
def show_cod_option(cartId, sourceId, pincode):
509
    cart = Cart.get_by(id = cartId)
509
    cart = Cart.get_by(id = cartId)
510
    cod_option = True
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()
511
    logistics_client = LogisticsClient().get_client()
515
    
512
    
516
    if cart:
513
    if cart:
517
        if cart.coupon_code and cart.coupon_code.lower() == 'sh911':
514
        if cart.coupon_code and cart.coupon_code.lower() == 'sh911':
518
            cod_option = False 
515
            cod_option = False 
519
    
516
    
520
        elif cart.lines:
517
        elif cart.lines:
521
            for line in cart.lines:
518
            for line in cart.lines:
522
                item = inventory_client.getItemForSource(line.item_id, sourceId)
519
                logistics_info = logistics_client.getLogisticsEstimation(line.item_id, pincode, DeliveryType.PREPAID)
523
            
520
                
524
                if item and (item.sellingPrice < COD_MIN_AMOUNT or item.sellingPrice > COD_MAX_AMOUNT):
521
                if not logistics_info.isCodAllowed:
525
                    cod_option = False
522
                    cod_option = False
526
                    break
523
                    break
527
    
524
    
528
    if pincode and cod_option:
-
 
529
        cod_option = logistics_client.isCodAllowed(pincode)
-
 
530
    
-
 
531
    return cod_option
525
    return cod_option
532
    
526
    
533
def close_session():
527
def close_session():
534
    if session.is_active:
528
    if session.is_active:
535
        print "session is active. closing it."
529
        print "session is active. closing it."