| Line 24... |
Line 24... |
| 24 |
import sys
|
24 |
import sys
|
| 25 |
import threading
|
25 |
import threading
|
| 26 |
from shop2020.clients.CatalogClient import CatalogClient
|
26 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 27 |
from shop2020.utils.Utils import to_py_date
|
27 |
from shop2020.utils.Utils import to_py_date
|
| 28 |
|
28 |
|
| 29 |
to_addresses = ["cnc.center@shop2020.in", "ashutosh.saxena@shop2020.in"]
|
29 |
to_addresses = ["ashutosh.saxena@shop2020.in", "abhishek.mathur@shop2020.in", "chaitnaya.vats@shop2020.in"]
|
| 30 |
from_user = "cnc.center@shop2020.in"
|
30 |
mail_user = "cnc.center@shop2020.in"
|
| 31 |
from_pwd = "5h0p2o2o"
|
31 |
mail_password = "5h0p2o2o"
|
| 32 |
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
|
32 |
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
|
| 33 |
193 : [5839] }
|
33 |
193 : [5839] }
|
| 34 |
|
34 |
|
| 35 |
def initialize(dbname='inventory', db_hostname="localhost"):
|
35 |
def initialize(dbname='inventory', db_hostname="localhost"):
|
| 36 |
DataService.initialize(dbname, db_hostname)
|
36 |
DataService.initialize(dbname, db_hostname)
|
| Line 149... |
Line 149... |
| 149 |
for item_id in item_ids:
|
149 |
for item_id in item_ids:
|
| 150 |
clear_item_availability_cache(item_id)
|
150 |
clear_item_availability_cache(item_id)
|
| 151 |
|
151 |
|
| 152 |
def __send_alert_for_negative_reserved(item, reserved, warehouse):
|
152 |
def __send_alert_for_negative_reserved(item, reserved, warehouse):
|
| 153 |
itemName = " ".join([str(item.id), str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
153 |
itemName = " ".join([str(item.id), str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
| 154 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', 'amar.kumar@shop2020.in', 'Negative reserved: ' + str(reserved) + ' for Item Id: ' + itemName + ' warehouse id: ' + str(warehouse.id), None)
|
154 |
EmailAttachmentSender.mail(mail_user, mail_password, 'amar.kumar@shop2020.in', 'Negative reserved: ' + str(reserved) + ' for Item Id: ' + itemName + ' warehouse id: ' + str(warehouse.id), None)
|
| 155 |
|
155 |
|
| 156 |
def __send_alert_for_negative_availability(item, availability, warehouse):
|
156 |
def __send_alert_for_negative_availability(item, availability, warehouse):
|
| 157 |
itemName = " ".join([str(item.id), str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
157 |
itemName = " ".join([str(item.id), str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
| 158 |
# EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', 'amar.kumar@shop2020.in', 'Negative availability ' + str(availability) + ' for Item id: ' + itemName + ' warehouse id: ' + str(warehouse.id), None)
|
158 |
# EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', 'amar.kumar@shop2020.in', 'Negative availability ' + str(availability) + ' for Item id: ' + itemName + ' warehouse id: ' + str(warehouse.id), None)
|
| 159 |
|
159 |
|
| 160 |
def __send_mail_for_missing_key(item_key, quantity, warehouse_id):
|
160 |
def __send_mail_for_missing_key(item_key, quantity, warehouse_id):
|
| 161 |
missedInventoryUpdate = MissedInventoryUpdate.get_by(itemKey = item_key, warehouseId = warehouse_id)
|
161 |
missedInventoryUpdate = MissedInventoryUpdate.get_by(itemKey = item_key, warehouseId = warehouse_id)
|
| 162 |
# One email per product key mismatch
|
162 |
# One email per product key mismatch
|
| 163 |
if not missedInventoryUpdate:
|
163 |
if not missedInventoryUpdate:
|
| 164 |
EmailAttachmentSender.mail('cnc.center@shop2020.in', '5h0p2o2o', ['mandeep.dhir@shop2020.in', 'chaitnaya.vats@shop2020.in', 'asghar.bilgrami@shop2020.in', 'amar.kumar@shop2020.in'], 'Skipped inventory update for ' + item_key + ' quantity ' + str(quantity) + ' warehouse id: ' + str(warehouse_id), None)
|
164 |
EmailAttachmentSender.mail(mail_user, mail_password, ['chaitnaya.vats@shop2020.in', 'asghar.bilgrami@shop2020.in', 'amar.kumar@shop2020.in'], 'Skipped inventory update for ' + item_key + ' quantity ' + str(quantity) + ' warehouse id: ' + str(warehouse_id), None)
|
| 165 |
missedInventoryUpdate = MissedInventoryUpdate()
|
165 |
missedInventoryUpdate = MissedInventoryUpdate()
|
| 166 |
missedInventoryUpdate.itemKey = item_key
|
166 |
missedInventoryUpdate.itemKey = item_key
|
| 167 |
missedInventoryUpdate.quantity = quantity
|
167 |
missedInventoryUpdate.quantity = quantity
|
| 168 |
missedInventoryUpdate.isIgnored = 1
|
168 |
missedInventoryUpdate.isIgnored = 1
|
| 169 |
missedInventoryUpdate.timestamp = datetime.datetime.now()
|
169 |
missedInventoryUpdate.timestamp = datetime.datetime.now()
|
| Line 785... |
Line 785... |
| 785 |
session.commit()
|
785 |
session.commit()
|
| 786 |
|
786 |
|
| 787 |
|
787 |
|
| 788 |
def __send_mail(subject, message):
|
788 |
def __send_mail(subject, message):
|
| 789 |
try:
|
789 |
try:
|
| 790 |
thread = threading.Thread(target=partial(mail, from_user, from_pwd, to_addresses, subject, message))
|
790 |
thread = threading.Thread(target=partial(mail, mail_user, mail_password, to_addresses, subject, message))
|
| 791 |
thread.start()
|
791 |
thread.start()
|
| 792 |
except Exception as ex:
|
792 |
except Exception as ex:
|
| 793 |
print ex
|
793 |
print ex
|
| 794 |
|
794 |
|
| 795 |
def get_shipping_locations():
|
795 |
def get_shipping_locations():
|