Subversion Repositories SmartDukaan

Rev

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

Rev 9896 Rev 10050
Line 14... Line 14...
14
    ItemInventoryHistory, CurrentInventorySnapshot, VendorItemPricing, \
14
    ItemInventoryHistory, CurrentInventorySnapshot, VendorItemPricing, \
15
    VendorItemMapping, Vendor, MissedInventoryUpdate, BadInventorySnapshot, \
15
    VendorItemMapping, Vendor, MissedInventoryUpdate, BadInventorySnapshot, \
16
    VendorHolidays, ItemAvailabilityCache, \
16
    VendorHolidays, ItemAvailabilityCache, \
17
    CurrentReservationSnapshot, IgnoredInventoryUpdateItems, ItemStockPurchaseParams, \
17
    CurrentReservationSnapshot, IgnoredInventoryUpdateItems, ItemStockPurchaseParams, \
18
    OOSStatus, AmazonInventorySnapshot, StateMaster, HoldInventoryDetail, AmazonFbaInventorySnapshot, \
18
    OOSStatus, AmazonInventorySnapshot, StateMaster, HoldInventoryDetail, AmazonFbaInventorySnapshot, \
19
    SnapdealInventorySnapshot
19
    SnapdealInventorySnapshot, FlipkartInventorySnapshot
20
from shop2020.thriftpy.model.v1.inventory.ttypes import \
20
from shop2020.thriftpy.model.v1.inventory.ttypes import \
21
    InventoryServiceException, HolidayType, InventoryType, WarehouseType
21
    InventoryServiceException, HolidayType, InventoryType, WarehouseType
22
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
22
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
23
from shop2020.thriftpy.purchase.ttypes import PurchaseServiceException
23
from shop2020.thriftpy.purchase.ttypes import PurchaseServiceException
24
from shop2020.utils import EmailAttachmentSender
24
from shop2020.utils import EmailAttachmentSender
Line 1311... Line 1311...
1311
        return 0
1311
        return 0
1312
    return vendoritempricing.nlc
1312
    return vendoritempricing.nlc
1313
 
1313
 
1314
def get_snapdeal_inventory_snapshot():
1314
def get_snapdeal_inventory_snapshot():
1315
    return SnapdealInventorySnapshot.query.all()
1315
    return SnapdealInventorySnapshot.query.all()
-
 
1316
 
1316
def get_held_inventory_map_for_item(itemId, warehouseId):
1317
def get_held_inventory_map_for_item(itemId, warehouseId):
1317
    heldInventoryMap = {}
1318
    heldInventoryMap = {}
1318
    holdInventories = HoldInventoryDetail.query.filter_by(item_id= itemId, warehouse_id = warehouseId).all()
1319
    holdInventories = HoldInventoryDetail.query.filter_by(item_id= itemId, warehouse_id = warehouseId).all()
1319
    for holdInventory in holdInventories:
1320
    for holdInventory in holdInventories:
1320
        heldInventoryMap[holdInventory.source] = holdInventory.held
1321
        heldInventoryMap[holdInventory.source] = holdInventory.held
1321
    return heldInventoryMap 
1322
    return heldInventoryMap 
-
 
1323
 
1322
def get_hold_inventory_details(itemId, warehouseId, source):
1324
def get_hold_inventory_details(itemId, warehouseId, source):
1323
    heldInventoryQuery = HoldInventoryDetail.query
1325
    heldInventoryQuery = HoldInventoryDetail.query
1324
    if itemId:
1326
    if itemId:
1325
        heldInventoryQuery = heldInventoryQuery.filter_by(item_id = itemId)
1327
        heldInventoryQuery = heldInventoryQuery.filter_by(item_id = itemId)
1326
    if warehouseId:
1328
    if warehouseId:
Line 1328... Line 1330...
1328
    if source:
1330
    if source:
1329
        heldInventoryQuery = heldInventoryQuery.filter_by(source = source)
1331
        heldInventoryQuery = heldInventoryQuery.filter_by(source = source)
1330
    holdInventoryDetails = heldInventoryQuery.all()
1332
    holdInventoryDetails = heldInventoryQuery.all()
1331
    return holdInventoryDetails
1333
    return holdInventoryDetails
1332
    
1334
    
-
 
1335
def add_or_update_flipkart_inventory_snapshot(flipkartInventorySnapshot):
-
 
1336
    for snapshot in flipkartInventorySnapshot:
-
 
1337
        flipkart_inventory = FlipkartInventorySnapshot.get_by(item_id = snapshot.item_id)
-
 
1338
        if flipkart_inventory is None:
-
 
1339
            flipkart_inventory = FlipkartInventorySnapshot()
-
 
1340
            flipkart_inventory.item_id = snapshot.item_id
-
 
1341
            flipkart_inventory.availability = snapshot.availability
-
 
1342
            flipkart_inventory.createdOrders = snapshot.createdOrders
-
 
1343
            flipkart_inventory.heldOrders = snapshot.heldOrders
-
 
1344
        else:
-
 
1345
            flipkart_inventory.availability = snapshot.availability
-
 
1346
            flipkart_inventory.createdOrders = snapshot.createdOrders
-
 
1347
            flipkart_inventory.heldOrders = snapshot.heldOrders
-
 
1348
    session.commit()
-
 
1349
       
-
 
1350
def get_flipkart_inventory_snapshot():
-
 
1351
    return FlipkartInventorySnapshot.query.all()     
-
 
1352