Subversion Repositories SmartDukaan

Rev

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

Rev 4316 Rev 4324
Line 1519... Line 1519...
1519
                quantity = quantity + item_wise_risky_orders_count[lineitem.item_id]
1519
                quantity = quantity + item_wise_risky_orders_count[lineitem.item_id]
1520
            
1520
            
1521
            item_wise_risky_orders_count[lineitem.item_id] = quantity
1521
            item_wise_risky_orders_count[lineitem.item_id] = quantity
1522
    return item_wise_risky_orders_count
1522
    return item_wise_risky_orders_count
1523
 
1523
 
-
 
1524
def update_shipment_address(order_id, address_id):
-
 
1525
    """
-
 
1526
    Updates shipment address of an order. Delivery and shipping date estimates
-
 
1527
    etc. are also updated here.
-
 
1528
 
-
 
1529
    Throws TransactionServiceException in case address change is not
-
 
1530
    possible due to certain reasons such as new pincode in address is
-
 
1531
    not serviceable etc.
-
 
1532
    
-
 
1533
    Parameters:
-
 
1534
     - orderId
-
 
1535
     - addressId
-
 
1536
    """
-
 
1537
    user_client = UserClient().get_client()
-
 
1538
    address     = user_client.getAddressById(address_id)
-
 
1539
    order       = get_order(order_id)
-
 
1540
 
-
 
1541
    logistics_client = LogisticsClient().get_client()
-
 
1542
    logistics_info = logistics_client.getLogisticsEstimation(order.lineitems[0].item_id, address.pin)
-
 
1543
 
-
 
1544
    # Check for new estimate. Raise exception if new address is not serviceable
-
 
1545
    if logistics_info.deliveryTime == -1:
-
 
1546
        raise TransactionServiceException(1, 'Location not serviceable')
-
 
1547
 
-
 
1548
    # COD services are not available everywhere
-
 
1549
    if order.cod:
-
 
1550
        if not logistics_client.isCodAllowed(address.pin):
-
 
1551
            raise TransactionServiceException(2, 'COD service not available')
-
 
1552
 
-
 
1553
    current_time = datetime.datetime.now()
-
 
1554
    logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
-
 
1555
    logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
-
 
1556
 
-
 
1557
    order.customer_name         = address.name
-
 
1558
    order.customer_pincode      = address.pin
-
 
1559
    order.customer_address1     = address.line1
-
 
1560
    order.customer_address2     = address.line2
-
 
1561
    order.customer_city         = address.city
-
 
1562
    order.customer_state        = address.state
-
 
1563
    order.customer_mobilenumber = address.phone
-
 
1564
 
-
 
1565
    if order.cod:
-
 
1566
        order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
-
 
1567
    else:
-
 
1568
        order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
-
 
1569
 
-
 
1570
    order.expected_delivery_time = current_time + datetime.timedelta(days=logistics_info.deliveryTime)
-
 
1571
    order.promised_shipping_time = order.expected_shipping_time
-
 
1572
    order.promised_delivery_time = order.expected_delivery_time 
-
 
1573
 
-
 
1574
    session.commit()
-
 
1575
 
1524
def mark_order_cancellation_request_received(orderId):
1576
def mark_order_cancellation_request_received(orderId):
1525
    """
1577
    """
1526
    Mark order as cancellation request received. If customer sends request of cancellation of
1578
    Mark order as cancellation request received. If customer sends request of cancellation of
1527
    a particular order, this method will be called. It will just change status of the order
1579
    a particular order, this method will be called. It will just change status of the order
1528
    depending on its current status. It also records the previous status, so that we can move
1580
    depending on its current status. It also records the previous status, so that we can move