| Line 17... |
Line 17... |
| 17 |
from shop2020.clients.UserClient import UserClient
|
17 |
from shop2020.clients.UserClient import UserClient
|
| 18 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
18 |
from shop2020.clients.WarehouseClient import WarehouseClient
|
| 19 |
from shop2020.model.v1 import order
|
19 |
from shop2020.model.v1 import order
|
| 20 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
20 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
| 21 |
Alerts, Order, BatchNoGenerator, InvoiceIDGenerator, \
|
21 |
Alerts, Order, BatchNoGenerator, InvoiceIDGenerator, \
|
| 22 |
TransactionRequiringExtraProcessing
|
22 |
TransactionRequiringExtraProcessing, OrderInventory
|
| 23 |
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
|
23 |
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
|
| 24 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType
|
24 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType
|
| 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
|
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
|
| 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
|
| Line 1616... |
Line 1616... |
| 1616 |
logging.info("Unable to accept the order")
|
1616 |
logging.info("Unable to accept the order")
|
| 1617 |
else:
|
1617 |
else:
|
| 1618 |
order_outofstock(order.id)
|
1618 |
order_outofstock(order.id)
|
| 1619 |
return
|
1619 |
return
|
| 1620 |
|
1620 |
|
| - |
|
1621 |
def mark_orders_as_po_raised(vendorId, itemId, quantity, estimate):
|
| - |
|
1622 |
orders = Order.query.filter(Order.status.in_(tuple([OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW]))).order_by(Order.expected_shipping_time).all()
|
| - |
|
1623 |
for order in orders:
|
| - |
|
1624 |
lineitem = order.lineitems[0]
|
| - |
|
1625 |
if quantity >= lineitem.quantity and itemId == lineitem.item_id:
|
| - |
|
1626 |
if estimate > 0:
|
| - |
|
1627 |
add_delay_reason(order.id, DelayReason.OTHERS, estimate)
|
| - |
|
1628 |
order.status = OrderStatus.LOW_INV_PO_RAISED
|
| - |
|
1629 |
quantity = quantity - lineitem.quantity
|
| - |
|
1630 |
store_inventory_action(order, itemId, HotspotAction.PO_RAISED, estimate, lineitem.quantity)
|
| - |
|
1631 |
session.commit()
|
| - |
|
1632 |
|
| - |
|
1633 |
def mark_orders_as_reversal_initiated(vendorId, itemId, quantity, estimate):
|
| - |
|
1634 |
orders = Order.query.filter(Order.status.in_(tuple([OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW]))).order_by(Order.expected_shipping_time).all()
|
| - |
|
1635 |
for order in orders:
|
| - |
|
1636 |
lineitem = order.lineitems[0]
|
| - |
|
1637 |
if quantity >= lineitem.quantity and itemId == lineitem.item_id:
|
| - |
|
1638 |
if estimate > 0:
|
| - |
|
1639 |
add_delay_reason(order.id, DelayReason.OTHERS, estimate)
|
| - |
|
1640 |
order.status = OrderStatus.LOW_INV_REVERSAL_IN_PROCESS
|
| - |
|
1641 |
quantity = quantity - lineitem.quantity
|
| - |
|
1642 |
store_inventory_action(order, itemId, HotspotAction.REVERSAL_INITIATED, estimate, lineitem.quantity)
|
| - |
|
1643 |
session.commit()
|
| - |
|
1644 |
|
| - |
|
1645 |
def mark_orders_as_not_available(vendorId, itemId, quantity, estimate):
|
| - |
|
1646 |
orders = Order.query.filter(Order.status.in_(tuple([OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW]))).order_by(Order.expected_shipping_time).all()
|
| - |
|
1647 |
for order in orders:
|
| - |
|
1648 |
lineitem = order.lineitems[0]
|
| - |
|
1649 |
if quantity >= lineitem.quantity and itemId == lineitem.item_id:
|
| - |
|
1650 |
order.status = OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT
|
| - |
|
1651 |
quantity = quantity - lineitem.quantity
|
| - |
|
1652 |
store_inventory_action(order, itemId, HotspotAction.NOT_AVAILABLE, estimate, lineitem.quantity)
|
| - |
|
1653 |
session.commit()
|
| - |
|
1654 |
|
| - |
|
1655 |
def store_inventory_action(order, itemId, hotspotAction, estimate, quantity):
|
| - |
|
1656 |
orderInv = OrderInventory()
|
| - |
|
1657 |
orderInv.hotspotAction = hotspotAction
|
| - |
|
1658 |
orderInv.estimate = estimate
|
| - |
|
1659 |
orderInv.itemId = itemId
|
| - |
|
1660 |
orderInv.timestamp = datetime.datetime.now()
|
| - |
|
1661 |
orderInv.quantity = quantity
|
| - |
|
1662 |
orderInv.order = order
|
| - |
|
1663 |
|
| 1621 |
def close_session():
|
1664 |
def close_session():
|
| 1622 |
if session.is_active:
|
1665 |
if session.is_active:
|
| 1623 |
print "session is active. closing it."
|
1666 |
print "session is active. closing it."
|
| 1624 |
session.close()
|
1667 |
session.close()
|
| 1625 |
|
1668 |
|