| Line 25... |
Line 25... |
| 25 |
from shop2020.thriftpy.model.v1.catalog.ttypes import BillingType
|
25 |
from shop2020.thriftpy.model.v1.catalog.ttypes import BillingType
|
| 26 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction, \
|
26 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction, \
|
| 27 |
TransactionServiceException, TransactionStatus, OrderStatus, DelayReason, \
|
27 |
TransactionServiceException, TransactionStatus, OrderStatus, DelayReason, \
|
| 28 |
ExtraTransactionProcessingType, HotspotAction
|
28 |
ExtraTransactionProcessingType, HotspotAction
|
| 29 |
from shop2020.thriftpy.warehouse.ttypes import PurchaseOrder, \
|
29 |
from shop2020.thriftpy.warehouse.ttypes import PurchaseOrder, \
|
| 30 |
LineItem as POLineItem
|
30 |
LineItem as POLineItem, ScanType
|
| 31 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
31 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
| 32 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
32 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| 33 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
33 |
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
|
| 34 |
from sqlalchemy.sql import func
|
34 |
from sqlalchemy.sql import func
|
| 35 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct
|
35 |
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct
|
| Line 645... |
Line 645... |
| 645 |
lineitems = order.lineitems
|
645 |
lineitems = order.lineitems
|
| 646 |
for lineitem in lineitems:
|
646 |
for lineitem in lineitems:
|
| 647 |
catalog_client.reduceReservationCount(item_id, order.warehouse_id, lineitem.quantity)
|
647 |
catalog_client.reduceReservationCount(item_id, order.warehouse_id, lineitem.quantity)
|
| 648 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
648 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 649 |
session.commit()
|
649 |
session.commit()
|
| - |
|
650 |
|
| - |
|
651 |
# For Mahipal warehouse, we need to scan out items for every billed order
|
| - |
|
652 |
if order.warehouse_id == 7:
|
| - |
|
653 |
try:
|
| - |
|
654 |
warehouse_client = WarehouseClient().get_client()
|
| - |
|
655 |
warehouse_client.scanOut(itemNumber, str(imeiNumber), ScanType.SALE)
|
| - |
|
656 |
except:
|
| - |
|
657 |
print sys.exc_info()[0]
|
| - |
|
658 |
print 'Could not scan out orders'
|
| - |
|
659 |
|
| 650 |
return True
|
660 |
return True
|
| 651 |
else:
|
661 |
else:
|
| 652 |
return False
|
662 |
return False
|
| 653 |
|
663 |
|
| 654 |
def batch_orders(warehouseId):
|
664 |
def batch_orders(warehouseId):
|
| Line 809... |
Line 819... |
| 809 |
|
819 |
|
| 810 |
def get_next_invoice_number():
|
820 |
def get_next_invoice_number():
|
| 811 |
entity_id = InvoiceIDGenerator.query.with_lockmode("update").one()
|
821 |
entity_id = InvoiceIDGenerator.query.with_lockmode("update").one()
|
| 812 |
invoice_number = entity_id.id + 1
|
822 |
invoice_number = entity_id.id + 1
|
| 813 |
entity_id.id = invoice_number
|
823 |
entity_id.id = invoice_number
|
| 814 |
session.commit()
|
- |
|
| 815 |
return invoice_number
|
824 |
return invoice_number
|
| 816 |
|
825 |
|
| 817 |
def toggle_doa_flag(order_id):
|
826 |
def toggle_doa_flag(order_id):
|
| 818 |
order = get_order(order_id)
|
827 |
order = get_order(order_id)
|
| 819 |
if(order.doaFlag):
|
828 |
if(order.doaFlag):
|
| Line 953... |
Line 962... |
| 953 |
orders_not_picked_up = Order.query.filter_by(logistics_provider_id = provider_id).filter_by(status=OrderStatus.DOA_RETURN_AUTHORIZED).filter(Order.doa_auth_timestamp >= from_datetime).filter(Order.doa_auth_timestamp <= to_datetime).all()
|
962 |
orders_not_picked_up = Order.query.filter_by(logistics_provider_id = provider_id).filter_by(status=OrderStatus.DOA_RETURN_AUTHORIZED).filter(Order.doa_auth_timestamp >= from_datetime).filter(Order.doa_auth_timestamp <= to_datetime).all()
|
| 954 |
return orders_not_picked_up
|
963 |
return orders_not_picked_up
|
| 955 |
|
964 |
|
| 956 |
def receive_return(order_id):
|
965 |
def receive_return(order_id):
|
| 957 |
order = get_order(order_id)
|
966 |
order = get_order(order_id)
|
| - |
|
967 |
|
| - |
|
968 |
# FIXME: For Mahipal warehouse, we need to scan in items for every sales return
|
| - |
|
969 |
if order.warehouse_id == 7:
|
| - |
|
970 |
try:
|
| - |
|
971 |
warehouse_client = WarehouseClient().get_client()
|
| - |
|
972 |
lineitem = order.lineitems[0]
|
| - |
|
973 |
|
| - |
|
974 |
# Inventory should not be updated for DOA returns
|
| - |
|
975 |
if order.status == OrderStatus.SALES_RETURN_IN_TRANSIT:
|
| - |
|
976 |
warehouse_client.scanIn(order.id, lineitem.item_number, lineitem.imei_number, ScanType.SALE_RET)
|
| - |
|
977 |
catalog_client = CatalogClient().get_client()
|
| - |
|
978 |
catalog_client.reduceReservationCount(lineitem.item_id, order.warehouse_id, lineitem.quantity)
|
| - |
|
979 |
elif order.status in [OrderStatus.DOA_RETURN_AUTHORIZED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
| - |
|
980 |
warehouse_client.scanIn(order.id, lineitem.item_number, lineitem.imei_number, ScanType.DOA_IN)
|
| - |
|
981 |
except:
|
| - |
|
982 |
print sys.exc_info()[0]
|
| - |
|
983 |
print 'Could not scan in sales return orders'
|
| - |
|
984 |
|
| 958 |
if order.status in [OrderStatus.DOA_RETURN_AUTHORIZED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
985 |
if order.status in [OrderStatus.DOA_RETURN_AUTHORIZED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
| 959 |
order.status = OrderStatus.DOA_RECEIVED
|
986 |
order.status = OrderStatus.DOA_RECEIVED
|
| 960 |
order.statusDescription = "DOA package received"
|
987 |
order.statusDescription = "DOA package received"
|
| 961 |
order.received_return_timestamp = datetime.datetime.now()
|
988 |
order.received_return_timestamp = datetime.datetime.now()
|
| 962 |
session.commit()
|
989 |
session.commit()
|
| Line 1306... |
Line 1333... |
| 1306 |
|
1333 |
|
| 1307 |
if not pending_orders:
|
1334 |
if not pending_orders:
|
| 1308 |
return -1
|
1335 |
return -1
|
| 1309 |
|
1336 |
|
| 1310 |
t_purchase_order = PurchaseOrder()
|
1337 |
t_purchase_order = PurchaseOrder()
|
| 1311 |
t_purchase_order.supplierId = warehouseId
|
1338 |
t_purchase_order.supplierId = 3 # Putting supplier id as 3 for sarvottam for time being
|
| 1312 |
t_purchase_order.warehouseId = warehouseId
|
1339 |
t_purchase_order.warehouseId = warehouseId
|
| 1313 |
t_purchase_order.lineitems = []
|
1340 |
t_purchase_order.lineitems = []
|
| 1314 |
|
1341 |
|
| 1315 |
lineitems = {}
|
1342 |
lineitems = {}
|
| 1316 |
|
1343 |
|