| Line 14... |
Line 14... |
| 14 |
to_t_vendor_item_pricing, to_t_source
|
14 |
to_t_vendor_item_pricing, to_t_source
|
| 15 |
from shop2020.model.v1.catalog.impl.DataService import Item, Warehouse, \
|
15 |
from shop2020.model.v1.catalog.impl.DataService import Item, Warehouse, \
|
| 16 |
ItemInventoryHistory, CurrentInventorySnapshot, ItemInfo, ItemChangeLog, \
|
16 |
ItemInventoryHistory, CurrentInventorySnapshot, ItemInfo, ItemChangeLog, \
|
| 17 |
Category, EntityIDGenerator, VendorItemPricing, VendorItemMapping, Vendor, \
|
17 |
Category, EntityIDGenerator, VendorItemPricing, VendorItemMapping, Vendor, \
|
| 18 |
SimilarItems, ProductNotification, Source, SourceItemPricing, AuthorizationLog, \
|
18 |
SimilarItems, ProductNotification, Source, SourceItemPricing, AuthorizationLog, \
|
| 19 |
MissedInventoryUpdate
|
19 |
MissedInventoryUpdate, VendorItemProcurementDelay
|
| 20 |
from shop2020.thriftpy.model.v1.catalog.ttypes import InventoryServiceException, \
|
20 |
from shop2020.thriftpy.model.v1.catalog.ttypes import InventoryServiceException, \
|
| 21 |
status, ItemShippingInfo
|
21 |
status, ItemShippingInfo
|
| 22 |
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
|
22 |
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
|
| 23 |
from shop2020.utils import EmailAttachmentSender
|
23 |
from shop2020.utils import EmailAttachmentSender
|
| 24 |
from shop2020.utils.EmailAttachmentSender import mail
|
24 |
from shop2020.utils.EmailAttachmentSender import mail
|
| Line 733... |
Line 733... |
| 733 |
else :
|
733 |
else :
|
| 734 |
[logisticsLocation, warehouse_retid, total_availability] = \
|
734 |
[logisticsLocation, warehouse_retid, total_availability] = \
|
| 735 |
__get_warehouse_with_max_availability(warehouse_loc = warehouse_loc, \
|
735 |
__get_warehouse_with_max_availability(warehouse_loc = warehouse_loc, \
|
| 736 |
warehouse_ids = warehouse_ids, item = item)
|
736 |
warehouse_ids = warehouse_ids, item = item)
|
| 737 |
|
737 |
|
| 738 |
if item.expectedDelay is None:
|
- |
|
| 739 |
print 'expectedDelay field for this item was Null. Resetting it to 0'
|
- |
|
| 740 |
item.expectedDelay = 0
|
- |
|
| 741 |
|
- |
|
| 742 |
## FIXME Assign warehouse 5 (9D2) for all the hotspot products.
|
738 |
## FIXME Assign warehouse 5 (9D2) for all the hotspot products.
|
| 743 |
#if warehouse_retid in [warehouse.id for warehouse in get_warehouses_for_vendor(1)]:
|
739 |
#if warehouse_retid in [warehouse.id for warehouse in get_warehouses_for_vendor(1)]:
|
| 744 |
if int(warehouse_retid) in [1,2,3,4,5]:
|
740 |
if int(warehouse_retid) in [1,2,3,4,5]:
|
| 745 |
warehouse_retid = 5
|
741 |
warehouse_retid = 5
|
| 746 |
warehouse = Warehouse.get_by(id=warehouse_retid)
|
742 |
warehouse = Warehouse.get_by(id=warehouse_retid)
|
| 747 |
logisticsLocation = warehouse.logisticsLocation
|
743 |
logisticsLocation = warehouse.logisticsLocation
|
| - |
|
744 |
|
| - |
|
745 |
expectedDelay = item.expectedDelay
|
| - |
|
746 |
if expectedDelay is None:
|
| - |
|
747 |
print 'expectedDelay field for this item was Null. Resetting it to 0'
|
| - |
|
748 |
expectedDelay = 0
|
| - |
|
749 |
else:
|
| - |
|
750 |
expectedDelay = int(item.expectedDelay)
|
| - |
|
751 |
|
| - |
|
752 |
if total_availability <= 0:
|
| - |
|
753 |
expectedDelay = expectedDelay + __get_expected_procurement_delay(item)
|
| 748 |
|
754 |
|
| 749 |
return [logisticsLocation, int(warehouse_retid), total_availability, int(item.expectedDelay)]
|
755 |
return [logisticsLocation, int(warehouse_retid), total_availability, expectedDelay]
|
| 750 |
|
756 |
|
| 751 |
def __get_warehouse_with_max_availability(warehouse_loc, warehouse_ids, item):
|
757 |
def __get_warehouse_with_max_availability(warehouse_loc, warehouse_ids, item):
|
| 752 |
|
758 |
|
| 753 |
warehouse_retid = -1
|
759 |
warehouse_retid = -1
|
| 754 |
max_availability = 0
|
760 |
max_availability = 0
|
| Line 795... |
Line 801... |
| 795 |
availability = 0
|
801 |
availability = 0
|
| 796 |
total_availability = total_availability + availability
|
802 |
total_availability = total_availability + availability
|
| 797 |
return total_availability
|
803 |
return total_availability
|
| 798 |
'''
|
804 |
'''
|
| 799 |
|
805 |
|
| - |
|
806 |
def __get_expected_procurement_delay(item):
|
| - |
|
807 |
procurementDelay = 0
|
| - |
|
808 |
try:
|
| - |
|
809 |
if item.preferredVendor:
|
| - |
|
810 |
delays = VendorItemProcurementDelay.query.filter_by(vendor_id = item.preferredVendor, item_id = item.id).all()
|
| - |
|
811 |
else:
|
| - |
|
812 |
delays = VendorItemProcurementDelay.query.filter_by(item_id = item.id).all()
|
| - |
|
813 |
|
| - |
|
814 |
procurementDelay= min([delay.procurementDelay for delay in delays])
|
| - |
|
815 |
except Exception as e:
|
| - |
|
816 |
print e
|
| - |
|
817 |
return procurementDelay
|
| - |
|
818 |
|
| - |
|
819 |
|
| 800 |
def get_warehouses_for_item(item_id):
|
820 |
def get_warehouses_for_item(item_id):
|
| 801 |
|
821 |
|
| 802 |
if not item_id:
|
822 |
if not item_id:
|
| 803 |
raise InventoryServiceException(101, "bad item_id")
|
823 |
raise InventoryServiceException(101, "bad item_id")
|
| 804 |
item = get_item(item_id)
|
824 |
item = get_item(item_id)
|