Subversion Repositories SmartDukaan

Rev

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

Rev 6864 Rev 6870
Line 2796... Line 2796...
2796
    try:
2796
    try:
2797
        warehouse = inventoryClient.getWarehouse(warehouse_id)
2797
        warehouse = inventoryClient.getWarehouse(warehouse_id)
2798
    except:
2798
    except:
2799
        raise TransactionServiceException(119, "No warehouse with id" + str(warehouse_id))
2799
        raise TransactionServiceException(119, "No warehouse with id" + str(warehouse_id))
2800
 
2800
 
2801
    if warehouse.billingWarehouseId is None:
2801
    if not warehouse.billingWarehouseId:
2802
        raise TransactionServiceException(119, "Shifting of warehouse allowed to warehouse with billing support only")
2802
        raise TransactionServiceException(119, "Shifting of warehouse allowed to warehouse with billing support only")
2803
 
2803
 
2804
    # If One gives a billing warehouse for warehouse shift, we should assign order to the GOOD warehouse
2804
    # If One gives a billing warehouse for warehouse shift, we should assign order to the GOOD warehouse
2805
    # present within it with maximum availability
2805
    # present within it with maximum availability
2806
    if warehouse.id == warehouse.billingWarehouseId:
2806
    if warehouse.id == warehouse.billingWarehouseId:
Line 3143... Line 3143...
3143
def move_orders_to_correct_warehouse():
3143
def move_orders_to_correct_warehouse():
3144
    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()
3144
    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()
3145
    logistics_client = LogisticsClient().get_client()
3145
    logistics_client = LogisticsClient().get_client()
3146
    for order in orders:
3146
    for order in orders:
3147
        lineitem = order.lineitems[0]
3147
        lineitem = order.lineitems[0]
3148
        logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, lineitem.item_id, order.cod, PickUpType.COURIER) #TODO: We should be able to pass another flag to suggest ignoring the inventory situation.
3148
        logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, lineitem.item_id, order.cod, PickUpType.COURIER)
3149
        if order.fulfilmentWarehouseId != logistics_info.fulfilmentWarehouseId:
3149
        if order.fulfilmentWarehouseId != logistics_info.fulfilmentWarehouseId:
-
 
3150
            try:
3150
            print "++++" + str(order.id) + "=" + str(order.fulfilmentWarehouseId) + "->"+ str(logistics_info.fulfilmentWarehouseId)
3151
                print "++++" + str(order.id) + "=" + str(order.fulfilmentWarehouseId) + "->"+ str(logistics_info.fulfilmentWarehouseId)
3151
            change_warehouse(order.id, logistics_info.fulfilmentWarehouseId)
3152
                change_warehouse(order.id, logistics_info.fulfilmentWarehouseId)
-
 
3153
            except:
-
 
3154
                print "++++" + str(order.id)
3152
    
3155
    
3153
def get_slipped_sipping_date_orders():
3156
def get_slipped_sipping_date_orders():
3154
    return Order.query.filter(Order.status.in_(tuple([OrderStatus.COD_VERIFICATION_PENDING, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.ACCEPTED, OrderStatus.BILLED]))).filter(Order.promised_shipping_time <= datetime.datetime.now()).order_by(Order.promised_shipping_time).all()
3157
    return Order.query.filter(Order.status.in_(tuple([OrderStatus.COD_VERIFICATION_PENDING, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.ACCEPTED, OrderStatus.BILLED]))).filter(Order.promised_shipping_time <= datetime.datetime.now()).order_by(Order.promised_shipping_time).all()
3155
    
3158
    
3156
def get_cancelled_orders(cancelDateFrom, cancelDateTo):
3159
def get_cancelled_orders(cancelDateFrom, cancelDateTo):