Subversion Repositories SmartDukaan

Rev

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

Rev 22632 Rev 22719
Line 318... Line 318...
318
        print e
318
        print e
319
        raise PurchaseServiceException(101, 'Exception while fetching availability of items in our warehouses')
319
        raise PurchaseServiceException(101, 'Exception while fetching availability of items in our warehouses')
320
 
320
 
321
    return availability_map
321
    return availability_map
322
 
322
 
-
 
323
def get_fofo_availability(item_ids):
-
 
324
    #TODO: Amit Should be removed
-
 
325
    returnMap = {}
-
 
326
    if not item_ids:
-
 
327
        return returnMap
-
 
328
    physicalWarehouseIdsForFofo = [7678, 7681]
-
 
329
    fofoWarehouses = Warehouse.query.filter(Warehouse.warehouseType.in_(['OURS', 'THIRD_PARTY'])).filter(Warehouse.warehouseType == 'GOOD').filter(Warehouse.billingWarehouseId.in_(physicalWarehouseIdsForFofo)).all()
-
 
330
    warehouse_ids = []
-
 
331
    for fofoWarehouse in fofoWarehouses:
-
 
332
        warehouse_ids.append(fofoWarehouse.id)
-
 
333
    snapshots = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).filter(CurrentInventorySnapshot.item_id.in_(item_ids)).all()
-
 
334
    for snapshot in snapshots:
-
 
335
        if returnMap.has_key(snapshot.item_id):
-
 
336
            returnMap[snapshot.item_id] += snapshot.availability - snapshot.reserved - snapshot.held
-
 
337
        else:
-
 
338
            returnMap[snapshot.item_id] = snapshot.availability - snapshot.reserved - snapshot.held 
-
 
339
    return returnMap
-
 
340
 
323
'''
341
'''
324
This method returns quantity of a particular item across all warehouses whose ids is provided
342
This method returns quantity of a particular item across all warehouses whose ids is provided
325
if warehouse_ids is null it checks for inventory in all warehouses.
343
if warehouse_ids is null it checks for inventory in all warehouses.
326
'''
344
'''
327
def __get_item_availability(item, warehouse_ids):
345
def __get_item_availability(item, warehouse_ids):
Line 623... Line 641...
623
        print "Unexpected error:", sys.exc_info()[0]
641
        print "Unexpected error:", sys.exc_info()[0]
624
        return False
642
        return False
625
 
643
 
626
#This is not the source as in snapdeal or website, this source is to incorporate different pricing depending upon source id.
644
#This is not the source as in snapdeal or website, this source is to incorporate different pricing depending upon source id.
627
#i.e. if user visiting to our site has specific source he would see pricing on that source basis. Default source is 1.
645
#i.e. if user visiting to our site has specific source he would see pricing on that source basis. Default source is 1.
-
 
646
# Have to add another source id 2 for fofo warehouses
628
def get_item_availability_for_location(item_id, source_id):
647
def get_item_availability_for_location(item_id, source_id):
629
    item_availability = ItemAvailabilityCache.get_by(itemId=item_id, sourceId = source_id)
648
    item_availability = ItemAvailabilityCache.get_by(itemId=item_id, sourceId = source_id)
630
    if item_availability:
649
    if item_availability:
631
        return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, item_availability.totalAvailability, item_availability.weight]
650
        return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, item_availability.totalAvailability, item_availability.weight]
632
        #return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, 0, item_availability.weight]
651
        #return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, 0, item_availability.weight]
Line 743... Line 762...
743
 
762
 
744
 
763
 
745
 
764
 
746
def __update_item_availability_cache(item_id, source_id, item=None):
765
def __update_item_availability_cache(item_id, source_id, item=None):
747
    """
766
    """
-
 
767
    Source 2 is completely hardcoded for fofo which has physical warehouse as 7678 and 7681
-
 
768
    Then how shoud we handle virtual because for both source virtual gonna mark
-
 
769
    """
-
 
770
    """
748
    Determines the warehouse that should be used to fulfil an order for the given item.
771
    Determines the warehouse that should be used to fulfil an order for the given item.
749
    Algorithm explained at https://sites.google.com/a/shop2020.in/virtual-w-h-and-inventory/technical-details
772
    Algorithm explained at https://sites.google.com/a/shop2020.in/virtual-w-h-and-inventory/technical-details
750
 
773
 
751
    It will be ensured that every item has either a preferred vendor specified or at least for one vendor its transfer price should be defined.
774
    It will be ensured that every item has either a preferred vendor specified or at least for one vendor its transfer price should be defined.
752
    This is needed to associate an item with at least one vendor so that in default case when its available no where, we know from where to procure it.
775
    This is needed to associate an item with at least one vendor so that in default case when its available no where, we know from where to procure it.