Subversion Repositories SmartDukaan

Rev

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

Rev 4868 Rev 4873
Line 55... Line 55...
55
PAGE_WIDTH=defaultPageSize[0]
55
PAGE_WIDTH=defaultPageSize[0]
56
 
56
 
57
billedOrdersColorMap = {}
57
billedOrdersColorMap = {}
58
 
58
 
59
ORDER_STATUS_TO_USER_TRUST_LEVEL_DELTA_DICT = {
59
ORDER_STATUS_TO_USER_TRUST_LEVEL_DELTA_DICT = {
60
        OrderStatus.RTO_RESHIPPED     :  3,
60
        OrderStatus.RTO_RESHIPPED    :  3,
61
        OrderStatus.RTO_IN_TRANSIT : -5,
61
        OrderStatus.RTO_IN_TRANSIT   : -5,
62
        OrderStatus.DELIVERY_SUCCESS        :  1,
62
        OrderStatus.DELIVERY_SUCCESS :  1,
63
        OrderStatus.DOA_CERT_INVALID        : -5
63
        OrderStatus.DOA_CERT_INVALID : -5
64
}
64
}
65
 
65
 
66
def get_new_transaction():
66
def get_new_transaction():
67
    transaction = Transaction()
67
    transaction = Transaction()
68
    transaction.createdOn = datetime.datetime.now()
68
    transaction.createdOn = datetime.datetime.now()
Line 1385... Line 1385...
1385
     - reason
1385
     - reason
1386
    """
1386
    """
1387
    logging.info("Refunding order id: " + str(order_id))
1387
    logging.info("Refunding order id: " + str(order_id))
1388
    order = get_order(order_id)
1388
    order = get_order(order_id)
1389
    
1389
    
1390
    
-
 
1391
    
-
 
1392
    if order.cod:
1390
    if order.cod:
1393
        logging.info("Refunding COD order with status " + str(order.status))
1391
        logging.info("Refunding COD order with status " + str(order.status))
1394
        status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
1392
        status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
1395
                     OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
1393
                     OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
1396
                     OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
1394
                     OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
Line 1501... Line 1499...
1501
                order.statusDescription = "Order Cancelled on customer request"
1499
                order.statusDescription = "Order Cancelled on customer request"
1502
        elif order.status == OrderStatus.PAYMENT_FLAGGED:
1500
        elif order.status == OrderStatus.PAYMENT_FLAGGED:
1503
            __update_inventory_reservation(order)
1501
            __update_inventory_reservation(order)
1504
            order.statusDescription = "Order Cancelled due to payment flagged"
1502
            order.statusDescription = "Order Cancelled due to payment flagged"
1505
 
1503
 
-
 
1504
    # For orders that are cancelled after being billed, we need to scan in the scanned out
-
 
1505
    # inventory item and change availability accordingly
-
 
1506
    if order.warehouse_id == 7:
-
 
1507
        if order.status in [OrderStatus.BILLED, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_FROM_WH] or (order.status == OrderStatus.CANCEL_REQUEST_CONFIRMED and order.previousStatus in [OrderStatus.BILLED, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_FROM_WH]):
-
 
1508
            lineitem = order.lineitems[0]
-
 
1509
            warehouseClient = WarehouseClient().get_client()
-
 
1510
            warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, ScanType.SALE_RET, order.id, order.warehouse_id)
-
 
1511
            # Increasing availability as well here
-
 
1512
            catalogClient = CatalogClient().get_client()
-
 
1513
            catalogClient.addInventory(lineitem.item_id, order.warehouse_id, lineitem.quantity)            
-
 
1514
 
1506
    order.status = status_transition[order.status]
1515
    order.status = status_transition[order.status]
1507
    order.refund_timestamp = datetime.datetime.now()
1516
    order.refund_timestamp = datetime.datetime.now()
1508
    order.refunded_by = refunded_by
1517
    order.refunded_by = refunded_by
1509
    order.refund_reason = reason
1518
    order.refund_reason = reason
1510
    
1519
 
1511
    session.commit()
1520
    session.commit()
1512
    return True
1521
    return True
1513
 
1522
 
1514
def __update_inventory_reservation(order):
1523
def __update_inventory_reservation(order):
1515
    '''
1524
    '''