| Line 1806... |
Line 1806... |
| 1806 |
try:
|
1806 |
try:
|
| 1807 |
warehouse = catalog_client.getWarehouse(warehouse_id)
|
1807 |
warehouse = catalog_client.getWarehouse(warehouse_id)
|
| 1808 |
except:
|
1808 |
except:
|
| 1809 |
raise TransactionServiceException(119, "No warehouse with id" + str(warehouse_id))
|
1809 |
raise TransactionServiceException(119, "No warehouse with id" + str(warehouse_id))
|
| 1810 |
|
1810 |
|
| - |
|
1811 |
if warehouse.billingWarehouseId is None:
|
| - |
|
1812 |
raise TransactionServiceException(119, "Shifting of warehouse allowed to warehouse with billing support only")
|
| - |
|
1813 |
|
| - |
|
1814 |
# If One gives a shipping location for warehouse shift, we should assign order to the GOOD warehouse
|
| - |
|
1815 |
# present with this shipping location with maximum availability
|
| 1811 |
if warehouse.billingWarehouseId is None or warehouse.inventoryType != InventoryType.GOOD:
|
1816 |
if warehouse.inventoryType != InventoryType.GOOD:
|
| - |
|
1817 |
warehouses = catalog_client.getWarehouses(None, InventoryType.GOOD, 0, 0, warehouse.id)
|
| - |
|
1818 |
if warehouses:
|
| - |
|
1819 |
itemInventory = catalog_client.getItemInventoryByItemId(lineitem.item_id)
|
| - |
|
1820 |
warehouse = warehouses[0]
|
| - |
|
1821 |
maxAvailability = 0
|
| - |
|
1822 |
for goodWarehouse in warehouses:
|
| - |
|
1823 |
if itemInventory.availability.has_key(goodWarehouse.id) and maxAvailability < itemInventory.availability[goodWarehouse.id]:
|
| - |
|
1824 |
warehouse = goodWarehouse
|
| - |
|
1825 |
maxAvailability = itemInventory.availability[goodWarehouse.id]
|
| - |
|
1826 |
|
| - |
|
1827 |
# Use preferred vendor's warehouse if not available anywhere
|
| - |
|
1828 |
if not maxAvailability:
|
| - |
|
1829 |
item = catalog_client.getItem(lineitem.item_id)
|
| - |
|
1830 |
if item.preferredVendor:
|
| - |
|
1831 |
for goodWarehouse in warehouses:
|
| - |
|
1832 |
if goodWarehouse.vendor.id == item.preferredVendor:
|
| - |
|
1833 |
warehouse = goodWarehouse
|
| - |
|
1834 |
else:
|
| 1812 |
raise TransactionServiceException(119, "Shifting of warehouse allowed to GOOD inventory type warehouse with billing support")
|
1835 |
raise TransactionServiceException(119, "Shifting of warehouse allowed to GOOD inventory type warehouse with billing support")
|
| 1813 |
|
1836 |
|
| 1814 |
catalog_client.reserveItemInWarehouse(lineitem.item_id, warehouse_id, lineitem.quantity)
|
1837 |
catalog_client.reserveItemInWarehouse(lineitem.item_id, warehouse_id, lineitem.quantity)
|
| 1815 |
__update_inventory_reservation(order)
|
1838 |
__update_inventory_reservation(order)
|
| 1816 |
|
1839 |
|
| 1817 |
order.warehouse_id = warehouse.billingWarehouseId
|
1840 |
order.warehouse_id = warehouse.billingWarehouseId
|
| 1818 |
order.fulfilmentWarehouseId = warehouse_id
|
1841 |
order.fulfilmentWarehouseId = warehouse.id
|
| 1819 |
session.commit()
|
1842 |
session.commit()
|
| 1820 |
return order
|
1843 |
return order
|
| 1821 |
|
1844 |
|
| 1822 |
def add_delay_reason(order_id, reason, further_delay, delayReasonText):
|
1845 |
def add_delay_reason(order_id, reason, further_delay, delayReasonText):
|
| 1823 |
'''
|
1846 |
'''
|