| Line 666... |
Line 666... |
| 666 |
print e.message
|
666 |
print e.message
|
| 667 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
667 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
| 668 |
|
668 |
|
| 669 |
# For OUR warehouse, we need to scan out items for every billed order
|
669 |
# For OUR warehouse, we need to scan out items for every billed order
|
| 670 |
if billingType == BillingType.OURS:
|
670 |
if billingType == BillingType.OURS:
|
| 671 |
if ItemType.SERIALIZED == item.type:
|
- |
|
| 672 |
try:
|
671 |
try:
|
| 673 |
warehouse_client = WarehouseClient().get_client()
|
672 |
warehouse_client = WarehouseClient().get_client()
|
| - |
|
673 |
if ItemType.SERIALIZED == item.type:
|
| 674 |
inventoryItem = warehouse_client.getInventoryItem(serialNumber)
|
674 |
inventoryItem = warehouse_client.getInventoryItem(serialNumber)
|
| 675 |
if (inventoryItem.itemId != item_id):
|
675 |
else:
|
| 676 |
catalog_client = CatalogClient().get_client()
|
- |
|
| 677 |
item = catalog_client.getItem(inventoryItem.itemId)
|
- |
|
| 678 |
scanItemString = " ".join([str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
- |
|
| 679 |
lineItemString = " ".join([str(lineitem.brand), str(lineitem.model_name), str(lineitem.model_number), str(lineitem.color)])
|
- |
|
| 680 |
raise TransactionServiceException(110, 'Trying to scan ' + scanItemString + ' instead of ' + lineItemString)
|
- |
|
| 681 |
print order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id
|
- |
|
| 682 |
inventoryItem = warehouse_client.scanSerializedItemForOrder(serialNumber, ScanType.SALE, orderId, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
676 |
inventoryItem = warehouse_client.getNonSeralizedInventoryItem(item_id, order.fulfilmentWarehouseId)
|
| 683 |
lineitem.transfer_price = inventoryItem.unitPrice
|
- |
|
| - |
|
677 |
|
| 684 |
order.vendorId = inventoryItem.supplierId
|
678 |
if (inventoryItem.itemId != item_id):
|
| 685 |
catalog_client = CatalogClient().get_client()
|
679 |
catalog_client = CatalogClient().get_client()
|
| - |
|
680 |
item = catalog_client.getItem(inventoryItem.itemId)
|
| - |
|
681 |
scanItemString = " ".join([str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
| - |
|
682 |
lineItemString = " ".join([str(lineitem.brand), str(lineitem.model_name), str(lineitem.model_number), str(lineitem.color)])
|
| - |
|
683 |
raise TransactionServiceException(110, 'Trying to scan ' + scanItemString + ' instead of ' + lineItemString)
|
| - |
|
684 |
|
| - |
|
685 |
if ItemType.SERIALIZED == item.type:
|
| - |
|
686 |
inventoryItem = warehouse_client.scanSerializedItemForOrder(serialNumber, ScanType.SALE, orderId, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
| - |
|
687 |
else:
|
| - |
|
688 |
inventoryItem = warehouse_client.scanForOrder(inventoryItem, ScanType.SALE, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
| - |
|
689 |
|
| - |
|
690 |
lineitem.transfer_price = inventoryItem.unitPrice
|
| - |
|
691 |
order.vendorId = inventoryItem.supplierId
|
| - |
|
692 |
catalog_client = CatalogClient().get_client()
|
| 686 |
warehouse = catalog_client.getWarehouse(order.fulfilmentWarehouseId)
|
693 |
warehouse = catalog_client.getWarehouse(order.fulfilmentWarehouseId)
|
| 687 |
# Fetching GOOD w/h corresponding to the virtual one here
|
694 |
# Fetching GOOD w/h corresponding to the virtual one here
|
| 688 |
if warehouse.billingWarehouseId is None:
|
695 |
if warehouse.billingWarehouseId is None:
|
| 689 |
warehouse = catalog_client.getWarehouses(None, InventoryType.GOOD, warehouse.vendor.id, order.warehouse_id, 0)[0]
|
696 |
warehouse = catalog_client.getWarehouses(None, InventoryType.GOOD, warehouse.vendor.id, order.warehouse_id, 0)[0]
|
| 690 |
order.fulfilmentWarehouseId = warehouse.id
|
697 |
order.fulfilmentWarehouseId = warehouse.id
|
| 691 |
except WarehouseServiceException as e:
|
698 |
except WarehouseServiceException as e:
|
| 692 |
print sys.exc_info()[0]
|
699 |
print sys.exc_info()[0]
|
| 693 |
print 'Could not scan out orders due to: ' + e.message
|
700 |
print 'Could not scan out orders due to: ' + e.message
|
| 694 |
raise TransactionServiceException(110, e.message)
|
701 |
raise TransactionServiceException(110, e.message)
|
| 695 |
else:
|
702 |
else:
|
| 696 |
if not warehouse.isAvailabilityMonitored:
|
703 |
if not warehouse.isAvailabilityMonitored:
|
| 697 |
catalog_client = CatalogClient().get_client()
|
704 |
catalog_client = CatalogClient().get_client()
|
| 698 |
catalog_client.addInventory(item.id, warehouse.id, -1 * lineitem.quantity)
|
705 |
catalog_client.addInventory(item.id, warehouse.id, -1 * lineitem.quantity)
|
| 699 |
|
706 |
|
| Line 1249... |
Line 1256... |
| 1249 |
|
1256 |
|
| 1250 |
# For OUR warehouses, we need to scan in items for every return
|
1257 |
# For OUR warehouses, we need to scan in items for every return
|
| 1251 |
catalogClient = CatalogClient().get_client()
|
1258 |
catalogClient = CatalogClient().get_client()
|
| 1252 |
warehouse = catalogClient.getWarehouse(order.warehouse_id)
|
1259 |
warehouse = catalogClient.getWarehouse(order.warehouse_id)
|
| 1253 |
if warehouse.billingType == BillingType.OURS:
|
1260 |
if warehouse.billingType == BillingType.OURS:
|
| 1254 |
try:
|
- |
|
| 1255 |
scanMap = {
|
1261 |
scanMap = {
|
| 1256 |
OrderStatus.RTO_RECEIVED_PRESTINE : ScanType.SALE_RET,
|
1262 |
OrderStatus.RTO_RECEIVED_PRESTINE : ScanType.SALE_RET,
|
| 1257 |
OrderStatus.RTO_RECEIVED_DAMAGED : ScanType.SALE_RET_UNUSABLE,
|
1263 |
OrderStatus.RTO_RECEIVED_DAMAGED : ScanType.SALE_RET_UNUSABLE,
|
| 1258 |
OrderStatus.RTO_LOST_IN_TRANSIT : ScanType.LOST_IN_TRANSIT,
|
1264 |
OrderStatus.RTO_LOST_IN_TRANSIT : ScanType.LOST_IN_TRANSIT,
|
| 1259 |
OrderStatus.DOA_RECEIVED_PRESTINE : ScanType.DOA_IN,
|
1265 |
OrderStatus.DOA_RECEIVED_PRESTINE : ScanType.DOA_IN,
|
| 1260 |
OrderStatus.DOA_RECEIVED_DAMAGED : ScanType.DOA_IN,
|
1266 |
OrderStatus.DOA_RECEIVED_DAMAGED : ScanType.DOA_IN,
|
| 1261 |
OrderStatus.DOA_LOST_IN_TRANSIT : ScanType.LOST_IN_TRANSIT
|
1267 |
OrderStatus.DOA_LOST_IN_TRANSIT : ScanType.LOST_IN_TRANSIT
|
| 1262 |
}
|
1268 |
}
|
| 1263 |
|
1269 |
|
| 1264 |
scanType = scanMap[order.status]
|
1270 |
scanType = scanMap[order.status]
|
| 1265 |
if scanType:
|
1271 |
if scanType:
|
| 1266 |
lineitem = order.lineitems[0]
|
1272 |
lineitem = order.lineitems[0]
|
| - |
|
1273 |
item = catalogClient.getItem(lineitem.item_id)
|
| 1267 |
warehouseClient = WarehouseClient().get_client()
|
1274 |
warehouseClient = WarehouseClient().get_client()
|
| - |
|
1275 |
if item.type == ItemType.SERIALIZED:
|
| 1268 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
1276 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
| 1269 |
except Exception as e:
|
1277 |
else:
|
| 1270 |
print sys.exc_info()[0]
|
- |
|
| 1271 |
print 'Could not scan in sales return orders' + str(e)
|
1278 |
warehouseClient.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
| 1272 |
|
1279 |
|
| 1273 |
return True
|
1280 |
return True
|
| 1274 |
|
1281 |
|
| 1275 |
def validate_doa(order_id, is_valid):
|
1282 |
def validate_doa(order_id, is_valid):
|
| 1276 |
order = get_order(order_id)
|
1283 |
order = get_order(order_id)
|
| Line 1305... |
Line 1312... |
| 1305 |
# For OUR warehouses, we need to scan in items for every return
|
1312 |
# For OUR warehouses, we need to scan in items for every return
|
| 1306 |
catalogClient = CatalogClient().get_client()
|
1313 |
catalogClient = CatalogClient().get_client()
|
| 1307 |
warehouse = catalogClient.getWarehouse(order.warehouse_id)
|
1314 |
warehouse = catalogClient.getWarehouse(order.warehouse_id)
|
| 1308 |
if warehouse.billingType == BillingType.OURS:
|
1315 |
if warehouse.billingType == BillingType.OURS:
|
| 1309 |
lineitem = order.lineitems[0]
|
1316 |
lineitem = order.lineitems[0]
|
| - |
|
1317 |
item = catalogClient.getItem(lineitem.item_id)
|
| 1310 |
warehouse_client = WarehouseClient().get_client()
|
1318 |
warehouse_client = WarehouseClient().get_client()
|
| - |
|
1319 |
if item.type == ItemType.SERIALIZED:
|
| 1311 |
warehouse_client.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
1320 |
warehouse_client.scanSerializedItemForOrder(lineitem.serial_number, scanType, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
| - |
|
1321 |
else:
|
| - |
|
1322 |
warehouse_client.scanForOrder(None, scanType, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
| 1312 |
return True
|
1323 |
return True
|
| 1313 |
|
1324 |
|
| 1314 |
def reship_order(order_id):
|
1325 |
def reship_order(order_id):
|
| 1315 |
"""
|
1326 |
"""
|
| 1316 |
If the order is in RTO_RECEIVED_PRESTINE or DOA_CERT_INVALID state, it does the following:
|
1327 |
If the order is in RTO_RECEIVED_PRESTINE or DOA_CERT_INVALID state, it does the following:
|
| Line 1554... |
Line 1565... |
| 1554 |
warehouse = catalogClient.getWarehouse(order.warehouse_id)
|
1565 |
warehouse = catalogClient.getWarehouse(order.warehouse_id)
|
| 1555 |
if warehouse.billingType == BillingType.OURS:
|
1566 |
if warehouse.billingType == BillingType.OURS:
|
| 1556 |
if order.status in [OrderStatus.BILLED, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_FROM_WH] or (order.status == OrderStatus.CANCEL_REQUEST_CONFIRMED and order.previousStatus in [OrderStatus.BILLED, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_FROM_WH]):
|
1567 |
if order.status in [OrderStatus.BILLED, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_FROM_WH] or (order.status == OrderStatus.CANCEL_REQUEST_CONFIRMED and order.previousStatus in [OrderStatus.BILLED, OrderStatus.SHIPPED_TO_LOGST, OrderStatus.SHIPPED_FROM_WH]):
|
| 1557 |
lineitem = order.lineitems[0]
|
1568 |
lineitem = order.lineitems[0]
|
| 1558 |
item = catalogClient.getItem(lineitem.item_id)
|
1569 |
item = catalogClient.getItem(lineitem.item_id)
|
| - |
|
1570 |
warehouseClient = WarehouseClient().get_client()
|
| 1559 |
if ItemType.SERIALIZED == item.type:
|
1571 |
if ItemType.SERIALIZED == item.type:
|
| 1560 |
warehouseClient = WarehouseClient().get_client()
|
- |
|
| 1561 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, ScanType.SALE_RET, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
1572 |
warehouseClient.scanSerializedItemForOrder(lineitem.serial_number, ScanType.SALE_RET, order.id, order.fulfilmentWarehouseId, lineitem.quantity, order.warehouse_id)
|
| - |
|
1573 |
else:
|
| - |
|
1574 |
warehouseClient.scanForOrder(None, ScanType.SALE_RET, lineitem.quantity, order.id, order.fulfilmentWarehouseId, order.warehouse_id)
|
| 1562 |
|
1575 |
|
| 1563 |
order.status = status_transition[order.status]
|
1576 |
order.status = status_transition[order.status]
|
| 1564 |
order.refund_timestamp = datetime.datetime.now()
|
1577 |
order.refund_timestamp = datetime.datetime.now()
|
| 1565 |
order.refunded_by = refunded_by
|
1578 |
order.refunded_by = refunded_by
|
| 1566 |
order.refund_reason = reason
|
1579 |
order.refund_reason = reason
|