Subversion Repositories SmartDukaan

Rev

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

Rev 7645 Rev 7663
Line 2127... Line 2127...
2127
        
2127
        
2128
        to_addr = order.customer_email
2128
        to_addr = order.customer_email
2129
        today = date.today().strftime("%d-%B-%Y (%A)")
2129
        today = date.today().strftime("%d-%B-%Y (%A)")
2130
 
2130
 
2131
        raw_message = '''
2131
        raw_message = '''
2132
        Dear Mr. %(customer_name)s,
2132
        Dear %(customer_name)s,
2133
        
2133
        
2134
        Would like to inform you that we have instructed %(provider_name)s to pick up the material from the below mentioned address on %(date)s. %(provider_name)s pickup request number is %(pickup_request_no)s.'
2134
        Would like to inform you that we have instructed %(provider_name)s to pick up the material from the below mentioned address on %(date)s. %(provider_name)s pickup request number is %(pickup_request_no)s.'
2135
        
2135
        
2136
        Take a printout of the attachment in this mail which contains the delivery address and paste it on the packed parcel. Kindly keep the parcel ready.
2136
        Take a printout of the attachment in this mail which contains the delivery address and paste it on the packed parcel. Kindly keep the parcel ready.
2137
 
2137
 
Line 2276... Line 2276...
2276
                warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)
2276
                warehouseClient.scanForOursExternalSaleReturn(order.id, lineitem.transfer_price)
2277
            if scanFreebie:
2277
            if scanFreebie:
2278
                warehouseClient.scanfreebie(order.id, order.freebieItemId, 0, scanType)
2278
                warehouseClient.scanfreebie(order.id, order.freebieItemId, 0, scanType)
2279
    
2279
    
2280
    session.commit()  
2280
    session.commit()  
2281
    if order.source == 2:
-
 
2282
        if order.new_order_id:
-
 
2283
            reship_order(order.id)
-
 
2284
        else:
-
 
2285
            storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == order.id).filter(StoreOrderDetail.storeId == order.storeId).first()
-
 
2286
            if storeOrderDetail.payStatus not in (StorePaymentStatus.ADV_REFUNDED , StorePaymentStatus.REFUND_INITIATED, \
-
 
2287
                                          StorePaymentStatus.REFUND_REQUESTED, StorePaymentStatus.REFUNDED):
-
 
2288
                refund_order(order.id, "Store", "N/A")
-
 
2289
    return True
2281
    return True
2290
 
2282
 
2291
def validate_doa(order_id, is_valid):
2283
def validate_doa(order_id, is_valid):
2292
    order = get_order(order_id)
2284
    order = get_order(order_id)
2293
    if order.status != OrderStatus.DOA_RECEIVED_PRESTINE:
2285
    if order.status != OrderStatus.DOA_RECEIVED_PRESTINE:
Line 2353... Line 2345...
2353
    Parameters:
2345
    Parameters:
2354
     - orderId
2346
     - orderId
2355
    """
2347
    """
2356
    order = get_order(order_id)
2348
    order = get_order(order_id)
2357
    alreadyReshipped = False
2349
    alreadyReshipped = False
-
 
2350
    
-
 
2351
    #If this order was from store and it was already marked refunded then this order 
-
 
2352
    #should not be reshipped.
-
 
2353
    if order.source == 2:
-
 
2354
        sod = StoreOrderDetail.get_by(orderId = order.id)
-
 
2355
        if sod.payStatus in (StorePaymentStatus.ADV_REFUNDED , StorePaymentStatus.REFUND_INITIATED, \
-
 
2356
                                          StorePaymentStatus.REFUND_REQUESTED, StorePaymentStatus.REFUNDED):
-
 
2357
            raise TransactionServiceException(112, "This order should be refunded")
-
 
2358
    
-
 
2359
    #If this order was from store and a new order Id has already been set then it means that
-
 
2360
    #a new order corresponding to this order has already been shipped.
2358
    if order.source == 2 and order.new_order_id:
2361
    if order.source == 2 and order.new_order_id:
2359
        alreadyReshipped = True
2362
        alreadyReshipped = True
2360
    if order.status == OrderStatus.RTO_RECEIVED_PRESTINE:
2363
    if order.status == OrderStatus.RTO_RECEIVED_PRESTINE:
2361
        order.status = OrderStatus.RTO_RESHIPPED
2364
        order.status = OrderStatus.RTO_RESHIPPED
2362
        order.statusDescription = "Order Reshipped"
2365
        order.statusDescription = "Order Reshipped"
Line 2432... Line 2435...
2432
        order.reship_timestamp = datetime.datetime.now()
2435
        order.reship_timestamp = datetime.datetime.now()
2433
        order.new_order_id = new_order.id
2436
        order.new_order_id = new_order.id
2434
        session.commit()
2437
        session.commit()
2435
        return new_order.id
2438
        return new_order.id
2436
    else:
2439
    else:
-
 
2440
        session.commit()
2437
        return order.new_order_id
2441
        return order.new_order_id
2438
    
2442
    
2439
 
2443
 
2440
def __scan_for_reship_order(order_id, new_order):
2444
def __scan_for_reship_order(order_id, new_order):
2441
    inventoryClient = InventoryClient().get_client()
2445
    inventoryClient = InventoryClient().get_client()
Line 2476... Line 2480...
2476
     - reason
2480
     - reason
2477
    """
2481
    """
2478
    logging.info("Refunding order id: " + str(order_id))
2482
    logging.info("Refunding order id: " + str(order_id))
2479
    order = get_order(order_id)
2483
    order = get_order(order_id)
2480
    
2484
    
-
 
2485
    #if this order is from store and a new order for it has already been reshipped then
-
 
2486
    #this order cannot be refunded.
-
 
2487
    if order.source == 2 and order.new_order_id:
-
 
2488
        raise TransactionServiceException(112, "This order should be marked reship")
-
 
2489
    
2481
    if order.cod:
2490
    if order.cod:
2482
        logging.info("Refunding COD order with status " + str(order.status))
2491
        logging.info("Refunding COD order with status " + str(order.status))
2483
        status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
2492
        status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
2484
                     OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
2493
                     OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
2485
                     OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
2494
                     OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,