| Line 11... |
Line 11... |
| 11 |
from reportlab.rl_config import defaultPageSize
|
11 |
from reportlab.rl_config import defaultPageSize
|
| 12 |
from shop2020.clients.CatalogClient import CatalogClient
|
12 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 13 |
from shop2020.clients.HelperClient import HelperClient
|
13 |
from shop2020.clients.HelperClient import HelperClient
|
| 14 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
14 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 15 |
from shop2020.clients.PaymentClient import PaymentClient
|
15 |
from shop2020.clients.PaymentClient import PaymentClient
|
| - |
|
16 |
from shop2020.clients.PurchaseClient import PurchaseClient
|
| 16 |
from shop2020.clients.UserClient import UserClient
|
17 |
from shop2020.clients.UserClient import UserClient
|
| 17 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
18 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
| 18 |
from shop2020.config.client.ConfigClient import ConfigClient
|
19 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 19 |
from shop2020.model.v1 import order
|
20 |
from shop2020.model.v1 import order
|
| 20 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
21 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
| Line 26... |
Line 27... |
| 26 |
InventoryServiceException
|
27 |
InventoryServiceException
|
| 27 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
28 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
| 28 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
29 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
| 29 |
HotspotAction, TimeoutSummary
|
30 |
HotspotAction, TimeoutSummary
|
| 30 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
31 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 31 |
from shop2020.thriftpy.warehouse.ttypes import PurchaseOrder, \
|
32 |
from shop2020.thriftpy.purchase.ttypes import PurchaseOrder, LineItem as POLineItem
|
| 32 |
LineItem as POLineItem, ScanType
|
33 |
from shop2020.thriftpy.warehouse.ttypes import ScanType
|
| 33 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
34 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
| 34 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
35 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| 35 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
36 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
| 36 |
from sqlalchemy.sql import func
|
37 |
from sqlalchemy.sql import func
|
| 37 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct
|
38 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct
|
| Line 673... |
Line 674... |
| 673 |
|
674 |
|
| 674 |
# For Mahipal warehouse, we need to scan out items for every billed order
|
675 |
# For Mahipal warehouse, we need to scan out items for every billed order
|
| 675 |
if order.warehouse_id == 7:
|
676 |
if order.warehouse_id == 7:
|
| 676 |
try:
|
677 |
try:
|
| 677 |
warehouse_client = WarehouseClient().get_client()
|
678 |
warehouse_client = WarehouseClient().get_client()
|
| - |
|
679 |
inventoryItem = warehouse_client.getInventoryItem(str(imeiNumber))
|
| 678 |
warehouse_client.scanOut(itemNumber, str(imeiNumber), ScanType.SALE)
|
680 |
transferPrice = warehouse_client.scanSerializedItemForOrder(inventoryItem.id, ScanType.SALE, orderId)
|
| - |
|
681 |
# order.transfer_price = transferPrice
|
| 679 |
except:
|
682 |
except:
|
| 680 |
print sys.exc_info()[0]
|
683 |
print sys.exc_info()[0]
|
| 681 |
print 'Could not scan out orders'
|
684 |
print 'Could not scan out orders'
|
| 682 |
|
685 |
|
| 683 |
return True
|
686 |
return True
|
| Line 1056... |
Line 1059... |
| 1056 |
if order.warehouse_id == 7:
|
1059 |
if order.warehouse_id == 7:
|
| 1057 |
try:
|
1060 |
try:
|
| 1058 |
warehouse_client = WarehouseClient().get_client()
|
1061 |
warehouse_client = WarehouseClient().get_client()
|
| 1059 |
lineitem = order.lineitems[0]
|
1062 |
lineitem = order.lineitems[0]
|
| 1060 |
|
1063 |
|
| - |
|
1064 |
inventoryItem = warehouse_client.getInventoryItem(lineitem.imei_number)
|
| 1061 |
# Inventory should not be updated for DOA returns
|
1065 |
# Inventory should not be updated for DOA returns
|
| 1062 |
if order.status == OrderStatus.RTO_IN_TRANSIT:
|
1066 |
if order.status == OrderStatus.RTO_IN_TRANSIT:
|
| 1063 |
warehouse_client.scanIn(order.id, lineitem.item_number, lineitem.imei_number, ScanType.SALE_RET)
|
1067 |
warehouse_client.scanSerializedItemForOrder(inventoryItem.id, ScanType.SALE_RET, order.id)
|
| 1064 |
catalog_client = CatalogClient().get_client()
|
1068 |
catalog_client = CatalogClient().get_client()
|
| 1065 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
1069 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
| 1066 |
elif order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
1070 |
elif order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
| 1067 |
warehouse_client.scanIn(order.id, lineitem.item_number, lineitem.imei_number, ScanType.DOA_IN)
|
1071 |
warehouse_client.scanSerializedItemForOrder(inventoryItem.id, ScanType.DOA_IN, order.id)
|
| 1068 |
except:
|
1072 |
except:
|
| 1069 |
print sys.exc_info()[0]
|
1073 |
print sys.exc_info()[0]
|
| 1070 |
print 'Could not scan in sales return orders'
|
1074 |
print 'Could not scan in sales return orders'
|
| 1071 |
|
1075 |
|
| 1072 |
if order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
1076 |
if order.status in [OrderStatus.DOA_PICKUP_CONFIRMED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
| Line 1577... |
Line 1581... |
| 1577 |
t_purchase_order.lineitems.append(lineitem)
|
1581 |
t_purchase_order.lineitems.append(lineitem)
|
| 1578 |
|
1582 |
|
| 1579 |
if not t_purchase_order.lineitems:
|
1583 |
if not t_purchase_order.lineitems:
|
| 1580 |
return -1
|
1584 |
return -1
|
| 1581 |
|
1585 |
|
| 1582 |
warehouse_client = WarehouseClient().get_client()
|
1586 |
purchase_client = PurchaseClient().get_client()
|
| 1583 |
po_id = warehouse_client.createPurchaseOrder(t_purchase_order)
|
1587 |
po_id = purchase_client.createPurchaseOrder(t_purchase_order)
|
| 1584 |
|
1588 |
|
| 1585 |
for order in pending_orders:
|
1589 |
for order in pending_orders:
|
| 1586 |
order.purchase_order_id = po_id
|
1590 |
order.purchase_order_id = po_id
|
| 1587 |
order.status = OrderStatus.LOW_INV_PO_RAISED
|
1591 |
order.status = OrderStatus.LOW_INV_PO_RAISED
|
| 1588 |
order.statusDescription = 'In Process'
|
1592 |
order.statusDescription = 'In Process'
|