Subversion Repositories SmartDukaan

Rev

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

Rev 10687 Rev 11173
Line 1270... Line 1270...
1270
    session.commit()
1270
    session.commit()
1271
    #**Update item availability cache**#
1271
    #**Update item availability cache**#
1272
    clear_item_availability_cache(itemId)
1272
    clear_item_availability_cache(itemId)
1273
    
1273
    
1274
def add_or_update_amazon_fba_inventory(amazonfbainventorysnapshot):
1274
def add_or_update_amazon_fba_inventory(amazonfbainventorysnapshot):
1275
    inventory = AmazonFbaInventorySnapshot.get_by(item_id = amazonfbainventorysnapshot.item_id)
1275
    inventory = AmazonFbaInventorySnapshot.query.filter_by(item_id = amazonfbainventorysnapshot.item_id,location=amazonfbainventorysnapshot.location).first()
1276
    if inventory is None:
1276
    if inventory is None:
1277
        amazon_fba_inventory = AmazonFbaInventorySnapshot()
1277
        amazon_fba_inventory = AmazonFbaInventorySnapshot()
1278
        amazon_fba_inventory.item_id = amazonfbainventorysnapshot.item_id
1278
        amazon_fba_inventory.item_id = amazonfbainventorysnapshot.item_id
1279
        amazon_fba_inventory.availability = amazonfbainventorysnapshot.availability
1279
        amazon_fba_inventory.availability = amazonfbainventorysnapshot.availability
-
 
1280
        amazon_fba_inventory.location = amazonfbainventorysnapshot.location
-
 
1281
        amazon_fba_inventory.reserved = amazonfbainventorysnapshot.reserved
-
 
1282
        amazon_fba_inventory.inbound = amazonfbainventorysnapshot.inbound
-
 
1283
        amazon_fba_inventory.unfulfillable = amazonfbainventorysnapshot.unfulfillable
-
 
1284
        
1280
    else:
1285
    else:
-
 
1286
        print 'updating'
1281
        inventory.availability = amazonfbainventorysnapshot.availability
1287
        inventory.availability = amazonfbainventorysnapshot.availability
1282
    session.commit()
1288
        inventory.location = amazonfbainventorysnapshot.location
-
 
1289
        inventory.reserved = amazonfbainventorysnapshot.reserved
-
 
1290
        inventory.inbound = amazonfbainventorysnapshot.inbound
-
 
1291
        inventory.unfulfillable = amazonfbainventorysnapshot.unfulfillable
1283
 
1292
 
1284
 
1293
 
1285
def get_amazon_fba_inventory(itemId):
1294
def get_amazon_fba_inventory(itemId):
1286
    row = AmazonFbaInventorySnapshot.get_by(item_id=itemId)
1295
    return AmazonFbaInventorySnapshot.query.filter_by(item_id = itemId)
1287
    if row is None:
-
 
1288
        return 0
-
 
1289
    else:
-
 
1290
        return row.availability
-
 
1291
 
1296
 
1292
def get_all_amazon_fba_inventory():
1297
def get_all_amazon_fba_inventory():
1293
    return AmazonFbaInventorySnapshot.query.all() 
1298
    return AmazonFbaInventorySnapshot.query.all() 
1294
 
1299
 
1295
def get_oursgood_warehouseids_for_location(state_id):
1300
def get_oursgood_warehouseids_for_location(state_id):