Subversion Repositories SmartDukaan

Rev

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

Rev 5573 Rev 5593
Line 2084... Line 2084...
2084
    # COD services are not available everywhere
2084
    # COD services are not available everywhere
2085
    if order.cod:
2085
    if order.cod:
2086
        if not logistics_info.codAllowed:
2086
        if not logistics_info.codAllowed:
2087
            raise TransactionServiceException(2, 'COD service not available')
2087
            raise TransactionServiceException(2, 'COD service not available')
2088
 
2088
 
-
 
2089
    if logistics_info.providerId != order.logistics_provider_id:
-
 
2090
        logistics_info = logistics_client.getLogisticsInfo(address.pin, order.lineitems[0].item_id, type)
-
 
2091
        order.tracking_id = logistics_info.airway_billno
-
 
2092
        order.airwaybill_no = logistics_info.airway_billno
-
 
2093
        order.logistics_provider_id = logistics_info.providerId
-
 
2094
 
2089
    current_time = datetime.datetime.now()
2095
    current_time = datetime.datetime.now()
2090
    logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
2096
    logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
2091
    logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
2097
    logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
2092
 
2098
 
2093
    order.customer_name         = address.name
2099
    order.customer_name         = address.name
Line 2652... Line 2658...
2652
        attribute = Attribute()
2658
        attribute = Attribute()
2653
        attribute.orderId = order.id
2659
        attribute.orderId = order.id
2654
        attribute.name = t_attribute.name
2660
        attribute.name = t_attribute.name
2655
        attribute.value = t_attribute.value
2661
        attribute.value = t_attribute.value
2656
        session.commit()
2662
        session.commit()
2657
        
2663
 
2658
def accept_order_for_item(itemId, quantity, fulfilmentWarehouseId, billingWarehouseId):
2664
def accept_order_for_item(itemId, quantity, fulfilmentWarehouseId, billingWarehouseId):
2659
    catalogClient = CatalogClient().get_client()
2665
    catalogClient = CatalogClient().get_client()
2660
    inventory = catalogClient.getItemInventoryByItemId(itemId)
2666
    inventory = catalogClient.getItemInventoryByItemId(itemId)
2661
    orders = Order.query.filter(Order.warehouse_id == billingWarehouseId).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.expected_shipping_time).all()
2667
    orders = Order.query.filter(Order.warehouse_id == billingWarehouseId).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.expected_shipping_time).all()
2662
    for order in orders:
2668
    for order in orders:
2663
        lineitem = order.limeitems[0]
2669
        lineitem = order.lineitems[0]
2664
        if lineitem.item_id == itemId and lineitem.quantity <= quantity:
2670
        if lineitem.item_id == itemId and lineitem.quantity <= quantity:
2665
            warehouse = catalogClient.getWarehouse(order.fulfilmentWarehouseId)
2671
            warehouse = catalogClient.getWarehouse(order.fulfilmentWarehouseId)
2666
            if not warehouse.billingWarehouseId and warehouse.warehouseType == WarehouseType._VALUES_TO_NAMES[WarehouseType.THIRD_PARTY]:
2672
            if not warehouse.billingWarehouseId and warehouse.warehouseType == WarehouseType._VALUES_TO_NAMES[WarehouseType.THIRD_PARTY]:
2667
                if inventory.availability.has_key(fulfilmentWarehouseId) and inventory.availability[fulfilmentWarehouseId] > inventory.reserved[fulfilmentWarehouseId]:
2673
                if inventory.availability.has_key(fulfilmentWarehouseId) and inventory.availability[fulfilmentWarehouseId] >= inventory.reserved[fulfilmentWarehouseId] + lineitem.quantity:
2668
                    accept_order(order.id)
2674
                    accept_order(order.id)
2669
                    quantity -= lineitem.quantity
2675
                    quantity -= lineitem.quantity
-
 
2676
                    if not quantity:
-
 
2677
                        break
2670
 
2678
 
2671
def close_session():
2679
def close_session():
2672
    if session.is_active:
2680
    if session.is_active:
2673
        print "session is active. closing it."
2681
        print "session is active. closing it."
2674
        session.close()
2682
        session.close()