| Line 24... |
Line 24... |
| 24 |
from shop2020.clients.HelperClient import HelperClient
|
24 |
from shop2020.clients.HelperClient import HelperClient
|
| 25 |
import urllib2
|
25 |
import urllib2
|
| 26 |
from urllib2 import HTTPBasicAuthHandler
|
26 |
from urllib2 import HTTPBasicAuthHandler
|
| 27 |
from shop2020.config.client.ConfigClient import ConfigClient
|
27 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 28 |
from shop2020.utils.EmailAttachmentSender import mail
|
28 |
from shop2020.utils.EmailAttachmentSender import mail
|
| - |
|
29 |
from shop2020.clients.TransactionClient import TransactionClient
|
| - |
|
30 |
from shop2020.thriftpy.model.v1.order.ttypes import AlertType
|
| 29 |
|
31 |
|
| 30 |
def initialize():
|
32 |
def initialize():
|
| 31 |
DataService.initialize()
|
33 |
DataService.initialize()
|
| 32 |
|
34 |
|
| 33 |
def get_all_items_by_status(status, offset=0, limit=None):
|
35 |
def get_all_items_by_status(status, offset=0, limit=None):
|
| Line 360... |
Line 362... |
| 360 |
current_inventory_snapshot.warehouse = warehouse
|
362 |
current_inventory_snapshot.warehouse = warehouse
|
| 361 |
current_inventory_snapshot.availibility = 0
|
363 |
current_inventory_snapshot.availibility = 0
|
| 362 |
current_inventory_snapshot.reserved = 0
|
364 |
current_inventory_snapshot.reserved = 0
|
| 363 |
# added the difference in the current inventory
|
365 |
# added the difference in the current inventory
|
| 364 |
current_inventory_snapshot.availibility = current_inventory_snapshot.availibility + quantity
|
366 |
current_inventory_snapshot.availibility = current_inventory_snapshot.availibility + quantity
|
| - |
|
367 |
try:
|
| - |
|
368 |
if quantity > 0 and __get_item_reserved(item) > 0:
|
| - |
|
369 |
cl = TransactionClient().get_client()
|
| - |
|
370 |
cl.addAlert(AlertType.NEW_INVENTORY_ALERT, "Inventory received for item " + item.brand + item.model_name + item.model_number)
|
| - |
|
371 |
except:
|
| - |
|
372 |
print "Not able to raise alert for incoming inventory"
|
| 365 |
except:
|
373 |
except:
|
| 366 |
raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
|
374 |
raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
|
| 367 |
session.commit()
|
375 |
session.commit()
|
| 368 |
check_risky_item(item)
|
376 |
check_risky_item(item)
|
| 369 |
|
377 |
|
| Line 523... |
Line 531... |
| 523 |
reserved = 0
|
531 |
reserved = 0
|
| 524 |
for currInv in all_inventory:
|
532 |
for currInv in all_inventory:
|
| 525 |
availability = availability + currInv.availibility
|
533 |
availability = availability + currInv.availibility
|
| 526 |
reserved = reserved + currInv.reserved
|
534 |
reserved = reserved + currInv.reserved
|
| 527 |
return availability - reserved
|
535 |
return availability - reserved
|
| - |
|
536 |
|
| - |
|
537 |
def __get_item_reserved(item):
|
| - |
|
538 |
all_inventory = CurrentInventorySnapshot.query.filter_by(item = item).all()
|
| - |
|
539 |
reserved = 0
|
| - |
|
540 |
for currInv in all_inventory:
|
| - |
|
541 |
reserved = reserved + currInv.reserved
|
| - |
|
542 |
return reserved
|
| 528 |
|
543 |
|
| 529 |
def reserve_item_in_warehouse(item_id, warehouse_id, quantity):
|
544 |
def reserve_item_in_warehouse(item_id, warehouse_id, quantity):
|
| 530 |
if not warehouse_id:
|
545 |
if not warehouse_id:
|
| 531 |
raise InventoryServiceException(101, "bad warehouse_id")
|
546 |
raise InventoryServiceException(101, "bad warehouse_id")
|
| 532 |
item = get_item(item_id)
|
547 |
item = get_item(item_id)
|