Subversion Repositories SmartDukaan

Rev

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

Rev 19239 Rev 19356
Line 3443... Line 3443...
3443
                order.statusDescription = "Order Cancelled on customer request"
3443
                order.statusDescription = "Order Cancelled on customer request"
3444
            elif order.previousStatus == OrderStatus.BILLED:
3444
            elif order.previousStatus == OrderStatus.BILLED:
3445
                __create_return_order(order)
3445
                __create_return_order(order)
3446
                order.statusDescription = "Order Cancelled on customer request"
3446
                order.statusDescription = "Order Cancelled on customer request"
3447
                order.received_return_timestamp = datetime.datetime.now()
3447
                order.received_return_timestamp = datetime.datetime.now()
-
 
3448
        
-
 
3449
        if order.transaction.payment_option == capitalFloatPayMethod and order.status in [OrderStatus.COD_VERIFICATION_PENDING, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT, OrderStatus.ACCEPTED, OrderStatus.CANCEL_REQUEST_CONFIRMED]:
-
 
3450
            total_amount = order.total_amount + order.shippingCost - order.gvAmount
-
 
3451
            shipping_id = str(order.id)
-
 
3452
            if order.logisticsTransactionId is not None:
-
 
3453
                shipping_id = order.logisticsTransactionId
-
 
3454
            creditObj = __creditHistoryObj(order.customer_id, 1, order.transaction.id, total_amount, CreditTxnType.BLOCKED_REVERSED, shipping_id)
-
 
3455
            creditTxns = []
-
 
3456
            creditTxns.append(creditObj)
-
 
3457
            try:
-
 
3458
                process_credit_transaction(order.transaction.id, order.customer_id, 1, creditTxns)
-
 
3459
            except:
-
 
3460
                traceback.print_exc()
-
 
3461
                session.rollback()
-
 
3462
                return False  
3448
    else:
3463
    else:
3449
        status_transition = {OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
3464
        status_transition = {OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
3450
                     OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
3465
                     OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
3451
                     OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
3466
                     OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
3452
                     OrderStatus.RTO_LOST_IN_TRANSIT : OrderStatus.RTO_LOST_IN_TRANSIT_REFUNDED,
3467
                     OrderStatus.RTO_LOST_IN_TRANSIT : OrderStatus.RTO_LOST_IN_TRANSIT_REFUNDED,
Line 3545... Line 3560...
3545
                __create_return_order(order)
3560
                __create_return_order(order)
3546
                __create_refund(order)
3561
                __create_refund(order)
3547
                order.statusDescription = "Order Cancelled on customer request"
3562
                order.statusDescription = "Order Cancelled on customer request"
3548
                order.received_return_timestamp = datetime.datetime.now()
3563
                order.received_return_timestamp = datetime.datetime.now()
3549
            
3564
            
3550
            if order.transaction.payment_option == capitalFloatPayMethod:
-
 
3551
                total_amount = order.total_amount + order.shippingCost - order.gvAmount
-
 
3552
                shipping_id = str(order.id)
-
 
3553
                if order.logisticsTransactionId is not None:
-
 
3554
                    shipping_id = order.logisticsTransactionId
-
 
3555
                creditObj = __creditHistoryObj(order.customer_id, 1, order.transaction.id, total_amount, CreditTxnType.BLOCKED_REVERSED, shipping_id)
-
 
3556
                creditTxns = []
-
 
3557
                creditTxns.append(creditObj)
-
 
3558
                try:
-
 
3559
                    process_credit_transaction(order.transaction.id, order.customer_id, 1, creditTxns)
-
 
3560
                except:
-
 
3561
                    traceback.print_exc()
-
 
3562
                    session.rollback()
-
 
3563
                    return False  
-
 
3564
            
-
 
3565
        elif order.status == OrderStatus.PAYMENT_FLAGGED:
3565
        elif order.status == OrderStatus.PAYMENT_FLAGGED:
3566
            __update_inventory_reservation(order)
3566
            __update_inventory_reservation(order)
3567
            order.statusDescription = "Order Cancelled due to payment flagged"
3567
            order.statusDescription = "Order Cancelled due to payment flagged"
-
 
3568
            
-
 
3569
        if order.transaction.payment_option == capitalFloatPayMethod and order.status in [OrderStatus.PAYMENT_FLAGGED, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT, OrderStatus.ACCEPTED, OrderStatus.CANCEL_REQUEST_CONFIRMED]:    
-
 
3570
            total_amount = order.total_amount + order.shippingCost - order.gvAmount
-
 
3571
            shipping_id = str(order.id)
-
 
3572
            if order.logisticsTransactionId is not None:
-
 
3573
                shipping_id = order.logisticsTransactionId
-
 
3574
            creditObj = __creditHistoryObj(order.customer_id, 1, order.transaction.id, total_amount, CreditTxnType.BLOCKED_REVERSED, shipping_id)
-
 
3575
            creditTxns = []
-
 
3576
            creditTxns.append(creditObj)
-
 
3577
            try:
-
 
3578
                process_credit_transaction(order.transaction.id, order.customer_id, 1, creditTxns)
-
 
3579
            except:
-
 
3580
                traceback.print_exc()
-
 
3581
                session.rollback()
-
 
3582
                return False  
3568
 
3583
 
3569
    # For orders that are cancelled after being billed, we need to scan in the scanned out
3584
    # For orders that are cancelled after being billed, we need to scan in the scanned out
3570
    # inventory item and change availability accordingly
3585
    # inventory item and change availability accordingly
3571
    inventoryClient = InventoryClient().get_client()
3586
    inventoryClient = InventoryClient().get_client()
3572
    warehouse = inventoryClient.getWarehouse(order.warehouse_id)
3587
    warehouse = inventoryClient.getWarehouse(order.warehouse_id)