Subversion Repositories SmartDukaan

Rev

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

Rev 22720 Rev 22721
Line 49... Line 49...
49
pincodePricingServiceabilityMap = {}
49
pincodePricingServiceabilityMap = {}
50
warehouseMap = {}
50
warehouseMap = {}
51
logisticsLocationWarehouseMap = {}
51
logisticsLocationWarehouseMap = {}
52
 
52
 
53
OOS_CALCULATION_TIME = 23
53
OOS_CALCULATION_TIME = 23
-
 
54
physicalWarehouseIdsForFofo = [7678, 7681]
54
 
55
 
55
last_date = datetime.date.today()
56
last_date = datetime.date.today()
56
adjusted_dates={}
57
adjusted_dates={}
57
 
58
 
58
def initialize(dbname='inventory', db_hostname="localhost"):
59
def initialize(dbname='inventory', db_hostname="localhost"):
Line 319... Line 320...
319
        raise PurchaseServiceException(101, 'Exception while fetching availability of items in our warehouses')
320
        raise PurchaseServiceException(101, 'Exception while fetching availability of items in our warehouses')
320
 
321
 
321
    return availability_map
322
    return availability_map
322
 
323
 
323
def get_fofo_availability(item_ids):
324
def get_fofo_availability(item_ids):
324
    #TODO: Amit Should be removed
325
    #TODO: Amit Should be removed physicalWarehouseIdsForFofo
325
    returnMap = {}
326
    returnMap = {}
326
    if not item_ids:
327
    if not item_ids:
327
        return returnMap
328
        return returnMap
328
    physicalWarehouseIdsForFofo = [7678, 7681]
-
 
329
    fofoWarehouses = Warehouse.query.filter(Warehouse.warehouseType.in_(['OURS', 'THIRD_PARTY'])).filter(Warehouse.inventoryType == 'GOOD').filter(Warehouse.billingWarehouseId.in_(physicalWarehouseIdsForFofo)).all()
329
    fofoWarehouses = Warehouse.query.filter(Warehouse.warehouseType.in_(['OURS', 'THIRD_PARTY'])).filter(Warehouse.inventoryType == 'GOOD').filter(Warehouse.billingWarehouseId.in_(physicalWarehouseIdsForFofo)).all()
330
    warehouse_ids = []
330
    warehouse_ids = []
331
    for fofoWarehouse in fofoWarehouses:
331
    for fofoWarehouse in fofoWarehouses:
332
        warehouse_ids.append(fofoWarehouse.id)
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()
333
    snapshots = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).filter(CurrentInventorySnapshot.item_id.in_(item_ids)).all()
Line 336... Line 336...
336
            returnMap[snapshot.item_id] += snapshot.availability - snapshot.reserved - snapshot.held
336
            returnMap[snapshot.item_id] += snapshot.availability - snapshot.reserved - snapshot.held
337
        else:
337
        else:
338
            returnMap[snapshot.item_id] = snapshot.availability - snapshot.reserved - snapshot.held 
338
            returnMap[snapshot.item_id] = snapshot.availability - snapshot.reserved - snapshot.held 
339
    return returnMap
339
    return returnMap
340
 
340
 
-
 
341
def get_fofo_fulfilment_warehouse_map(itemIds):
-
 
342
    returnMap = {}
-
 
343
    fofoWarehouses = Warehouse.query.filter(Warehouse.warehouseType.in_(['OURS', 'THIRD_PARTY'])).filter(Warehouse.inventoryType == 'GOOD').filter(Warehouse.billingWarehouseId.in_(physicalWarehouseIdsForFofo)).all()
-
 
344
    warehouse_ids = []
-
 
345
    for fofoWarehouse in fofoWarehouses:
-
 
346
        warehouse_ids.append(fofoWarehouse.id)
-
 
347
    snapshots = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).filter(CurrentInventorySnapshot.item_id.in_(itemIds)).all()
-
 
348
    for snapshot in snapshots:
-
 
349
        availability = snapshot.availability - snapshot.reserved - snapshot.held
-
 
350
        if availability > 0:
-
 
351
            if not returnMap.has_key(snapshot.item_id):
-
 
352
                returnMap[snapshot.item_id] = to_t_warehouse(snapshot.warehouse)
-
 
353
    return returnMap 
-
 
354
            
-
 
355
        
-
 
356
 
341
'''
357
'''
342
This method returns quantity of a particular item across all warehouses whose ids is provided
358
This method returns quantity of a particular item across all warehouses whose ids is provided
343
if warehouse_ids is null it checks for inventory in all warehouses.
359
if warehouse_ids is null it checks for inventory in all warehouses.
344
'''
360
'''
345
def __get_item_availability(item, warehouse_ids):
361
def __get_item_availability(item, warehouse_ids):