| Line 651... |
Line 651... |
| 651 |
itemId = order.lineitems[0].item_id
|
651 |
itemId = order.lineitems[0].item_id
|
| 652 |
catalogClient = CatalogClient().get_client()
|
652 |
catalogClient = CatalogClient().get_client()
|
| 653 |
inventory = catalogClient.getItemInventoryByItemId(itemId)
|
653 |
inventory = catalogClient.getItemInventoryByItemId(itemId)
|
| 654 |
if not (inventory.availability.has_key(order.fulfilmentWarehouseId) and inventory.availability[order.fulfilmentWarehouseId]):
|
654 |
if not (inventory.availability.has_key(order.fulfilmentWarehouseId) and inventory.availability[order.fulfilmentWarehouseId]):
|
| 655 |
for warehouse in catalogClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, order.warehouse_id, 0):
|
655 |
for warehouse in catalogClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, order.warehouse_id, 0):
|
| 656 |
if inventory.availability.has_key(warehouse.id) and inventory.availability[warehouse.id]:
|
656 |
if inventory.availability.has_key(warehouse.id) and inventory.availability[warehouse.id] >= inventory.reserved[warehouse.id] + order.lineitems[0].quantity:
|
| 657 |
order.fulfilmentWarehouseId = warehouse.id
|
657 |
order.fulfilmentWarehouseId = warehouse.id
|
| 658 |
catalogClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, order.lineitems[0].quantity)
|
658 |
catalogClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, order.lineitems[0].quantity)
|
| 659 |
catalogClient.reserveItemInWarehouse(itemId, warehouse.id, order.lineitems[0].quantity)
|
659 |
catalogClient.reserveItemInWarehouse(itemId, warehouse.id, order.lineitems[0].quantity)
|
| 660 |
break
|
660 |
break
|
| 661 |
|
661 |
|
| Line 1298... |
Line 1298... |
| 1298 |
order.statusDescription = "DOA received damaged"
|
1298 |
order.statusDescription = "DOA received damaged"
|
| 1299 |
elif receiveCondition == 2:
|
1299 |
elif receiveCondition == 2:
|
| 1300 |
order.status = OrderStatus.DOA_LOST_IN_TRANSIT
|
1300 |
order.status = OrderStatus.DOA_LOST_IN_TRANSIT
|
| 1301 |
order.statusDescription = "DOA lost in transit"
|
1301 |
order.statusDescription = "DOA lost in transit"
|
| 1302 |
order.received_return_timestamp = datetime.datetime.now()
|
1302 |
order.received_return_timestamp = datetime.datetime.now()
|
| 1303 |
session.commit()
|
- |
|
| 1304 |
elif order.status in [OrderStatus.RET_PICKUP_CONFIRMED, OrderStatus.RET_RETURN_IN_TRANSIT]:
|
1303 |
elif order.status in [OrderStatus.RET_PICKUP_CONFIRMED, OrderStatus.RET_RETURN_IN_TRANSIT]:
|
| 1305 |
if receiveCondition == 0:
|
1304 |
if receiveCondition == 0:
|
| 1306 |
order.status = OrderStatus.RET_RECEIVED_PRESTINE
|
1305 |
order.status = OrderStatus.RET_RECEIVED_PRESTINE
|
| 1307 |
order.statusDescription = "RETURN package received"
|
1306 |
order.statusDescription = "RETURN package received"
|
| 1308 |
elif receiveCondition == 1:
|
1307 |
elif receiveCondition == 1:
|
| Line 1310... |
Line 1309... |
| 1310 |
order.statusDescription = "RETURN received damaged"
|
1309 |
order.statusDescription = "RETURN received damaged"
|
| 1311 |
elif receiveCondition == 2:
|
1310 |
elif receiveCondition == 2:
|
| 1312 |
order.status = OrderStatus.RET_LOST_IN_TRANSIT
|
1311 |
order.status = OrderStatus.RET_LOST_IN_TRANSIT
|
| 1313 |
order.statusDescription = "RETURN lost in transit"
|
1312 |
order.statusDescription = "RETURN lost in transit"
|
| 1314 |
order.received_return_timestamp = datetime.datetime.now()
|
1313 |
order.received_return_timestamp = datetime.datetime.now()
|
| 1315 |
session.commit()
|
- |
|
| 1316 |
elif order.status == OrderStatus.RTO_IN_TRANSIT :
|
1314 |
elif order.status == OrderStatus.RTO_IN_TRANSIT :
|
| 1317 |
if receiveCondition == 0:
|
1315 |
if receiveCondition == 0:
|
| 1318 |
order.status = OrderStatus.RTO_RECEIVED_PRESTINE
|
1316 |
order.status = OrderStatus.RTO_RECEIVED_PRESTINE
|
| 1319 |
order.statusDescription = "Returned to origin"
|
1317 |
order.statusDescription = "Returned to origin"
|
| 1320 |
elif receiveCondition == 1:
|
1318 |
elif receiveCondition == 1:
|
| Line 1322... |
Line 1320... |
| 1322 |
order.statusDescription = "RTO received damaged"
|
1320 |
order.statusDescription = "RTO received damaged"
|
| 1323 |
elif receiveCondition == 2:
|
1321 |
elif receiveCondition == 2:
|
| 1324 |
order.status = OrderStatus.RTO_LOST_IN_TRANSIT
|
1322 |
order.status = OrderStatus.RTO_LOST_IN_TRANSIT
|
| 1325 |
order.statusDescription = "RTO lost in transit"
|
1323 |
order.statusDescription = "RTO lost in transit"
|
| 1326 |
order.received_return_timestamp = datetime.datetime.now()
|
1324 |
order.received_return_timestamp = datetime.datetime.now()
|
| 1327 |
session.commit()
|
- |
|
| 1328 |
else:
|
1325 |
else:
|
| 1329 |
return False
|
1326 |
return False
|
| 1330 |
|
1327 |
|
| 1331 |
# For OUR warehouses, we need to scan in items for every return
|
1328 |
# For OUR warehouses, we need to scan in items for every return
|
| 1332 |
catalogClient = CatalogClient().get_client()
|
1329 |
catalogClient = CatalogClient().get_client()
|
| Line 1349... |
Line 1346... |
| 1349 |
if item.type == ItemType.SERIALIZED:
|
1346 |
if item.type == ItemType.SERIALIZED:
|
| 1350 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
1347 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
| 1351 |
else:
|
1348 |
else:
|
| 1352 |
warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
1349 |
warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
| 1353 |
|
1350 |
|
| - |
|
1351 |
session.commit()
|
| 1354 |
return True
|
1352 |
return True
|
| 1355 |
|
1353 |
|
| 1356 |
def validate_doa(order_id, is_valid):
|
1354 |
def validate_doa(order_id, is_valid):
|
| 1357 |
order = get_order(order_id)
|
1355 |
order = get_order(order_id)
|
| 1358 |
if order.status != OrderStatus.DOA_RECEIVED_PRESTINE:
|
1356 |
if order.status != OrderStatus.DOA_RECEIVED_PRESTINE:
|
| Line 2655... |
Line 2653... |
| 2655 |
attribute.orderId = order.id
|
2653 |
attribute.orderId = order.id
|
| 2656 |
attribute.name = t_attribute.name
|
2654 |
attribute.name = t_attribute.name
|
| 2657 |
attribute.value = t_attribute.value
|
2655 |
attribute.value = t_attribute.value
|
| 2658 |
session.commit()
|
2656 |
session.commit()
|
| 2659 |
|
2657 |
|
| - |
|
2658 |
def accept_order_for_item(itemId, quantity, fulfilmentWarehouseId, billingWarehouseId):
|
| - |
|
2659 |
catalogClient = CatalogClient().get_client()
|
| - |
|
2660 |
inventory = catalogClient.getItemInventoryByItemId(itemId)
|
| 2660 |
|
2661 |
orders = Order.query.filter(Order.warehouse_id == billingWarehouseId).filter(Order.status.in_(tuple([OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS]))).order_by(Order.expected_shipping_time).all()
|
| - |
|
2662 |
for order in orders:
|
| - |
|
2663 |
lineitem = order.limeitems[0]
|
| - |
|
2664 |
if lineitem.item_id == itemId and lineitem.quantity <= quantity:
|
| - |
|
2665 |
warehouse = catalogClient.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
2666 |
if not warehouse.billingWarehouseId and warehouse.warehouseType == WarehouseType._VALUES_TO_NAMES[WarehouseType.THIRD_PARTY]:
|
| - |
|
2667 |
if inventory.availability.has_key(fulfilmentWarehouseId) and inventory.availability[fulfilmentWarehouseId] > inventory.reserved[fulfilmentWarehouseId]:
|
| - |
|
2668 |
accept_order(order.id)
|
| - |
|
2669 |
quantity -= lineitem.quantity
|
| - |
|
2670 |
|
| 2661 |
def close_session():
|
2671 |
def close_session():
|
| 2662 |
if session.is_active:
|
2672 |
if session.is_active:
|
| 2663 |
print "session is active. closing it."
|
2673 |
print "session is active. closing it."
|
| 2664 |
session.close()
|
2674 |
session.close()
|
| 2665 |
|
2675 |
|