Subversion Repositories SmartDukaan

Rev

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

Rev 7589 Rev 7608
Line 71... Line 71...
71
 
71
 
72
def get_providers():
72
def get_providers():
73
    providers = Provider.query.filter_by(isActive = 1).all()
73
    providers = Provider.query.filter_by(isActive = 1).all()
74
    return providers 
74
    return providers 
75
 
75
 
76
def get_logistics_estimation(destination_pin, item_selling_price, weight, type):
76
def get_logistics_estimation(destination_pin, item_selling_price, weight, type, billingWarehouseId):
77
    logging.info("Getting logistics estimation for pincode:" + destination_pin )
77
    logging.info("Getting logistics estimation for pincode:" + destination_pin )
78
    
78
    
79
    provider_id, codAllowed, otgAvailable = __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type)
79
    provider_id, codAllowed, otgAvailable = __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId)
80
    
80
    
81
    if not provider_id:
81
    if not provider_id:
82
        raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin))
82
        raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin))
83
    try:
83
    try:
84
        delivery_time = delivery_estimate_cache[destination_pin, provider_id][0]
84
        delivery_time = delivery_estimate_cache[destination_pin, provider_id][0]
Line 87... Line 87...
87
        return delivery_estimate
87
        return delivery_estimate
88
    except Exception as ex:
88
    except Exception as ex:
89
        print ex
89
        print ex
90
        raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
90
        raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
91
 
91
 
92
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type):
92
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
93
    if serviceable_location_cache.get(6).has_key(destination_pin):
93
    if billingWarehouseId != 12 and serviceable_location_cache.get(6).has_key(destination_pin):
-
 
94
        if weight < 480 and serviceable_location_cache.get(3).has_key(destination_pin) and (type == DeliveryType.PREPAID or item_selling_price < 3000):
94
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(6).get(destination_pin)
95
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
95
        iscod = iscod and item_selling_price <= websiteCodLimit
96
            iscod = iscod and item_selling_price <= websiteCodLimit
96
        otgAvailable = otgAvailable and item_selling_price >= 2000
97
            otgAvailable = otgAvailable and item_selling_price >= 2000
-
 
98
            return 3, iscod, otgAvailable
-
 
99
        else:
-
 
100
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(6).get(destination_pin)
-
 
101
            iscod = iscod and item_selling_price <= websiteCodLimit
97
        if weight >= 480 or (type == DeliveryType.COD and item_selling_price >= 3000):
102
            otgAvailable = otgAvailable and item_selling_price >= 2000
98
            return 6, iscod, otgAvailable    
103
            return 6, iscod, otgAvailable
99
        
104
            
100
    if serviceable_location_cache.get(3).has_key(destination_pin):
105
    if serviceable_location_cache.get(3).has_key(destination_pin):
101
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
106
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
102
        iscod = iscod and item_selling_price <= websiteCodLimit
107
        iscod = iscod and item_selling_price <= websiteCodLimit
103
        otgAvailable = otgAvailable and item_selling_price >= 2000
108
        otgAvailable = otgAvailable and item_selling_price >= 2000
104
        return 3, iscod, otgAvailable
109
        return 3, iscod, otgAvailable
Line 247... Line 252...
247
        a.type =  dtype
252
        a.type =  dtype
248
        a.is_available = True
253
        a.is_available = True
249
        a.awb_number = awb
254
        a.awb_number = awb
250
        a.provider = provider 
255
        a.provider = provider 
251
    session.commit()
256
    session.commit()
-
 
257
    return True
252
    
258
    
253
def adjust_delivery_time(start_time, delivery_days):
259
def adjust_delivery_time(start_time, delivery_days):
254
    '''
260
    '''
255
    Returns the actual no. of days which will pass while 'delivery_days'
261
    Returns the actual no. of days which will pass while 'delivery_days'
256
    no. of business days will pass since 'order_time'. 
262
    no. of business days will pass since 'order_time'.