Subversion Repositories SmartDukaan

Rev

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

Rev 20745 Rev 20924
Line 358... Line 358...
358
    query = Awb.query.filter_by(awb_number = awb_number)
358
    query = Awb.query.filter_by(awb_number = awb_number)
359
    awb = query.one() 
359
    awb = query.one() 
360
    awb.is_available=False
360
    awb.is_available=False
361
    session.commit()
361
    session.commit()
362
    
362
    
363
#def get_empty_AWB(provider_id, logisticsTransactionId):
363
def get_awb(provider_id, logisticsTransactionId, type):
364
#    query = Awb.query.with_lockmode("update").filter_by(provider_id = provider_id, is_available = True)  #check the provider thing
364
    query = Awb.query.with_lockmode("update").filter_by(provider_id = provider_id, is_available = True)  #check the provider thing
365
#    if type == DeliveryType.PREPAID:
365
    if type == DeliveryType.PREPAID:
366
#        query = query.filter_by(type="Prepaid")
366
        query = query.filter_by(type="Prepaid")
367
#    if type == DeliveryType.COD:
367
    if type == DeliveryType.COD:
368
#        query = query.filter_by(type="COD")
368
        query = query.filter_by(type="COD")
369
#    
369
    
370
#    additionalQuery = query
370
    additionalQuery = query
371
#    query = query.filter_by(awbUsedFor=0)
371
    query = query.filter_by(awbUsedFor=0)
372
#    
372
    
373
#    try:
373
    try:
374
#        awb = query.first()
374
        awb = query.first()
375
#        if awb is None:
375
        if awb is None:
376
#            additionalQuery = additionalQuery.filter_by(awbUsedFor=2)
376
            additionalQuery = additionalQuery.filter_by(awbUsedFor=2)
377
#            awb = additionalQuery.first()
377
            awb = additionalQuery.first()
378
#        awb.is_available = False
378
        awb.is_available = False
379
#        session.commit()
379
        session.commit()
380
#        return awb.awb_number
380
        return awb.awb_number
381
#    except:
381
    except:
382
#        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
382
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
383
 
383
 
384
def get_empty_AWB(provider_id, logisticsTransactionId):
384
def get_empty_AWB(provider_id, logisticsTransactionId):
385
    try:
385
    try:
386
        if logisticsTransactionId is None:
386
        if logisticsTransactionId is None:
387
            return ""
387
            return ""
Line 399... Line 399...
399
                bluedartAttribute_destcode.logisticsTransactionId = logisticsTransactionId
399
                bluedartAttribute_destcode.logisticsTransactionId = logisticsTransactionId
400
                bluedartAttribute_destcode.name = "destCode"
400
                bluedartAttribute_destcode.name = "destCode"
401
                bluedartAttribute_destcode.value = bluedartResponse.destArea +"/"+ bluedartResponse.destLocation
401
                bluedartAttribute_destcode.value = bluedartResponse.destArea +"/"+ bluedartResponse.destLocation
402
                session.commit()
402
                session.commit()
403
            return bluedartAttribute.value
403
            return bluedartAttribute.value
-
 
404
        if provider_id  ==4:
-
 
405
            return get_awb(provider_id, logisticsTransactionId, DeliveryType.PREPAID)
404
    except:
406
    except:
405
        traceback.print_exc()
407
        traceback.print_exc()
406
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
408
        raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
407
        
409
        
408
 
410