Subversion Repositories SmartDukaan

Rev

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

Rev 20939 Rev 20954
Line 11362... Line 11362...
11362
def calculate_payment_amount(txnId):
11362
def calculate_payment_amount(txnId):
11363
    transaction = Transaction.get_by(id=txnId)
11363
    transaction = Transaction.get_by(id=txnId)
11364
    miscCharges = MiscCharges.get_by(transaction_id = transaction.id)
11364
    miscCharges = MiscCharges.get_by(transaction_id = transaction.id)
11365
    total_amount = 0.0
11365
    total_amount = 0.0
11366
    for order in transaction.orders:
11366
    for order in transaction.orders:
-
 
11367
        if order.net_payable_amount is None:
-
 
11368
            order.net_payable_amount = 0
11367
        total_amount = total_amount + order.net_payable_amount
11369
        total_amount = total_amount + order.net_payable_amount
11368
    if miscCharges and miscCharges.get(1) is not None:
11370
    if miscCharges and miscCharges.get(1) is not None:
11369
        total_amount = total_amount + miscCharges.get(1)
11371
        total_amount = total_amount + miscCharges.get(1)
11370
    return total_amount
11372
    return total_amount
11371
 
11373
 
-
 
11374
def get_billed_orders_for_manifest_gen(warehouse_id, logistics_provider_id, cod):
-
 
11375
    orders =  Order.query.filter(Order.warehouse_id == warehouse_id)\
-
 
11376
    .filter(Order.status == OrderStatus.BILLED)\
-
 
11377
    .filter(Order.logistics_provider_id == logistics_provider_id).all()
-
 
11378
    shipmentMap = {}
-
 
11379
    p_returnMap = {}
-
 
11380
    c_returnMap = {}
-
 
11381
    for order in orders:
-
 
11382
        if shipmentMap.has_key(order.logisticsTransactionId):
-
 
11383
            shipmentMap.get(order.logisticsTransactionId).append(order)
-
 
11384
        else:
-
 
11385
            shipmentMap[order.logisticsTransactionId] = [order]
-
 
11386
            
-
 
11387
    for k,v in shipmentMap.iteritems():
-
 
11388
        validShipment = True
-
 
11389
        for order in v:
-
 
11390
            if order.cod and order.net_payable_amount > 0:
-
 
11391
                validShipment = False
-
 
11392
                break
-
 
11393
        if validShipment:
-
 
11394
            p_returnMap[k] = shipmentMap.get(k)
-
 
11395
        else:
-
 
11396
            c_returnMap[k] = shipmentMap.get(k)
-
 
11397
    
-
 
11398
    if cod:
-
 
11399
        return c_returnMap.values()
-
 
11400
    else:
-
 
11401
        return p_returnMap.values()
-
 
11402
 
11372
 
11403
 
11373
 
11404
 
11374
if __name__ == '__main__':
11405
if __name__ == '__main__':
11375
    pass
11406
    DataService.initialize()
-
 
11407
    get_billed_orders_for_manifest_gen(7441, 2, True)
11376
#    ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
11408
#    ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
11377
#                 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
11409
#                 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
11378
#                 'x911319502973102':1544269,'x911319502913009':1544269,'x911319502973979':1544269,'x911319502842729':1544269,'x911319502824784':1544269,'x911319502847249':1544269,'x911319502848387':1544269,'x911319502887021':1544269,'x911319502962634':1544269,
11410
#                 'x911319502973102':1544269,'x911319502913009':1544269,'x911319502973979':1544269,'x911319502842729':1544269,'x911319502824784':1544269,'x911319502847249':1544269,'x911319502848387':1544269,'x911319502887021':1544269,'x911319502962634':1544269,
11379
#                 'x911319502826268':1544269,'x911319502785761':1544269,'x911319502956750':1544269,'x911319502825195':1544269,'x911319502828298':1544269,'x911319502972054':1544269,'x911319502902044':1544269,'x911319502846498':1544269,'x911319502824305':1544269,
11411
#                 'x911319502826268':1544269,'x911319502785761':1544269,'x911319502956750':1544269,'x911319502825195':1544269,'x911319502828298':1544269,'x911319502972054':1544269,'x911319502902044':1544269,'x911319502846498':1544269,'x911319502824305':1544269,
11380
#                 'x911319502891478':1544269,'x911319502962451':1544269,'x911319502929732':1544269,'x911319502834304':1544269,'x911319502830575':1544269,'x911319502889456':1544269,'x911319502842521':1544269,'x911319502900998':1544269,'x911319502890462':1544269,'x911319502881222':1544269,'x911319503523252':1544269}
11412
#                 'x911319502891478':1544269,'x911319502962451':1544269,'x911319502929732':1544269,'x911319502834304':1544269,'x911319502830575':1544269,'x911319502889456':1544269,'x911319502842521':1544269,'x911319502900998':1544269,'x911319502890462':1544269,'x911319502881222':1544269,'x911319503523252':1544269}