| Line 7... |
Line 7... |
| 7 |
|
7 |
|
| 8 |
if __name__ == '__main__' and __package__ is None:
|
8 |
if __name__ == '__main__' and __package__ is None:
|
| 9 |
import os
|
9 |
import os
|
| 10 |
sys.path.insert(0, os.getcwd())
|
10 |
sys.path.insert(0, os.getcwd())
|
| 11 |
|
11 |
|
| 12 |
from shop2020.clients.InventoryClient import InventoryClient
|
12 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 13 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus,\
|
13 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderStatus,\
|
| 14 |
TransactionServiceException
|
14 |
TransactionServiceException
|
| 15 |
from shop2020.model.v1.order.impl import DataService
|
15 |
from shop2020.model.v1.order.impl import DataService
|
| 16 |
from shop2020.model.v1.order.impl.DataAccessors import get_order,\
|
16 |
from shop2020.model.v1.order.impl.DataAccessors import get_order,\
|
| 17 |
order_outofstock, close_session
|
17 |
order_outofstock, close_session
|
| Line 142... |
Line 142... |
| 142 |
#if warehouse_id is None or warehouse_id == "":
|
142 |
#if warehouse_id is None or warehouse_id == "":
|
| 143 |
# warehouse_id = order.warehouse_id
|
143 |
# warehouse_id = order.warehouse_id
|
| 144 |
|
144 |
|
| 145 |
lineitem = order.lineitems[0]
|
145 |
lineitem = order.lineitems[0]
|
| 146 |
|
146 |
|
| 147 |
catalog_client = InventoryClient().get_client()
|
147 |
catalog_client = CatalogClient().get_client()
|
| 148 |
catalog_client.reserveItemInWarehouse(item_id, order.warehouse_id, lineitem.quantity)
|
148 |
catalog_client.reserveItemInWarehouse(item_id, order.warehouse_id, lineitem.quantity)
|
| 149 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
149 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
| 150 |
#TODO: Check that this new item has the same price
|
150 |
#TODO: Check that this new item has the same price
|
| 151 |
|
151 |
|
| 152 |
lineitem.item_id = item_id
|
152 |
lineitem.item_id = item_id
|
| Line 174... |
Line 174... |
| 174 |
if warehouse_id == order.warehouse_id:
|
174 |
if warehouse_id == order.warehouse_id:
|
| 175 |
print("You have selected the current warehouse again. Nothing to do")
|
175 |
print("You have selected the current warehouse again. Nothing to do")
|
| 176 |
return
|
176 |
return
|
| 177 |
|
177 |
|
| 178 |
lineitem = order.lineitems[0]
|
178 |
lineitem = order.lineitems[0]
|
| 179 |
catalog_client = InventoryClient().get_client()
|
179 |
catalog_client = CatalogClient().get_client()
|
| 180 |
catalog_client.reserveItemInWarehouse(lineitem.item_id, warehouse_id, lineitem.quantity)
|
180 |
catalog_client.reserveItemInWarehouse(lineitem.item_id, warehouse_id, lineitem.quantity)
|
| 181 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
181 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
| 182 |
|
182 |
|
| 183 |
order.warehouse_id = warehouse_id
|
183 |
order.warehouse_id = warehouse_id
|
| 184 |
session.commit()
|
184 |
session.commit()
|