Subversion Repositories SmartDukaan

Rev

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

Rev 21101 Rev 21105
Line 5058... Line 5058...
5058
    return True
5058
    return True
5059
 
5059
 
5060
def move_orders_to_correct_warehouse():
5060
def move_orders_to_correct_warehouse():
5061
    completedOrders = []
5061
    completedOrders = []
5062
    pendingOrders = ""
5062
    pendingOrders = ""
5063
    orders = Order.query.filter(Order.status.in_(tuple([OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.ACCEPTED]))).order_by(Order.promised_shipping_time).all()
5063
    orders = Order.query.filter(Order.status.in_(tuple([OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS]))).order_by(Order.promised_shipping_time).all()
5064
    logistics_client = LogisticsClient().get_client()
5064
    logistics_client = LogisticsClient().get_client()
5065
    inventoryClient = InventoryClient().get_client()
5065
    inventoryClient = InventoryClient().get_client()
-
 
5066
    #warehouses = inventoryClient.getWarehouses(None, None, None, None, None)
5066
    for order in orders:
5067
    for order in orders:
5067
        lineitem = order.lineitems[0]
5068
        lineitem = order.lineitems[0]
5068
        try:
5069
        try:
5069
            if not logistics_client or not logistics_client.isAlive():
5070
            if not logistics_client or not logistics_client.isAlive():
5070
                logistics_client = LogisticsClient().get_client()
5071
                logistics_client = LogisticsClient().get_client()
Line 11544... Line 11545...
11544
    ap.cash_back = 1
11545
    ap.cash_back = 1
11545
    ap.cash_back_type = "PERCENTAGE"
11546
    ap.cash_back_type = "PERCENTAGE"
11546
    ap.cash_back_amount = int(math.floor(amount * .01))
11547
    ap.cash_back_amount = int(math.floor(amount * .01))
11547
    session.commit()
11548
    session.commit()
11548
    add_amount_in_wallet(userId, ap.amount + ap.cash_back_amount, ap.id, WalletReferenceType.ADVANCE_AMOUNT, True, True)
11549
    add_amount_in_wallet(userId, ap.amount + ap.cash_back_amount, ap.id, WalletReferenceType.ADVANCE_AMOUNT, True, True)
11549
    return True
11550
    return True    
11550
    
-
 
11551
    
-
 
11552
    
11551
    
11553
if __name__ == '__main__':
11552
if __name__ == '__main__':
11554
    #DataService.initialize()
11553
    DataService.initialize()
11555
    get_billed_orders_for_manifest_gen(7441, 2, True)
11554
#    get_billed_orders_for_manifest_gen(7441, 2, True)
11556
#    ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
11555
#    ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
11557
#                 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
11556
#                 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
11558
#                 'x911319502973102':1544269,'x911319502913009':1544269,'x911319502973979':1544269,'x911319502842729':1544269,'x911319502824784':1544269,'x911319502847249':1544269,'x911319502848387':1544269,'x911319502887021':1544269,'x911319502962634':1544269,
11557
#                 'x911319502973102':1544269,'x911319502913009':1544269,'x911319502973979':1544269,'x911319502842729':1544269,'x911319502824784':1544269,'x911319502847249':1544269,'x911319502848387':1544269,'x911319502887021':1544269,'x911319502962634':1544269,
11559
#                 'x911319502826268':1544269,'x911319502785761':1544269,'x911319502956750':1544269,'x911319502825195':1544269,'x911319502828298':1544269,'x911319502972054':1544269,'x911319502902044':1544269,'x911319502846498':1544269,'x911319502824305':1544269,
11558
#                 'x911319502826268':1544269,'x911319502785761':1544269,'x911319502956750':1544269,'x911319502825195':1544269,'x911319502828298':1544269,'x911319502972054':1544269,'x911319502902044':1544269,'x911319502846498':1544269,'x911319502824305':1544269,
11560
#                 'x911319502891478':1544269,'x911319502962451':1544269,'x911319502929732':1544269,'x911319502834304':1544269,'x911319502830575':1544269,'x911319502889456':1544269,'x911319502842521':1544269,'x911319502900998':1544269,'x911319502890462':1544269,'x911319502881222':1544269,'x911319503523252':1544269}
11559
#                 'x911319502891478':1544269,'x911319502962451':1544269,'x911319502929732':1544269,'x911319502834304':1544269,'x911319502830575':1544269,'x911319502889456':1544269,'x911319502842521':1544269,'x911319502900998':1544269,'x911319502890462':1544269,'x911319502881222':1544269,'x911319503523252':1544269}
Line 11572... Line 11571...
11572
#        arr.append(k)    
11571
#        arr.append(k)    
11573
#    order_ids=serialNumbersMap.keys()
11572
#    order_ids=serialNumbersMap.keys()
11574
#    for order_id in order_ids:
11573
#    for order_id in order_ids:
11575
#        itemNumbersMap[order_id]=['1']
11574
#        itemNumbersMap[order_id]=['1']
11576
#    add_billing_details_for_groupped_orders(order_ids, invoice_number, itemNumbersMap, serialNumbersMap, {}, 'mp-mmx-admin', '1', 0, False, 'Individual')
11575
#    add_billing_details_for_groupped_orders(order_ids, invoice_number, itemNumbersMap, serialNumbersMap, {}, 'mp-mmx-admin', '1', 0, False, 'Individual')
11577
    
-
 
11578
11576
#from shop2020.clients.LogisticsClient import LogisticsClient
-
 
11577
#pincodes = [302006,263139,781001,834001,380051,380001,110074,400095,560037,125055,122001,700009,400709,462022,700023,400015]
-
 
11578
#logistics_client = LogisticsClient().get_client()
-
 
11579
#for pincode in pincodes:
-
 
11580
#    print pincode, logistics_client.getLogisticsEstimation(26385, str(pincode), 1).providerId
-
 
11581
    transaction_id=[1,2,3]
-
 
11582
    for transaction_id in transaction_id:
-
 
11583
        transaction = get_transaction(transaction_id)      
-
 
11584
        user_client = UserClient().get_client()
-
 
11585
        oa = Attribute()
-
 
11586
        counter = user_client.getCounterByUserId(transaction.customer_id)
-
 
11587
        oa.value = counter.tin
-
 
11588
        address = user_client.getAddressById(counter.address)
-
 
11589
        shipping_refund = 0
-
 
11590
        net_payable = 0
-
 
11591
        for order in transaction.orders:
-
 
11592
            oa.name='tinNumber'
-
 
11593
            oa.orderId = order.id
-
 
11594
    
-
 
11595
            order.customer_name         = address.name
-
 
11596
            order.customer_pincode      = address.pin
-
 
11597
            order.customer_address1     = address.line1
-
 
11598
            order.customer_address2     = address.line2
-
 
11599
            order.customer_city         = address.city
-
 
11600
            order.customer_state        = address.state
-
 
11601
            order.orderType = OrderType.B2B
-
 
11602
            order.logistics_provider_id = 4 #Self Pickup
-
 
11603
            shipping_refund += order.shippingCost     
-
 
11604
            net_payable += order.net_payable_amount
-
 
11605
            order.shippingCost = 0
-
 
11606
        if shipping_refund > 0 and net_payable==0:
-
 
11607
            add_amount_in_wallet(order.customer_id, order.shippingCost, order.transaction_id, WalletReferenceType.REFUND, False, False)
-
 
11608
            payment_client = PaymentClient().get_client()
-
 
11609
            payment_client.
-
 
11610
            payments = payment_client.refundPayment(transaction_id, shipping_refund, False)
-
 
11611
        session.commit()
-
 
11612
11579
11613