Subversion Repositories SmartDukaan

Rev

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

Rev 22238 Rev 22636
Line 7... Line 7...
7
from collections import namedtuple
7
from collections import namedtuple
8
from elixir import session
8
from elixir import session
9
from shop2020.clients.CatalogClient import CatalogClient
9
from shop2020.clients.CatalogClient import CatalogClient
10
from shop2020.clients.InventoryClient import InventoryClient
10
from shop2020.clients.InventoryClient import InventoryClient
11
from shop2020.clients.TransactionClient import TransactionClient
11
from shop2020.clients.TransactionClient import TransactionClient
12
from shop2020.logistics.service.impl import BluedartService, DataService
12
from shop2020.logistics.service.impl import BluedartService, DataService,\
-
 
13
    EcomExpressService
13
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
14
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
14
    DeliveryEstimate, WarehouseAllocation, PublicHolidays, \
15
    DeliveryEstimate, WarehouseAllocation, PublicHolidays, \
15
    ServiceableLocationDetails, PickupStore, Locations, ProviderCosting, \
16
    ServiceableLocationDetails, PickupStore, Locations, ProviderCosting, \
16
    BluedartAttribute, PincodeStates
17
    BluedartAttribute, PincodeStates
17
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException, \
18
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException, \
Line 141... Line 142...
141
 
142
 
142
def __cache_warehouse_locations():
143
def __cache_warehouse_locations():
143
    client = InventoryClient().get_client()
144
    client = InventoryClient().get_client()
144
    #client.getAllWarehouses(True)
145
    #client.getAllWarehouses(True)
145
    for warehouse in client.getAllWarehouses(True):
146
    for warehouse in client.getAllWarehouses(True):
-
 
147
        if warehouse.billingWarehouseId == warehouse.id:
146
        warehouse_location_cache[warehouse.billingWarehouseId]=warehouse.logisticsLocation
148
            warehouse_location_cache[warehouse.billingWarehouseId]=warehouse.logisticsLocation
147
        
149
        
148
def __cache_courier_costing_table():
150
def __cache_courier_costing_table():
149
    allCostings = ProviderCosting.query.all()
151
    allCostings = ProviderCosting.query.all()
150
    for costing in allCostings:
152
    for costing in allCostings:
151
        if provider_costing_sheet.has_key(costing.provider_id):
153
        if provider_costing_sheet.has_key(costing.provider_id):
Line 394... Line 396...
394
            awb = Awb()
396
            awb = Awb()
395
            awb.awb_number = number
397
            awb.awb_number = number
396
            awb.provider_id = provider_id
398
            awb.provider_id = provider_id
397
            awb.is_available = True
399
            awb.is_available = True
398
            awb.type = type
400
            awb.type = type
-
 
401
            awb.awbUsedFor = 2
399
    session.commit()
402
    session.commit()
400
 
403
 
401
def set_AWB_as_used(awb_number):
404
def set_AWB_as_used(awb_number):
402
    query = Awb.query.filter_by(awb_number = awb_number)
405
    query = Awb.query.filter_by(awb_number = awb_number)
403
    awb = query.one() 
406
    awb = query.one() 
Line 421... Line 424...
421
            awb = additionalQuery.first()
424
            awb = additionalQuery.first()
422
        awb.is_available = False
425
        awb.is_available = False
423
        session.commit()
426
        session.commit()
424
        return awb.awb_number
427
        return awb.awb_number
425
    except:
428
    except:
-
 
429
        #In case of missing awb for EComExpress fetch new awbs using their api
-
 
430
        if provider_id==48:
-
 
431
            awbs = EcomExpressService.generate_awb(type)
-
 
432
            #add_new_awbs(provider_id, isCod, awbs, awbUsedFor)
-
 
433
            add_empty_AWBs(awbs, provider_id, type)
-
 
434
            return get_awb(provider_id, logisticsTransactionId, type)
-
 
435
            
-
 
436
            
426
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
437
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
427
 
438
 
428
def get_empty_AWB(provider_id, logisticsTransactionId):
439
def get_empty_AWB(provider_id, logisticsTransactionId):
429
    try:
440
    try:
430
        if logisticsTransactionId is None:
441
        if logisticsTransactionId is None:
Line 443... Line 454...
443
                bluedartAttribute_destcode.logisticsTransactionId = logisticsTransactionId
454
                bluedartAttribute_destcode.logisticsTransactionId = logisticsTransactionId
444
                bluedartAttribute_destcode.name = "destCode"
455
                bluedartAttribute_destcode.name = "destCode"
445
                bluedartAttribute_destcode.value = bluedartResponse.destArea +"/"+ bluedartResponse.destLocation
456
                bluedartAttribute_destcode.value = bluedartResponse.destArea +"/"+ bluedartResponse.destLocation
446
                session.commit()
457
                session.commit()
447
            return bluedartAttribute.value
458
            return bluedartAttribute.value
448
        if provider_id  ==4:
459
        else :
449
            return get_awb(provider_id, logisticsTransactionId, DeliveryType.PREPAID)
460
            return get_awb(provider_id, logisticsTransactionId, DeliveryType.PREPAID)
450
    except:
461
    except:
451
        traceback.print_exc()
462
        traceback.print_exc()
452
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
463
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
453
        
464