| Line 397... |
Line 397... |
| 397 |
def __send_alert_for_negative_availability(item, availability, warehouse):
|
397 |
def __send_alert_for_negative_availability(item, availability, warehouse):
|
| 398 |
itemName = " ".join([str(item.id), str(item.brand), str(item.model_name), str(item.model_number), str(item.color)])
|
398 |
itemName = " ".join([str(item.id), str(item.brand), str(item.model_name), str(item.model_number), str(item.color)])
|
| 399 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', 'mandeep.dhir@shop2020.in', 'Negative availability ' + str(availability) + ' for Item id: ' + itemName + ' warehouse id: ' + str(warehouse.id), None)
|
399 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', 'mandeep.dhir@shop2020.in', 'Negative availability ' + str(availability) + ' for Item id: ' + itemName + ' warehouse id: ' + str(warehouse.id), None)
|
| 400 |
|
400 |
|
| 401 |
def __send_mail_for_missing_key(item_key, quantity, warehouse_id):
|
401 |
def __send_mail_for_missing_key(item_key, quantity, warehouse_id):
|
| 402 |
if not MissedInventoryUpdate.get_by(itemKey = item_key, isIgnored = 1):
|
402 |
missedInventoryUpdate = MissedInventoryUpdate.get_by(itemKey = item_key, warehouseId = warehouse_id)
|
| 403 |
# One email per product key mismatch
|
403 |
# One email per product key mismatch
|
| 404 |
if not MissedInventoryUpdate.get_by(itemKey = item_key):
|
404 |
if not missedInventoryUpdate:
|
| 405 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', ['mandeep.dhir@shop2020.in', 'chaitnaya.vats@shop2020.in'], 'Skipped inventory update for ' + item_key + ' quantity ' + str(quantity) + ' warehouse id: ' + str(warehouse_id), None)
|
405 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', ['mandeep.dhir@shop2020.in', 'chaitnaya.vats@shop2020.in'], 'Skipped inventory update for ' + item_key + ' quantity ' + str(quantity) + ' warehouse id: ' + str(warehouse_id), None)
|
| 406 |
missedInventoryUpdate = MissedInventoryUpdate()
|
406 |
missedInventoryUpdate = MissedInventoryUpdate()
|
| 407 |
missedInventoryUpdate.itemKey = item_key
|
407 |
missedInventoryUpdate.itemKey = item_key
|
| 408 |
missedInventoryUpdate.quantity = quantity
|
408 |
missedInventoryUpdate.quantity = quantity
|
| 409 |
missedInventoryUpdate.isIgnored = 0
|
409 |
missedInventoryUpdate.isIgnored = 1
|
| 410 |
missedInventoryUpdate.timestamp = datetime.datetime.now()
|
410 |
missedInventoryUpdate.timestamp = datetime.datetime.now()
|
| 411 |
missedInventoryUpdate.warehouseId = warehouse_id
|
411 |
missedInventoryUpdate.warehouseId = warehouse_id
|
| 412 |
session.commit()
|
412 |
session.commit()
|
| - |
|
413 |
else:
|
| - |
|
414 |
missedInventoryUpdate.quantity += quantity
|
| - |
|
415 |
session.commit()
|
| 413 |
|
416 |
|
| 414 |
def add_inventory(itemId, warehouseId, quantity):
|
417 |
def add_inventory(itemId, warehouseId, quantity):
|
| 415 |
current_inventory_snapshot = CurrentInventorySnapshot.get_by(item_id=itemId, warehouse_id=warehouseId)
|
418 |
current_inventory_snapshot = CurrentInventorySnapshot.get_by(item_id=itemId, warehouse_id=warehouseId)
|
| 416 |
if not current_inventory_snapshot:
|
419 |
if not current_inventory_snapshot:
|
| 417 |
current_inventory_snapshot = CurrentInventorySnapshot()
|
420 |
current_inventory_snapshot = CurrentInventorySnapshot()
|
| Line 714... |
Line 717... |
| 714 |
|
717 |
|
| 715 |
#If preference is not sticky then this order should be fulfilled from preferred WH if inventory available
|
718 |
#If preference is not sticky then this order should be fulfilled from preferred WH if inventory available
|
| 716 |
#otherwise we should check for its availability elsewhere and fulfil this order from there, but if it is not available anywhere
|
719 |
#otherwise we should check for its availability elsewhere and fulfil this order from there, but if it is not available anywhere
|
| 717 |
#then we should fulfil this order from its default warehouse.
|
720 |
#then we should fulfil this order from its default warehouse.
|
| 718 |
|
721 |
|
| 719 |
elif (not item.isWarehousePreferenceSticky and item.preferredWarehouse is not None) :
|
722 |
elif (not item.isWarehousePreferenceSticky and item.preferredWarehouse is not None):
|
| 720 |
try:
|
723 |
try:
|
| 721 |
current_inventory_snapshot = CurrentInventorySnapshot.query.filter_by(warehouse_id = item.preferredWarehouse, item_id = item_id).one()
|
724 |
current_inventory_snapshot = CurrentInventorySnapshot.query.filter_by(warehouse_id = item.preferredWarehouse, item_id = item_id).one()
|
| 722 |
availability = current_inventory_snapshot.availibility - current_inventory_snapshot.reserved
|
725 |
availability = current_inventory_snapshot.availibility - current_inventory_snapshot.reserved
|
| 723 |
except Exception as e:
|
726 |
except Exception as e:
|
| 724 |
print e
|
727 |
print e
|
| Line 1177... |
Line 1180... |
| 1177 |
except:
|
1180 |
except:
|
| 1178 |
ds_vendorItemMapping = VendorItemMapping()
|
1181 |
ds_vendorItemMapping = VendorItemMapping()
|
| 1179 |
ds_vendorItemMapping.vendor = vendor
|
1182 |
ds_vendorItemMapping.vendor = vendor
|
| 1180 |
ds_vendorItemMapping.item = item
|
1183 |
ds_vendorItemMapping.item = item
|
| 1181 |
ds_vendorItemMapping.item_key = vendorItemMapping.itemKey
|
1184 |
ds_vendorItemMapping.item_key = vendorItemMapping.itemKey
|
| - |
|
1185 |
|
| - |
|
1186 |
session.commit()
|
| 1182 |
|
1187 |
|
| - |
|
1188 |
# Marking the missed inventory as not ignored as the catalog dashboard user has updated their key
|
| - |
|
1189 |
for missedInventoryUpdate in MissedInventoryUpdate.query.filter_by(itemKey = vendorItemMapping.itemKey).all():
|
| - |
|
1190 |
missedInventoryUpdate.isIgnored = 0
|
| 1183 |
session.commit()
|
1191 |
session.commit()
|
| - |
|
1192 |
|
| 1184 |
return
|
1193 |
return
|
| 1185 |
|
1194 |
|
| 1186 |
def validate_item_prices(item):
|
1195 |
def validate_item_prices(item):
|
| 1187 |
if item.mrp == None or item.sellingPrice == None or item.mrp == "" or item.sellingPrice == "":
|
1196 |
if item.mrp == None or item.sellingPrice == None or item.mrp == "" or item.sellingPrice == "":
|
| 1188 |
return
|
1197 |
return
|
| Line 1673... |
Line 1682... |
| 1673 |
def __send_mail_for_oos_item(item):
|
1682 |
def __send_mail_for_oos_item(item):
|
| 1674 |
try:
|
1683 |
try:
|
| 1675 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', ['abhishek.mathur@shop2020.in', 'chaitnaya.vats@shop2020.in'], "Item is out of stock. ID: " + str(item.id) + " " + str(item.brand) + " " + str(item.model_name) + " " + str(item.model_number)+ " " + str(item.color), None)
|
1684 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', ['abhishek.mathur@shop2020.in', 'chaitnaya.vats@shop2020.in'], "Item is out of stock. ID: " + str(item.id) + " " + str(item.brand) + " " + str(item.model_name) + " " + str(item.model_number)+ " " + str(item.color), None)
|
| 1676 |
except Exception as e:
|
1685 |
except Exception as e:
|
| 1677 |
print e
|
1686 |
print e
|
| - |
|
1687 |
|
| - |
|
1688 |
def mark_missed_inventory_updates_as_processed(itemKey, warehouseId):
|
| - |
|
1689 |
MissedInventoryUpdate.query.filter_by(itemKey = itemKey, warehouseId = warehouseId).delete()
|
| - |
|
1690 |
session.commit()
|
| - |
|
1691 |
|
| - |
|
1692 |
def get_item_keys_to_be_processed(warehouseId):
|
| - |
|
1693 |
return [i.itemKey for i in MissedInventoryUpdate.query.filter_by(warehouseId = warehouseId, isIgnored = 0)]
|
| - |
|
1694 |
|
| - |
|
1695 |
def reset_availability(itemKey, vendorId, quantity, warehouseId):
|
| - |
|
1696 |
vendorItemMapping = VendorItemMapping.get_by(vendor_id = vendorId, item_key = itemKey)
|
| - |
|
1697 |
if vendorItemMapping:
|
| - |
|
1698 |
itemId = vendorItemMapping.item_id
|
| - |
|
1699 |
currentInventorySnapshot = CurrentInventorySnapshot.get_by(item_id = itemId, warehouse_id = warehouseId)
|
| - |
|
1700 |
if currentInventorySnapshot:
|
| - |
|
1701 |
currentInventorySnapshot.availibility = quantity
|
| - |
|
1702 |
else:
|
| - |
|
1703 |
add_inventory(itemId, warehouseId, quantity)
|
| - |
|
1704 |
else:
|
| - |
|
1705 |
raise InventoryServiceException(101, 'VendorMapping not found for: ' + itemKey)
|
| - |
|
1706 |
session.commit()
|