| Line 84... |
Line 84... |
| 84 |
t_item_shipping_info = ItemShippingInfo()
|
84 |
t_item_shipping_info = ItemShippingInfo()
|
| 85 |
try:
|
85 |
try:
|
| 86 |
item = get_item(item_id)
|
86 |
item = get_item(item_id)
|
| 87 |
t_item_shipping_info.isRisky = item.risky
|
87 |
t_item_shipping_info.isRisky = item.risky
|
| 88 |
warehouse_ids = None
|
88 |
warehouse_ids = None
|
| 89 |
if item.isWarehousePreferenceSticky :
|
89 |
if item.isWarehousePreferenceSticky:
|
| 90 |
warehouse_ids = [item.preferredWarehouse]
|
90 |
warehouse_ids = [w.id for w in Warehouse.query.filter_by(shippingWarehouseId = item.preferredWarehouse, inventoryType = InventoryType._VALUES_TO_NAMES[InventoryType.GOOD]).all()]
|
| 91 |
availability = __get_item_availability(item, warehouse_ids)
|
91 |
availability = __get_item_availability(item, warehouse_ids)
|
| 92 |
if item.risky and availability <= 0 and item.status == status.ACTIVE:
|
92 |
if item.risky and availability <= 0 and item.status == status.ACTIVE:
|
| 93 |
add_status_change_log(item, status.PAUSED_BY_RISK)
|
93 |
add_status_change_log(item, status.PAUSED_BY_RISK)
|
| 94 |
item.status = status.PAUSED_BY_RISK
|
94 |
item.status = status.PAUSED_BY_RISK
|
| 95 |
item.status_description = "This item is currently out of stock"
|
95 |
item.status_description = "This item is currently out of stock"
|
| Line 608... |
Line 608... |
| 608 |
def check_risky_item(item):
|
608 |
def check_risky_item(item):
|
| 609 |
if not item.risky:
|
609 |
if not item.risky:
|
| 610 |
return
|
610 |
return
|
| 611 |
warehouse_ids = None
|
611 |
warehouse_ids = None
|
| 612 |
if item.isWarehousePreferenceSticky :
|
612 |
if item.isWarehousePreferenceSticky :
|
| 613 |
warehouse_ids = [item.preferredWarehouse]
|
613 |
warehouse_ids = [w.id for w in Warehouse.query.filter_by(shippingWarehouseId = item.preferredWarehouse, inventoryType = InventoryType._VALUES_TO_NAMES[InventoryType.GOOD]).all()]
|
| 614 |
availability = __get_item_availability(item, warehouse_ids)
|
614 |
availability = __get_item_availability(item, warehouse_ids)
|
| 615 |
if availability <= 0:
|
615 |
if availability <= 0:
|
| 616 |
if item.status == status.ACTIVE:
|
616 |
if item.status == status.ACTIVE:
|
| 617 |
change_item_status(item.id, status.PAUSED_BY_RISK)
|
617 |
change_item_status(item.id, status.PAUSED_BY_RISK)
|
| 618 |
__send_mail_for_oos_item(item)
|
618 |
__send_mail_for_oos_item(item)
|
| Line 634... |
Line 634... |
| 634 |
availability = availability + currInv.availibility
|
634 |
availability = availability + currInv.availibility
|
| 635 |
reserved = reserved + currInv.reserved
|
635 |
reserved = reserved + currInv.reserved
|
| 636 |
return availability - reserved
|
636 |
return availability - reserved
|
| 637 |
else:
|
637 |
else:
|
| 638 |
total_availability = 0
|
638 |
total_availability = 0
|
| 639 |
for warehouse_id in warehouse_ids:
|
- |
|
| 640 |
try:
|
- |
|
| 641 |
current_inventory_snapshot = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item.id).one()
|
639 |
for current_inventory_snapshot in CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(warehouse_ids)).filter_by(item_id = item.id).all():
|
| 642 |
availability = current_inventory_snapshot.availibility - current_inventory_snapshot.reserved
|
640 |
total_availability += current_inventory_snapshot.availibility - current_inventory_snapshot.reserved
|
| 643 |
except Exception as e:
|
- |
|
| 644 |
print e
|
- |
|
| 645 |
availability = 0
|
- |
|
| 646 |
total_availability = total_availability + availability
|
- |
|
| 647 |
return total_availability
|
641 |
return total_availability
|
| 648 |
|
642 |
|
| 649 |
def __get_item_reserved(item):
|
643 |
def __get_item_reserved(item):
|
| 650 |
all_inventory = CurrentInventorySnapshot.query.filter_by(item = item).all()
|
644 |
all_inventory = CurrentInventorySnapshot.query.filter_by(item = item).all()
|
| 651 |
reserved = 0
|
645 |
reserved = 0
|