| Line 615... |
Line 615... |
| 615 |
if order.transaction.status == TransactionStatus.AUTHORIZED:
|
615 |
if order.transaction.status == TransactionStatus.AUTHORIZED:
|
| 616 |
__capture_txn(order)
|
616 |
__capture_txn(order)
|
| 617 |
order.status = OrderStatus.ACCEPTED
|
617 |
order.status = OrderStatus.ACCEPTED
|
| 618 |
order.statusDescription = "Order Accepted"
|
618 |
order.statusDescription = "Order Accepted"
|
| 619 |
order.accepted_timestamp = datetime.datetime.now()
|
619 |
order.accepted_timestamp = datetime.datetime.now()
|
| - |
|
620 |
__amend_fulfilment_warehouse(order)
|
| 620 |
session.commit()
|
621 |
session.commit()
|
| 621 |
logging.info("Successfully accepted the order no.:" + str(orderId))
|
622 |
logging.info("Successfully accepted the order no.:" + str(orderId))
|
| 622 |
return True
|
623 |
return True
|
| 623 |
else:
|
624 |
else:
|
| 624 |
logging.warning("Accept called for the unacceptable order: " + str(orderId))
|
625 |
logging.warning("Accept called for the unacceptable order: " + str(orderId))
|
| Line 641... |
Line 642... |
| 641 |
session.commit()
|
642 |
session.commit()
|
| 642 |
raise TransactionServiceException(122, "Unable to capture payment due to connection issue.")
|
643 |
raise TransactionServiceException(122, "Unable to capture payment due to connection issue.")
|
| 643 |
else:
|
644 |
else:
|
| 644 |
raise TransactionServiceException(115, "Payment capture failed.")
|
645 |
raise TransactionServiceException(115, "Payment capture failed.")
|
| 645 |
|
646 |
|
| - |
|
647 |
def __amend_fulfilment_warehouse(order):
|
| - |
|
648 |
itemId = order.lineitems[0].item_id
|
| - |
|
649 |
catalogClient = CatalogClient().get_client()
|
| - |
|
650 |
inventory = catalogClient.getItemInventoryByItemId(itemId)
|
| - |
|
651 |
if not (inventory.availability.has_key(order.fulfilmentWarehouseId) and inventory.availability[order.fulfilmentWarehouseId]):
|
| - |
|
652 |
for warehouse in catalogClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, order.warehouse_id, 0):
|
| - |
|
653 |
if inventory.availability.has_key(warehouse.id) and inventory.availability[warehouse.id]:
|
| - |
|
654 |
order.fulfilmentWarehouseId = warehouse.id
|
| - |
|
655 |
catalogClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, order.lineitems[0].quantity)
|
| - |
|
656 |
catalogClient.reserveItemInWarehouse(itemId, warehouse.id, order.lineitems[0].quantity)
|
| - |
|
657 |
break
|
| - |
|
658 |
|
| 646 |
def add_billing_details(orderId, invoice_number, serialNumbers, itemNumbers, billedBy, jacketNumber, billingType, fulfilmentWarehouseId, authorize):
|
659 |
def add_billing_details(orderId, invoice_number, serialNumbers, itemNumbers, billedBy, jacketNumber, billingType, fulfilmentWarehouseId, authorize):
|
| 647 |
if jacketNumber is None or jacketNumber <= 0:
|
660 |
if jacketNumber is None or jacketNumber <= 0:
|
| 648 |
raise TransactionServiceException(110, "Invalid jacket number")
|
661 |
raise TransactionServiceException(110, "Invalid jacket number")
|
| 649 |
|
662 |
|
| 650 |
if billedBy is None or billedBy.strip() == "":
|
663 |
if billedBy is None or billedBy.strip() == "":
|
| Line 699... |
Line 712... |
| 699 |
print e.message
|
712 |
print e.message
|
| 700 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
713 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
| 701 |
|
714 |
|
| 702 |
# For OUR warehouse, we need to scan out items for every billed order
|
715 |
# For OUR warehouse, we need to scan out items for every billed order
|
| 703 |
if billingType == BillingType.OURS:
|
716 |
if billingType == BillingType.OURS:
|
| 704 |
for serialNumber in serialNumbers:
|
717 |
for index, serialNumber in enumerate(serialNumbers):
|
| 705 |
try:
|
718 |
try:
|
| 706 |
warehouse_client = WarehouseClient().get_client()
|
719 |
warehouse_client = WarehouseClient().get_client()
|
| 707 |
# Fetching GOOD w/h corresponding to the virtual one here
|
720 |
# Fetching GOOD w/h corresponding to the virtual one here
|
| 708 |
if warehouse.billingWarehouseId is None:
|
721 |
if warehouse.billingWarehouseId is None:
|
| 709 |
warehouse = catalog_client.getWarehouses(None, InventoryType.GOOD, warehouse.vendor.id, order.warehouse_id, 0)[0]
|
722 |
warehouse = catalog_client.getWarehouses(None, InventoryType.GOOD, warehouse.vendor.id, order.warehouse_id, 0)[0]
|
| 710 |
order.fulfilmentWarehouseId = warehouse.id
|
723 |
order.fulfilmentWarehouseId = warehouse.id
|
| 711 |
|
724 |
|
| 712 |
if ItemType.SERIALIZED == item.type:
|
725 |
if ItemType.SERIALIZED == item.type:
|
| 713 |
inventoryItem = warehouse_client.getInventoryItem(serialNumber)
|
726 |
inventoryItem = warehouse_client.getInventoryItem(serialNumber)
|
| 714 |
else:
|
727 |
else:
|
| 715 |
inventoryItem = warehouse_client.getNonSeralizedInventoryItem(item_id, order.fulfilmentWarehouseId)
|
728 |
inventoryItem = warehouse_client.getNonSeralizedInventoryItem(itemNumbers[index], item_id, order.fulfilmentWarehouseId)
|
| 716 |
|
729 |
|
| 717 |
if (inventoryItem.itemId != item_id):
|
730 |
if (inventoryItem.itemId != item_id):
|
| 718 |
catalog_client = CatalogClient().get_client()
|
731 |
catalog_client = CatalogClient().get_client()
|
| 719 |
item = catalog_client.getItem(inventoryItem.itemId)
|
732 |
item = catalog_client.getItem(inventoryItem.itemId)
|
| 720 |
scanItemString = " ".join([str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
733 |
scanItemString = " ".join([str(item.brand), str(item.modelName), str(item.modelNumber), str(item.color)])
|
| Line 1632... |
Line 1645... |
| 1632 |
Reduce the reservation count for all line items of the given order.
|
1645 |
Reduce the reservation count for all line items of the given order.
|
| 1633 |
'''
|
1646 |
'''
|
| 1634 |
try:
|
1647 |
try:
|
| 1635 |
catalog_client = CatalogClient().get_client()
|
1648 |
catalog_client = CatalogClient().get_client()
|
| 1636 |
for lineitem in order.lineitems:
|
1649 |
for lineitem in order.lineitems:
|
| 1637 |
catalog_client.reduceReservationCount(lineitem.item_id, order.fulfilmentWarehouseId, lineitem.quantity);
|
1650 |
catalog_client.reduceReservationCount(lineitem.item_id, order.fulfilmentWarehouseId, lineitem.quantity)
|
| 1638 |
except:
|
1651 |
except:
|
| 1639 |
print "Unable to reduce reservation count"
|
1652 |
print "Unable to reduce reservation count"
|
| 1640 |
|
1653 |
|
| 1641 |
def __clone_order(order, should_copy_billing_info, is_cod):
|
1654 |
def __clone_order(order, should_copy_billing_info, is_cod):
|
| 1642 |
current_time = datetime.datetime.now()
|
1655 |
current_time = datetime.datetime.now()
|