Subversion Repositories SmartDukaan

Rev

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

Rev 7608 Rev 7627
Line 56... Line 56...
56
        try:
56
        try:
57
            provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
57
            provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
58
        except:
58
        except:
59
            provider_pincodes = {}
59
            provider_pincodes = {}
60
            serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes 
60
            serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes 
61
        provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.otgAvailable, serviceable_location.websiteCodLimit, serviceable_location.storeCodLimit
61
        provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.otgAvailable, serviceable_location.websiteCodLimit, serviceable_location.storeCodLimit, serviceable_location.providerPrepaidLimit
62
 
62
 
63
def __cache_warehouse_allocation_table():
63
def __cache_warehouse_allocation_table():
64
    warehouse_allocations = WarehouseAllocation.query.all()
64
    warehouse_allocations = WarehouseAllocation.query.all()
65
    for warehouse_allocation in warehouse_allocations:
65
    for warehouse_allocation in warehouse_allocations:
66
        warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
66
        warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
Line 90... Line 90...
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, billingWarehouseId):
92
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
93
    if billingWarehouseId != 12 and 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
        if weight < 480 and serviceable_location_cache.get(3).has_key(destination_pin) and (type == DeliveryType.PREPAID or item_selling_price < 3000):
95
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
95
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(3).get(destination_pin)
-
 
96
            if item_selling_price <= providerPrepaidLimit:
96
            iscod = iscod and item_selling_price <= websiteCodLimit
97
                iscod = iscod and item_selling_price <= websiteCodLimit
97
            otgAvailable = otgAvailable and item_selling_price >= 2000
98
                otgAvailable = otgAvailable and item_selling_price >= 2000
98
            return 3, iscod, otgAvailable
99
                return 3, iscod, otgAvailable
99
        else:
100
        else:
100
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(6).get(destination_pin)
101
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(6).get(destination_pin)
-
 
102
            if item_selling_price <= providerPrepaidLimit:
101
            iscod = iscod and item_selling_price <= websiteCodLimit
103
                iscod = iscod and item_selling_price <= websiteCodLimit
102
            otgAvailable = otgAvailable and item_selling_price >= 2000
104
                otgAvailable = otgAvailable and item_selling_price >= 2000
103
            return 6, iscod, otgAvailable
105
                return 6, iscod, otgAvailable
104
            
106
            
105
    if serviceable_location_cache.get(3).has_key(destination_pin):
107
    if serviceable_location_cache.get(3).has_key(destination_pin):
106
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(3).get(destination_pin)
108
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(3).get(destination_pin)
-
 
109
        if item_selling_price <= providerPrepaidLimit:
107
        iscod = iscod and item_selling_price <= websiteCodLimit
110
            iscod = iscod and item_selling_price <= websiteCodLimit
108
        otgAvailable = otgAvailable and item_selling_price >= 2000
111
            otgAvailable = otgAvailable and item_selling_price >= 2000
109
        return 3, iscod, otgAvailable
112
            return 3, iscod, otgAvailable
110
    
113
    
111
    if serviceable_location_cache.get(1).has_key(destination_pin):
114
    if serviceable_location_cache.get(1).has_key(destination_pin):
112
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(1).get(destination_pin)
115
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(1).get(destination_pin)
-
 
116
        if item_selling_price <= providerPrepaidLimit:
113
        iscod = iscod and item_selling_price <= websiteCodLimit
117
            iscod = iscod and item_selling_price <= websiteCodLimit
114
        otgAvailable = otgAvailable and item_selling_price >= 2000
118
            otgAvailable = otgAvailable and item_selling_price >= 2000
115
        return 1, iscod, otgAvailable
119
            return 1, iscod, otgAvailable
116
    else:
120
    else:
117
        return None, False, False    
121
        return None, False, False    
118
 
122
 
119
def get_destination_code(providerId, pinCode):
123
def get_destination_code(providerId, pinCode):
120
    serviceableLocationDetail = ServiceableLocationDetails.query.filter_by(provider_id = providerId, dest_pincode = pinCode).one()
124
    serviceableLocationDetail = ServiceableLocationDetails.query.filter_by(provider_id = providerId, dest_pincode = pinCode).one()
Line 222... Line 226...
222
    serviceableLocationDetails.exp = exp
226
    serviceableLocationDetails.exp = exp
223
    serviceableLocationDetails.cod = cod
227
    serviceableLocationDetails.cod = cod
224
    serviceableLocationDetails.station_type = stationType
228
    serviceableLocationDetails.station_type = stationType
225
    serviceableLocationDetails.otgAvailable = otgAvailable
229
    serviceableLocationDetails.otgAvailable = otgAvailable
226
    if provider == 1:
230
    if provider == 1:
227
        limit = 10000
231
        codlimit = 10000
-
 
232
        prepaidlimit = 50000
228
    elif provider == 3:
233
    elif provider == 3:
229
        limit = 25000
234
        codlimit = 25000
-
 
235
        prepaidlimit = 100000
230
    elif provider == 6:
236
    elif provider == 6:
231
        limit = 25000
237
        codlimit = 25000
-
 
238
        prepaidlimit = 100000
-
 
239
    serviceableLocationDetails.providerPrepaidLimit = prepaidlimit
232
    serviceableLocationDetails.providerCodLimit = limit
240
    serviceableLocationDetails.providerCodLimit = codlimit
233
    serviceableLocationDetails.websiteCodLimit = limit
241
    serviceableLocationDetails.websiteCodLimit = codlimit
234
    serviceableLocationDetails.websiteCodLimit = limit
242
    serviceableLocationDetails.storeCodLimit = codlimit
235
    session.commit()
243
    session.commit()
236
 
244
 
237
def update_pincode(providerId, pincode, exp, cod, otgAvailable):
245
def update_pincode(providerId, pincode, exp, cod, otgAvailable):
238
    serviceableLocationDetails = ServiceableLocationDetails.get_by(provider_id = providerId, dest_pincode = pincode)
246
    serviceableLocationDetails = ServiceableLocationDetails.get_by(provider_id = providerId, dest_pincode = pincode)
239
    serviceableLocationDetails.exp = exp
247
    serviceableLocationDetails.exp = exp
Line 279... Line 287...
279
    sp = client.getStorePricing(itemId)
287
    sp = client.getStorePricing(itemId)
280
    
288
    
281
    if codAllowed:
289
    if codAllowed:
282
        return sp.minAdvancePrice, True
290
        return sp.minAdvancePrice, True
283
    else:
291
    else:
284
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(providerId).get(destination_pin)
292
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(providerId).get(destination_pin)
285
        if iscod:
293
        if iscod:
286
            if providerId == 6:
294
            if providerId == 6:
287
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
295
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
288
            if providerId == 3:
296
            if providerId == 3:
289
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
297
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True