Subversion Repositories SmartDukaan

Rev

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

Rev 6467 Rev 6484
Line 235... Line 235...
235
        current_inventory_snapshot = query.one()
235
        current_inventory_snapshot = query.one()
236
        return current_inventory_snapshot.availability - current_inventory_snapshot.reserved
236
        return current_inventory_snapshot.availability - current_inventory_snapshot.reserved
237
    except:
237
    except:
238
        return 0
238
        return 0
239
 
239
 
-
 
240
def get_item_availability_for_our_warehouses(item_ids):
-
 
241
    warehouses = Warehouse.query.filter_by(warehouseType = 'OURS', inventoryType = 'GOOD').all()
-
 
242
    warehouse_ids = []
-
 
243
    for warehouse in warehouses :
-
 
244
        warehouse_ids.append(warehouse.id)
-
 
245
    
-
 
246
    availability_map = dict()
-
 
247
    
-
 
248
    try :
-
 
249
        for item_id in item_ids :
-
 
250
            total_availability = 0
-
 
251
            for current_inventory_snapshot in CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).filter_by(item_id = item_id).all():
-
 
252
                total_availability += current_inventory_snapshot.availability
-
 
253
            if total_availability >0:
-
 
254
                availability_map[item_id] = total_availability
-
 
255
    except Exception as e:
-
 
256
        print e
-
 
257
        raise PurchaseServiceException(101, 'Exception while fetching availability of items in our warehouses')
-
 
258
 
-
 
259
    return availability_map
-
 
260
 
240
'''
261
'''
241
This method returns quantity of a particular item across all warehouses whose ids is provided
262
This method returns quantity of a particular item across all warehouses whose ids is provided
242
if warehouse_ids is null it checks for inventory in all warehouses.
263
if warehouse_ids is null it checks for inventory in all warehouses.
243
'''
264
'''
244
def __get_item_availability(item, warehouse_ids):
265
def __get_item_availability(item, warehouse_ids):