Subversion Repositories SmartDukaan

Rev

Rev 13356 | Rev 16025 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
442 rajveer 1
'''
2
Created on 13-Sep-2010
3
 
4
@author: rajveer
5
'''
6
 
7
from shop2020.logistics.service.impl import DataService
644 chandransh 8
from shop2020.logistics.service.impl.DataService import Awb, AwbUpdate, Provider, \
3218 rajveer 9
     DeliveryEstimate, WarehouseAllocation, \
5555 rajveer 10
    PublicHolidays, ServiceableLocationDetails, PickupStore
3044 chandransh 11
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException,\
7786 manish.sha 12
    DeliveryType, LogisticsLocationInfo
442 rajveer 13
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
5964 amar.kumar 14
from sqlalchemy.sql import or_
442 rajveer 15
from elixir import session
1730 ankur.sing 16
import datetime, time
1504 ankur.sing 17
import sys
3355 chandransh 18
import logging
13146 manish.sha 19
import os
7293 anupam.sin 20
from shop2020.clients.CatalogClient import CatalogClient
3355 chandransh 21
logging.basicConfig(level=logging.DEBUG)
442 rajveer 22
 
3217 rajveer 23
warehouse_allocation_cache = {}
24
serviceable_location_cache = {}
25
delivery_estimate_cache = {}
6370 rajveer 26
 
3218 rajveer 27
'''
28
This class is for only data transfer. Never used outside this module.
29
'''
30
class _DeliveryEstimateObject:
6537 rajveer 31
    def __init__(self, delivery_time, delivery_delay, provider_id, codAllowed, otgAvailable):
3218 rajveer 32
        self.delivery_time = delivery_time
6537 rajveer 33
        self.delivery_delay = delivery_delay
3218 rajveer 34
        self.provider_id = provider_id
4866 rajveer 35
        self.codAllowed = codAllowed
6524 rajveer 36
        self.otgAvailable = otgAvailable
3218 rajveer 37
 
3187 rajveer 38
def initialize(dbname="logistics", db_hostname="localhost"):
442 rajveer 39
    log_entry("initialize@DataAccessor", "Initializing data service")
3187 rajveer 40
    DataService.initialize(dbname, db_hostname)
3218 rajveer 41
    print "Starting cache population at: " + str(datetime.datetime.now())
3217 rajveer 42
    __cache_warehouse_allocation_table()
43
    __cache_serviceable_location_details_table()
44
    __cache_delivery_estimate_table()
45
    close_session()
3218 rajveer 46
    print "Done cache population at: " + str(datetime.datetime.now())
442 rajveer 47
 
3217 rajveer 48
def __cache_delivery_estimate_table():
49
    delivery_estimates = DeliveryEstimate.query.all()
50
    for delivery_estimate in delivery_estimates:
7857 rajveer 51
        delivery_estimate_cache[delivery_estimate.destination_pin, delivery_estimate.provider_id, delivery_estimate.warehouse_location]\
6537 rajveer 52
        =delivery_estimate.delivery_time, delivery_estimate.delivery_delay
3217 rajveer 53
 
54
def __cache_serviceable_location_details_table():
5964 amar.kumar 55
    serviceable_locations = ServiceableLocationDetails.query.filter(or_("exp!=0","cod!=0"))
3217 rajveer 56
    for serviceable_location in serviceable_locations:
57
        try:
58
            provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
59
        except:
60
            provider_pincodes = {}
61
            serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes 
7627 rajveer 62
        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
3217 rajveer 63
 
64
def __cache_warehouse_allocation_table():
65
    warehouse_allocations = WarehouseAllocation.query.all()
66
    for warehouse_allocation in warehouse_allocations:
67
        warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
68
 
644 chandransh 69
def get_provider(provider_id):
766 rajveer 70
    provider =  Provider.get_by(id=provider_id)
71
    return provider
644 chandransh 72
 
73
def get_providers():
5387 rajveer 74
    providers = Provider.query.filter_by(isActive = 1).all()
766 rajveer 75
    return providers 
644 chandransh 76
 
7608 rajveer 77
def get_logistics_estimation(destination_pin, item_selling_price, weight, type, billingWarehouseId):
5692 rajveer 78
    logging.info("Getting logistics estimation for pincode:" + destination_pin )
1504 ankur.sing 79
 
7608 rajveer 80
    provider_id, codAllowed, otgAvailable = __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId)
9964 anupam.sin 81
 
82
    if item_selling_price > 60000 or item_selling_price <= 250:
83
        codAllowed = False
84
 
7857 rajveer 85
    warehouse_location = 0
86
    if billingWarehouseId in [12,13]:
87
        warehouse_location = 1
88
 
3217 rajveer 89
    if not provider_id:
5692 rajveer 90
        raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin))
644 chandransh 91
    try:
7857 rajveer 92
        delivery_time = delivery_estimate_cache[destination_pin, provider_id, warehouse_location][0]
93
        delivery_delay = delivery_estimate_cache[destination_pin, provider_id, warehouse_location][1]
6537 rajveer 94
        delivery_estimate = _DeliveryEstimateObject(delivery_time, delivery_delay, provider_id, codAllowed, otgAvailable)
3218 rajveer 95
        return delivery_estimate
1504 ankur.sing 96
    except Exception as ex:
97
        print ex
644 chandransh 98
        raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
3150 rajveer 99
 
7608 rajveer 100
def __get_logistics_provider_for_destination_pincode(destination_pin, item_selling_price, weight, type, billingWarehouseId):
13357 manish.sha 101
    '''
102
    if serviceable_location_cache.get(6).has_key(destination_pin):
103
        if weight < 480 and serviceable_location_cache.get(3).has_key(destination_pin) and type == DeliveryType.PREPAID:
104
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(3).get(destination_pin)
105
            if item_selling_price <= providerPrepaidLimit:
106
                iscod = iscod and item_selling_price <= websiteCodLimit
107
                otgAvailable = otgAvailable and item_selling_price >= 2000
108
                return 3, iscod, otgAvailable
109
        else:
110
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(6).get(destination_pin)
111
            if item_selling_price <= providerPrepaidLimit:
112
                iscod = iscod and item_selling_price <= websiteCodLimit
113
                otgAvailable = otgAvailable and item_selling_price >= 2000
114
                return 6, iscod, otgAvailable
115
    '''        
7981 rajveer 116
    if serviceable_location_cache.get(3).has_key(destination_pin):
117
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(3).get(destination_pin)
7627 rajveer 118
        if item_selling_price <= providerPrepaidLimit:
7608 rajveer 119
            iscod = iscod and item_selling_price <= websiteCodLimit
120
            otgAvailable = otgAvailable and item_selling_price >= 2000
7981 rajveer 121
            return 3, iscod, otgAvailable
8575 rajveer 122
 
123
    if billingWarehouseId not in [12,13] and serviceable_location_cache.get(7).has_key(destination_pin):
124
        if item_selling_price < 3000 and serviceable_location_cache.get(1).has_key(destination_pin):
125
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(1).get(destination_pin)
126
            if item_selling_price <= providerPrepaidLimit:
127
                iscod = iscod and item_selling_price <= websiteCodLimit
128
                otgAvailable = otgAvailable and item_selling_price >= 2000
129
                return 1, iscod, otgAvailable
130
        else:
131
            dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(7).get(destination_pin)
132
            if item_selling_price <= providerPrepaidLimit:
133
                iscod = iscod and item_selling_price <= websiteCodLimit
134
                otgAvailable = otgAvailable and item_selling_price >= 2000
135
                return 7, iscod, otgAvailable
136
 
7627 rajveer 137
    if serviceable_location_cache.get(1).has_key(destination_pin):
138
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(1).get(destination_pin)
139
        if item_selling_price <= providerPrepaidLimit:
7608 rajveer 140
            iscod = iscod and item_selling_price <= websiteCodLimit
141
            otgAvailable = otgAvailable and item_selling_price >= 2000
7627 rajveer 142
            return 1, iscod, otgAvailable
7981 rajveer 143
 
10185 amit.gupta 144
    return None, False, False    
5278 rajveer 145
 
6017 amar.kumar 146
def get_destination_code(providerId, pinCode):
147
    serviceableLocationDetail = ServiceableLocationDetails.query.filter_by(provider_id = providerId, dest_pincode = pinCode).one()
148
    return serviceableLocationDetail.dest_code
149
 
644 chandransh 150
def add_empty_AWBs(numbers, provider_id, type):
442 rajveer 151
    for number in numbers:
644 chandransh 152
        query = Awb.query.filter_by(awb_number = number, provider_id = provider_id)
444 rajveer 153
        try:
154
            query.one()
155
        except:    
644 chandransh 156
            awb = Awb()
444 rajveer 157
            awb.awb_number = number
644 chandransh 158
            awb.provider_id = provider_id
444 rajveer 159
            awb.is_available = True
644 chandransh 160
            awb.type = type
161
    session.commit()
442 rajveer 162
 
444 rajveer 163
def set_AWB_as_used(awb_number):
644 chandransh 164
    query = Awb.query.filter_by(awb_number = awb_number)
444 rajveer 165
    awb = query.one() 
166
    awb.is_available=False
167
    session.commit()
168
 
3044 chandransh 169
def get_empty_AWB(provider_id, type = DeliveryType.PREPAID):
2342 chandransh 170
    query = Awb.query.with_lockmode("update").filter_by(provider_id = provider_id, is_available = True)  #check the provider thing
3044 chandransh 171
    if type == DeliveryType.PREPAID:
172
        query = query.filter_by(type="Prepaid")
173
    if type == DeliveryType.COD:
174
        query = query.filter_by(type="COD")
175
 
13158 manish.sha 176
    additionalQuery = query
177
    query = query.filter_by(awbUsedFor=0)
178
 
442 rajveer 179
    try:
644 chandransh 180
        awb = query.first()
13158 manish.sha 181
        if awb is None:
182
            additionalQuery = additionalQuery.filter_by(awbUsedFor=2)
183
            awb = additionalQuery.first()
644 chandransh 184
        awb.is_available = False
185
        session.commit()
444 rajveer 186
        return awb.awb_number
442 rajveer 187
    except:
644 chandransh 188
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
1137 chandransh 189
 
3103 chandransh 190
def get_free_awb_count(provider_id, type):
191
    count = Awb.query.filter_by(provider_id = provider_id, is_available = True, type=type).count()
1137 chandransh 192
    if count == None:
193
        count = 0
194
    return count
442 rajveer 195
 
644 chandransh 196
def get_shipment_info(awb_number, provider_id):
197
    awb = Awb.get_by(awb_number = awb_number, provider_id = provider_id)
198
    query = AwbUpdate.query.filter_by(awb = awb)
766 rajveer 199
    info = query.all()
200
    return info
201
 
6643 rajveer 202
def store_shipment_info(update):
203
    updates = AwbUpdate.query.filter_by(providerId = update.providerId, awbNumber  = update.awbNumber, location = update.location, date = to_py_date(update.date), status = update.status, description = update.description).all()
204
    if not updates:
205
        dupdate = AwbUpdate()
206
        dupdate.providerId = update.providerId
207
        dupdate.awbNumber  = update.awbNumber
208
        dupdate.location = update.location
209
        dupdate.date = to_py_date(update.date)
210
        dupdate.status = update.status
211
        dupdate.description = update.description
212
        session.commit()
213
 
1730 ankur.sing 214
def get_holidays(start_date, end_date):
215
    query = PublicHolidays.query
216
    if start_date != -1:
217
        query = query.filter(PublicHolidays.date >= to_py_date(start_date))
218
    if end_date != -1:
219
        query = query.filter(PublicHolidays.date <= to_py_date(end_date))
220
    holidays = query.all()
221
    holiday_dates = [to_java_date(datetime.datetime(*time.strptime(str(holiday.date), '%Y-%m-%d')[:3])) for holiday in holidays] 
222
    return holiday_dates
223
 
5527 anupam.sin 224
def get_provider_for_pickup_type(pickUp):
225
    return Provider.query.filter(Provider.pickup == pickUp).first().id
226
 
766 rajveer 227
def close_session():
228
    if session.is_active:
229
        print "session is active. closing it."
2823 chandransh 230
        session.close()
3376 rajveer 231
 
232
def is_alive():
233
    try:
234
        session.query(Awb.id).limit(1).one()
235
        return True
236
    except:
5555 rajveer 237
        return False
238
 
239
def get_all_pickup_stores():
5572 anupam.sin 240
    pickupStores = PickupStore.query.all()
241
    return pickupStores
5555 rajveer 242
 
243
def get_pickup_store(storeId):
5719 rajveer 244
    return PickupStore.query.filter_by(id = storeId).one()
245
 
246
def get_pickup_store_by_hotspot_id(hotspotId):
247
    return PickupStore.query.filter_by(hotspotId = hotspotId).one()
6322 amar.kumar 248
 
6524 rajveer 249
def add_pincode(provider, pincode, destCode, exp, cod, stationType, otgAvailable):
7914 rajveer 250
    provider = Provider.query.filter_by(id = provider).one()
6322 amar.kumar 251
    serviceableLocationDetails = ServiceableLocationDetails()
252
    serviceableLocationDetails.provider = provider
253
    serviceableLocationDetails.dest_pincode = pincode
254
    serviceableLocationDetails.dest_code = destCode
255
    serviceableLocationDetails.exp = exp
256
    serviceableLocationDetails.cod = cod
257
    serviceableLocationDetails.station_type = stationType
6524 rajveer 258
    serviceableLocationDetails.otgAvailable = otgAvailable
7733 manish.sha 259
    if provider.id == 1:
7627 rajveer 260
        codlimit = 10000
261
        prepaidlimit = 50000
7733 manish.sha 262
    elif provider.id == 3:
7627 rajveer 263
        codlimit = 25000
264
        prepaidlimit = 100000
7733 manish.sha 265
    elif provider.id == 6:
7627 rajveer 266
        codlimit = 25000
267
        prepaidlimit = 100000
268
    serviceableLocationDetails.providerPrepaidLimit = prepaidlimit
269
    serviceableLocationDetails.providerCodLimit = codlimit
270
    serviceableLocationDetails.websiteCodLimit = codlimit
271
    serviceableLocationDetails.storeCodLimit = codlimit
6322 amar.kumar 272
    session.commit()
273
 
6524 rajveer 274
def update_pincode(providerId, pincode, exp, cod, otgAvailable):
6615 amar.kumar 275
    serviceableLocationDetails = ServiceableLocationDetails.get_by(provider_id = providerId, dest_pincode = pincode)
6322 amar.kumar 276
    serviceableLocationDetails.exp = exp
277
    serviceableLocationDetails.cod = cod
6524 rajveer 278
    serviceableLocationDetails.otgAvailable = otgAvailable
7256 rajveer 279
    session.commit()
7567 rajveer 280
 
13146 manish.sha 281
def add_new_awbs(provider_id, isCod, awbs, awbUsedFor):
7567 rajveer 282
    provider = get_provider(provider_id)
283
    if isCod:
284
        dtype = 'Cod'
285
    else:
286
        dtype = 'Prepaid'
287
    for awb in awbs:
288
        a = Awb()
289
        a.type =  dtype
290
        a.is_available = True
291
        a.awb_number = awb
13146 manish.sha 292
        a.awbUsedFor = awbUsedFor
7567 rajveer 293
        a.provider = provider 
294
    session.commit()
7608 rajveer 295
    return True
7256 rajveer 296
 
297
def adjust_delivery_time(start_time, delivery_days):
298
    '''
299
    Returns the actual no. of days which will pass while 'delivery_days'
300
    no. of business days will pass since 'order_time'. 
301
    '''
302
    start_date = start_time.date()
303
    end_date = start_date + datetime.timedelta(days = delivery_days)
7272 amit.gupta 304
    holidays = get_holidays(to_java_date(start_time), -1)
7256 rajveer 305
    holidays = [to_py_date(holiday).date() for holiday in holidays]
306
 
307
    while start_date <= end_date:
308
        if start_date.weekday() == 6 or start_date in holidays:
309
            delivery_days = delivery_days + 1
310
            end_date = end_date + datetime.timedelta(days = 1)
311
        start_date = start_date + datetime.timedelta(days = 1)
312
 
313
    return delivery_days
7275 rajveer 314
 
315
def get_min_advance_amount(itemId, destination_pin, providerId, codAllowed):
316
    client = CatalogClient().get_client()
317
    sp = client.getStorePricing(itemId)
318
 
319
    if codAllowed:
320
        return sp.minAdvancePrice, True
321
    else:
7857 rajveer 322
        dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit = serviceable_location_cache.get(providerId).get(destination_pin)
7275 rajveer 323
        if iscod:
324
            if providerId == 6:
7489 rajveer 325
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
7275 rajveer 326
            if providerId == 3:
7489 rajveer 327
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
7275 rajveer 328
            if providerId == 1:
7489 rajveer 329
                return max(sp.minAdvancePrice, sp.recommendedPrice - storeCodLimit), True
7275 rajveer 330
        else:
7425 rajveer 331
            return sp.recommendedPrice, False
7733 manish.sha 332
#Start:- Added by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013
333
 
7786 manish.sha 334
def run_Logistics_Location_Info_Update(logisticsLocationInfoList, runCompleteUpdate):
335
    if runCompleteUpdate == True :
336
        serviceableLocationDetails = ServiceableLocationDetails.query.all()
337
        for serviceableLocationDetail in serviceableLocationDetails:
7841 manish.sha 338
            serviceableLocationDetail.exp = False
339
            serviceableLocationDetail.cod = False
7786 manish.sha 340
    for logisticsLocationInfo in logisticsLocationInfoList:
7841 manish.sha 341
        serviceableLocationDetail = ServiceableLocationDetails.get_by(provider_id = logisticsLocationInfo.providerId, dest_pincode = logisticsLocationInfo.pinCode)
7914 rajveer 342
        provider = Provider.query.filter_by(id = logisticsLocationInfo.providerId).one()
7841 manish.sha 343
        if serviceableLocationDetail:
344
            serviceableLocationDetail.exp = logisticsLocationInfo.expAvailable
345
            serviceableLocationDetail.cod = logisticsLocationInfo.codAvailable
346
            serviceableLocationDetail.otgAvailable = logisticsLocationInfo.otgAvailable
347
            serviceableLocationDetail.providerCodLimit = logisticsLocationInfo.codLimit
348
            serviceableLocationDetail.providerPrepaidLimit = logisticsLocationInfo.prepaidLimit
349
            serviceableLocationDetail.storeCodLimit = logisticsLocationInfo.codLimit
8219 manish.sha 350
            serviceableLocationDetail.websiteCodLimit = min(26000,logisticsLocationInfo.codLimit)
7841 manish.sha 351
        else:
352
            serviceableLocationDetail= ServiceableLocationDetails()
353
            serviceableLocationDetail.provider = provider
354
            serviceableLocationDetail.dest_pincode = logisticsLocationInfo.pinCode
355
            serviceableLocationDetail.dest_code = logisticsLocationInfo.destinationCode
356
            serviceableLocationDetail.exp = logisticsLocationInfo.expAvailable
357
            serviceableLocationDetail.cod = logisticsLocationInfo.codAvailable
358
            serviceableLocationDetail.station_type = 0
359
            serviceableLocationDetail.otgAvailable = logisticsLocationInfo.otgAvailable
360
            serviceableLocationDetail.providerCodLimit = logisticsLocationInfo.codLimit
361
            serviceableLocationDetail.providerPrepaidLimit = logisticsLocationInfo.prepaidLimit
362
            serviceableLocationDetail.storeCodLimit = logisticsLocationInfo.codLimit
8219 manish.sha 363
            serviceableLocationDetail.websiteCodLimit = min(26000,logisticsLocationInfo.codLimit)
7841 manish.sha 364
 
7870 rajveer 365
        deliveryEstimate = DeliveryEstimate.get_by(provider_id = logisticsLocationInfo.providerId, destination_pin = logisticsLocationInfo.pinCode, warehouse_location = logisticsLocationInfo.warehouseId) 
7841 manish.sha 366
        if deliveryEstimate:
367
            deliveryEstimate.warehouse_location= logisticsLocationInfo.warehouseId
368
            deliveryEstimate.delivery_time= logisticsLocationInfo.deliveryTime
369
            deliveryEstimate.delivery_delay= logisticsLocationInfo.delivery_delay
370
        else:
371
            deliveryEstimate = DeliveryEstimate()
372
            deliveryEstimate.destination_pin= logisticsLocationInfo.pinCode
373
            deliveryEstimate.provider = provider
374
            deliveryEstimate.warehouse_location= logisticsLocationInfo.warehouseId
375
            deliveryEstimate.delivery_time= logisticsLocationInfo.deliveryTime
376
            deliveryEstimate.delivery_delay= logisticsLocationInfo.delivery_delay
7733 manish.sha 377
    session.commit()
7786 manish.sha 378
 
7733 manish.sha 379
#End:- Added by Manish Sharma for Multiple Pincode Updation on 05-Jul-2013             
7275 rajveer 380
 
12895 manish.sha 381
def get_first_delivery_estimate_for_wh_location(pincode, whLocation):
382
    delEstimate = DeliveryEstimate.query.filter(DeliveryEstimate.destination_pin == pincode).filter(DeliveryEstimate.warehouse_location == whLocation).first()
383
    if delEstimate is None:
384
        return -1
385
    else:
386
        return 1
13146 manish.sha 387
 
388
def get_provider_limit_details_for_pincode(provider, pincode):
389
    serviceAbleDetails = ServiceableLocationDetails.get_by(provider_id = provider, dest_pincode = pincode)
390
    returnDataMap = {}
391
    if serviceAbleDetails:
392
        returnDataMap["websiteCodLimit"] = str(serviceAbleDetails.websiteCodLimit)
393
        returnDataMap["providerPrepaidLimit"] = str(serviceAbleDetails.providerPrepaidLimit)
394
 
395
    return returnDataMap
396
 
397
def get_new_empty_awb(providerId, type, orderQuantity):
398
    query = Awb.query.with_lockmode("update").filter_by(provider_id = providerId, is_available = True)  #check the provider thing
399
    if type == DeliveryType.PREPAID:
400
        query = query.filter_by(type="Prepaid")
401
    if type == DeliveryType.COD:
402
        query = query.filter_by(type="COD")
403
 
404
    additionalQuery = query
405
    if orderQuantity == 1:
406
        query = query.filter_by(awbUsedFor=0)
407
    if orderQuantity >1:
408
        query = query.filter_by(awbUsedFor=1) 
409
 
410
    try:
411
        awb = query.first()
412
        if awb is None:
413
            additionalQuery = additionalQuery.filter_by(awbUsedFor=2)
414
            awb = additionalQuery.first()
415
        awb.is_available = False
416
        session.commit()
417
        return awb.awb_number
418
    except:
419
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(providerId))
420