| Line 51... |
Line 51... |
| 51 |
import os
|
51 |
import os
|
| 52 |
import sys
|
52 |
import sys
|
| 53 |
import time
|
53 |
import time
|
| 54 |
import traceback
|
54 |
import traceback
|
| 55 |
import urllib
|
55 |
import urllib
|
| - |
|
56 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 56 |
|
57 |
|
| 57 |
logging.basicConfig(level=logging.DEBUG)
|
58 |
logging.basicConfig(level=logging.DEBUG)
|
| 58 |
|
59 |
|
| - |
|
60 |
sourceId = int(ConfigClient().get_property("sourceid"))
|
| - |
|
61 |
mail_user = 'cnc.center@shop2020.in'
|
| - |
|
62 |
mail_password = '5h0p2o2o'
|
| - |
|
63 |
help_user = 'help@shop2020.in'
|
| - |
|
64 |
help_password = '5h0p2o2o'
|
| 59 |
|
65 |
|
| 60 |
PREPAID_SHIPPING_CUTOFF_TIME = 15
|
66 |
PREPAID_SHIPPING_CUTOFF_TIME = 15
|
| 61 |
COD_SHIPPING_CUTOFF_TIME = 12
|
67 |
COD_SHIPPING_CUTOFF_TIME = 12
|
| 62 |
|
68 |
|
| 63 |
PAGE_HEIGHT=defaultPageSize[1]
|
69 |
PAGE_HEIGHT=defaultPageSize[1]
|
| Line 248... |
Line 254... |
| 248 |
order.promised_shipping_time = order.expected_shipping_time
|
254 |
order.promised_shipping_time = order.expected_shipping_time
|
| 249 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
255 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 250 |
order.promised_delivery_time = order.expected_delivery_time
|
256 |
order.promised_delivery_time = order.expected_delivery_time
|
| 251 |
|
257 |
|
| 252 |
inventory_client = InventoryClient().get_client()
|
258 |
inventory_client = InventoryClient().get_client()
|
| 253 |
inventory_client.reserveItemInWarehouse(item_id, logistics_info.fulfilmentWarehouseId, order.lineitems[0].quantity)
|
259 |
inventory_client.reserveItemInWarehouse(item_id, logistics_info.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 254 |
|
260 |
|
| 255 |
try:
|
261 |
try:
|
| 256 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
262 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 257 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
263 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 258 |
except:
|
264 |
except:
|
| Line 295... |
Line 301... |
| 295 |
order.promised_shipping_time = order.expected_shipping_time
|
301 |
order.promised_shipping_time = order.expected_shipping_time
|
| 296 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
302 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 297 |
order.promised_delivery_time = order.expected_delivery_time
|
303 |
order.promised_delivery_time = order.expected_delivery_time
|
| 298 |
|
304 |
|
| 299 |
inventory_client = InventoryClient().get_client()
|
305 |
inventory_client = InventoryClient().get_client()
|
| 300 |
inventory_client.reserveItemInWarehouse(item_id, logistics_info.fulfilmentWarehouseId, order.lineitems[0].quantity)
|
306 |
inventory_client.reserveItemInWarehouse(item_id, logistics_info.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 301 |
|
307 |
|
| 302 |
try:
|
308 |
try:
|
| 303 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
309 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 304 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
310 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 305 |
except:
|
311 |
except:
|
| Line 618... |
Line 624... |
| 618 |
return True
|
624 |
return True
|
| 619 |
except Exception as e:
|
625 |
except Exception as e:
|
| 620 |
print e
|
626 |
print e
|
| 621 |
return False
|
627 |
return False
|
| 622 |
|
628 |
|
| 623 |
def enqueue_delivery_successe_mail(order):
|
629 |
def enqueue_delivery_success_mail(order):
|
| 624 |
html_header = """
|
630 |
html_header = """
|
| 625 |
<html>
|
631 |
<html>
|
| 626 |
<body>
|
632 |
<body>
|
| 627 |
<div>
|
633 |
<div>
|
| 628 |
<p>
|
634 |
<p>
|
| Line 960... |
Line 966... |
| 960 |
inventoryClient = InventoryClient().get_client()
|
966 |
inventoryClient = InventoryClient().get_client()
|
| 961 |
inventory = inventoryClient.getItemInventoryByItemId(itemId)
|
967 |
inventory = inventoryClient.getItemInventoryByItemId(itemId)
|
| 962 |
if not (inventory.availability.has_key(order.fulfilmentWarehouseId) and inventory.availability[order.fulfilmentWarehouseId]):
|
968 |
if not (inventory.availability.has_key(order.fulfilmentWarehouseId) and inventory.availability[order.fulfilmentWarehouseId]):
|
| 963 |
for warehouse in inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, order.warehouse_id, 0):
|
969 |
for warehouse in inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, order.warehouse_id, 0):
|
| 964 |
if inventory.availability.has_key(warehouse.id) and inventory.availability[warehouse.id] >= inventory.reserved[warehouse.id] + order.lineitems[0].quantity:
|
970 |
if inventory.availability.has_key(warehouse.id) and inventory.availability[warehouse.id] >= inventory.reserved[warehouse.id] + order.lineitems[0].quantity:
|
| 965 |
inventoryClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, order.lineitems[0].quantity)
|
971 |
inventoryClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, sourceId, order.id, order.lineitems[0].quantity)
|
| 966 |
inventoryClient.reserveItemInWarehouse(itemId, warehouse.id, order.lineitems[0].quantity)
|
972 |
inventoryClient.reserveItemInWarehouse(itemId, warehouse.id, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 967 |
order.fulfilmentWarehouseId = warehouse.id
|
973 |
order.fulfilmentWarehouseId = warehouse.id
|
| 968 |
break
|
974 |
break
|
| 969 |
|
975 |
|
| 970 |
def add_billing_details(orderId, invoice_number, serialNumbers, itemNumbers, billedBy, jacketNumber, billingType, fulfilmentWarehouseId, authorize):
|
976 |
def add_billing_details(orderId, invoice_number, serialNumbers, itemNumbers, billedBy, jacketNumber, billingType, fulfilmentWarehouseId, authorize):
|
| 971 |
if jacketNumber is None or jacketNumber <= 0:
|
977 |
if jacketNumber is None or jacketNumber <= 0:
|
| Line 976... |
Line 982... |
| 976 |
|
982 |
|
| 977 |
order = Order.get_by(id=orderId)
|
983 |
order = Order.get_by(id=orderId)
|
| 978 |
if not order:
|
984 |
if not order:
|
| 979 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
985 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
| 980 |
|
986 |
|
| - |
|
987 |
|
| 981 |
lineitem = order.lineitems[0]
|
988 |
lineitem = order.lineitems[0]
|
| 982 |
item_id = lineitem.item_id
|
989 |
item_id = lineitem.item_id
|
| - |
|
990 |
|
| - |
|
991 |
inventoryClient = InventoryClient().get_client()
|
| - |
|
992 |
if not inventoryClient.isOrderBillable(item_id, order.fulfilmentWarehouseId, sourceId, orderId):
|
| - |
|
993 |
raise TransactionServiceException(101, "There are other orders to be billed before this order id " + str(orderId))
|
| - |
|
994 |
|
| 983 |
catalog_client = CatalogClient().get_client()
|
995 |
catalog_client = CatalogClient().get_client()
|
| 984 |
item = catalog_client.getItem(item_id)
|
996 |
item = catalog_client.getItem(item_id)
|
| 985 |
if order.status == OrderStatus.ACCEPTED:
|
997 |
if order.status == OrderStatus.ACCEPTED:
|
| 986 |
order.jacket_number = jacketNumber
|
998 |
order.jacket_number = jacketNumber
|
| 987 |
if billingType == BillingType.OURS:
|
999 |
if billingType == BillingType.OURS:
|
| Line 1154... |
Line 1166... |
| 1154 |
except:
|
1166 |
except:
|
| 1155 |
return False
|
1167 |
return False
|
| 1156 |
|
1168 |
|
| 1157 |
def send_mails_to_bdms(order):
|
1169 |
def send_mails_to_bdms(order):
|
| 1158 |
logistics_client = LogisticsClient().get_client()
|
1170 |
logistics_client = LogisticsClient().get_client()
|
| 1159 |
from_user = 'cnc.center@shop2020.in'
|
- |
|
| 1160 |
from_pwd = '5h0p2o2o'
|
- |
|
| 1161 |
store = logistics_client.getPickupStore(order.pickupStoreId)
|
1171 |
store = logistics_client.getPickupStore(order.pickupStoreId)
|
| 1162 |
provider = logistics_client.getProvider(order.logistics_provider_id)
|
1172 |
provider = logistics_client.getProvider(order.logistics_provider_id)
|
| 1163 |
subject = "Saholic order " + str(order.id) +" shipped to store"
|
1173 |
subject = "Saholic order " + str(order.id) +" shipped to store"
|
| 1164 |
raw_message = '''
|
1174 |
raw_message = '''
|
| 1165 |
Dear Sir,
|
1175 |
Dear Sir,
|
| Line 1192... |
Line 1202... |
| 1192 |
'note' : note
|
1202 |
'note' : note
|
| 1193 |
}
|
1203 |
}
|
| 1194 |
to_addresses = [store.email, store.bdmEmail, 'sandeep.sachdeva@shop2020.in', 'suraj.sharma@shop2020.in', 'manoj.kumar@shop2020.in']
|
1204 |
to_addresses = [store.email, store.bdmEmail, 'sandeep.sachdeva@shop2020.in', 'suraj.sharma@shop2020.in', 'manoj.kumar@shop2020.in']
|
| 1195 |
cc = ['khushal.bhatia@spiceretail.co.in']
|
1205 |
cc = ['khushal.bhatia@spiceretail.co.in']
|
| 1196 |
bcc = ['rajneesh.arora@spiceretail.co.in']
|
1206 |
bcc = ['rajneesh.arora@spiceretail.co.in']
|
| 1197 |
mail(from_user, from_pwd, to_addresses, subject, message, [], cc, bcc)
|
1207 |
mail(mail_user, mail_password, to_addresses, subject, message, [], cc, bcc)
|
| 1198 |
|
1208 |
|
| 1199 |
def mark_orders_as_returned_from_store(providerId, orderIds, awbs):
|
1209 |
def mark_orders_as_returned_from_store(providerId, orderIds, awbs):
|
| 1200 |
try:
|
1210 |
try:
|
| 1201 |
current_timestamp = datetime.datetime.now()
|
1211 |
current_timestamp = datetime.datetime.now()
|
| 1202 |
orders = Order.query.filter(Order.id.in_(orderIds)).filter_by(logistics_provider_id = providerId, status = OrderStatus.RET_PICKUP_REQUEST_RAISED).all()
|
1212 |
orders = Order.query.filter(Order.id.in_(orderIds)).filter_by(logistics_provider_id = providerId, status = OrderStatus.RET_PICKUP_REQUEST_RAISED).all()
|
| Line 1287... |
Line 1297... |
| 1287 |
print e
|
1297 |
print e
|
| 1288 |
else:
|
1298 |
else:
|
| 1289 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
1299 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
| 1290 |
order.statusDescription = "Order delivered"
|
1300 |
order.statusDescription = "Order delivered"
|
| 1291 |
update_trust_level(order)
|
1301 |
update_trust_level(order)
|
| 1292 |
enqueue_delivery_successe_mail(order)
|
1302 |
enqueue_delivery_success_mail(order)
|
| 1293 |
try:
|
1303 |
try:
|
| 1294 |
alert_client = AlertClient().get_client()
|
1304 |
alert_client = AlertClient().get_client()
|
| 1295 |
alert_client.endMonitoringEntity(EntityType.COURIER, "orderId = " + str(order.id))
|
1305 |
alert_client.endMonitoringEntity(EntityType.COURIER, "orderId = " + str(order.id))
|
| 1296 |
except Exception as e:
|
1306 |
except Exception as e:
|
| 1297 |
print "Exception in scheduling alert in ShippedFromWarehouse method"
|
1307 |
print "Exception in scheduling alert in ShippedFromWarehouse method"
|
| Line 1322... |
Line 1332... |
| 1322 |
session.commit()
|
1332 |
session.commit()
|
| 1323 |
|
1333 |
|
| 1324 |
if order.pickupStoreId and order.cod:
|
1334 |
if order.pickupStoreId and order.cod:
|
| 1325 |
__push_collection_to_hotspot(order, "SALE")
|
1335 |
__push_collection_to_hotspot(order, "SALE")
|
| 1326 |
|
1336 |
|
| 1327 |
enqueue_delivery_successe_mail(order)
|
1337 |
enqueue_delivery_success_mail(order)
|
| 1328 |
# if order.pickupStoreId:
|
1338 |
# if order.pickupStoreId:
|
| 1329 |
# payment_client = PaymentClient().get_client()
|
1339 |
# payment_client = PaymentClient().get_client()
|
| 1330 |
# payment_client.createRefund(order.id, order.transaction.id, order.total_amount)
|
1340 |
# payment_client.createRefund(order.id, order.transaction.id, order.total_amount)
|
| 1331 |
# payment_client = PaymentClient().get_client()
|
1341 |
# payment_client = PaymentClient().get_client()
|
| 1332 |
# payment_client.partiallyCapturePayment(order.transaction.id, order.total_amount, xferBy, xferTxnId, now())
|
1342 |
# payment_client.partiallyCapturePayment(order.transaction.id, order.total_amount, xferBy, xferTxnId, now())
|
| Line 1647... |
Line 1657... |
| 1647 |
|
1657 |
|
| 1648 |
def request_pickup_number(order_id, providerId):
|
1658 |
def request_pickup_number(order_id, providerId):
|
| 1649 |
order = get_order(order_id)
|
1659 |
order = get_order(order_id)
|
| 1650 |
if order.status != OrderStatus.DELIVERY_SUCCESS and order.status != OrderStatus.DOA_REQUEST_AUTHORIZED and order.status != OrderStatus.RET_REQUEST_AUTHORIZED:
|
1660 |
if order.status != OrderStatus.DELIVERY_SUCCESS and order.status != OrderStatus.DOA_REQUEST_AUTHORIZED and order.status != OrderStatus.RET_REQUEST_AUTHORIZED:
|
| 1651 |
return False
|
1661 |
return False
|
| 1652 |
from_user = 'cnc.center@shop2020.in'
|
- |
|
| 1653 |
from_pwd = '5h0p2o2o'
|
- |
|
| 1654 |
|
1662 |
|
| 1655 |
subject = "Pickup request from " + order.customer_city
|
1663 |
subject = "Pickup request from " + order.customer_city
|
| 1656 |
try:
|
1664 |
try:
|
| 1657 |
inventory_client = InventoryClient().get_client()
|
1665 |
inventory_client = InventoryClient().get_client()
|
| 1658 |
warehouse = inventory_client.getWarehouse(order.warehouse_id)
|
1666 |
warehouse = inventory_client.getWarehouse(order.warehouse_id)
|
| Line 1694... |
Line 1702... |
| 1694 |
'warehouse_executive' : executive,
|
1702 |
'warehouse_executive' : executive,
|
| 1695 |
'warehouse_address' : warehouse.location,
|
1703 |
'warehouse_address' : warehouse.location,
|
| 1696 |
'warehouse_pin' : warehouse.pincode}
|
1704 |
'warehouse_pin' : warehouse.pincode}
|
| 1697 |
to_addresses = [to_addr, 'gaurabh.verma@shop2020.in', 'suraj.sharma@shop2020.in']
|
1705 |
to_addresses = [to_addr, 'gaurabh.verma@shop2020.in', 'suraj.sharma@shop2020.in']
|
| 1698 |
|
1706 |
|
| 1699 |
mail(from_user, from_pwd, to_addresses, subject, message)
|
1707 |
mail(mail_user, mail_password, to_addresses, subject, message)
|
| 1700 |
if order.status == OrderStatus.RET_REQUEST_AUTHORIZED:
|
1708 |
if order.status == OrderStatus.RET_REQUEST_AUTHORIZED:
|
| 1701 |
order.status = OrderStatus.RET_PICKUP_REQUEST_RAISED
|
1709 |
order.status = OrderStatus.RET_PICKUP_REQUEST_RAISED
|
| 1702 |
order.statusDescription = "Pick up requested for RETURN"
|
1710 |
order.statusDescription = "Pick up requested for RETURN"
|
| 1703 |
else:
|
1711 |
else:
|
| 1704 |
order.status = OrderStatus.DOA_PICKUP_REQUEST_RAISED
|
1712 |
order.status = OrderStatus.DOA_PICKUP_REQUEST_RAISED
|
| Line 1714... |
Line 1722... |
| 1714 |
order = get_order(order_id)
|
1722 |
order = get_order(order_id)
|
| 1715 |
if order.status not in [OrderStatus.DOA_PICKUP_REQUEST_RAISED, OrderStatus.RET_PICKUP_REQUEST_RAISED]:
|
1723 |
if order.status not in [OrderStatus.DOA_PICKUP_REQUEST_RAISED, OrderStatus.RET_PICKUP_REQUEST_RAISED]:
|
| 1716 |
return False
|
1724 |
return False
|
| 1717 |
if order.doa_logistics_provider_id is not None:
|
1725 |
if order.doa_logistics_provider_id is not None:
|
| 1718 |
providerId = order.doa_logistics_provider_id #previously we are not storing this so data is taken from omdashboarduser
|
1726 |
providerId = order.doa_logistics_provider_id #previously we are not storing this so data is taken from omdashboarduser
|
| 1719 |
from_user = 'help@shop2020.in'
|
- |
|
| 1720 |
from_pwd = '5h0p2o2o'
|
- |
|
| 1721 |
subject = 'Pickup details'
|
1727 |
subject = 'Pickup details'
|
| 1722 |
filename = "/tmp/" + str(order.id) +".pdf"
|
1728 |
filename = "/tmp/" + str(order.id) +".pdf"
|
| 1723 |
try:
|
1729 |
try:
|
| 1724 |
inventory_client = InventoryClient().get_client()
|
1730 |
inventory_client = InventoryClient().get_client()
|
| 1725 |
warehouse = inventory_client.getWarehouse(order.warehouse_id)
|
1731 |
warehouse = inventory_client.getWarehouse(order.warehouse_id)
|
| Line 1754... |
Line 1760... |
| 1754 |
'date': today,
|
1760 |
'date': today,
|
| 1755 |
'pickup_request_no' : pickup_number,
|
1761 |
'pickup_request_no' : pickup_number,
|
| 1756 |
'customer_address' : __get_order_address(order)}
|
1762 |
'customer_address' : __get_order_address(order)}
|
| 1757 |
print message
|
1763 |
print message
|
| 1758 |
__generate_return_advice(order, warehouse, provider, filename)
|
1764 |
__generate_return_advice(order, warehouse, provider, filename)
|
| 1759 |
mail(from_user, from_pwd, [to_addr], subject, message, [get_attachment_part(filename)])
|
1765 |
mail(help_user, help_password, [to_addr], subject, message, [get_attachment_part(filename)])
|
| 1760 |
order.pickupRequestNo = pickup_number
|
1766 |
order.pickupRequestNo = pickup_number
|
| 1761 |
if order.status == OrderStatus.RET_PICKUP_REQUEST_RAISED:
|
1767 |
if order.status == OrderStatus.RET_PICKUP_REQUEST_RAISED:
|
| 1762 |
order.status = OrderStatus.RET_PICKUP_CONFIRMED
|
1768 |
order.status = OrderStatus.RET_PICKUP_CONFIRMED
|
| 1763 |
order.statusDescription = "RETURN pick up confirmed"
|
1769 |
order.statusDescription = "RETURN pick up confirmed"
|
| 1764 |
else:
|
1770 |
else:
|
| Line 2222... |
Line 2228... |
| 2222 |
Reduce the reservation count for all line items of the given order.
|
2228 |
Reduce the reservation count for all line items of the given order.
|
| 2223 |
'''
|
2229 |
'''
|
| 2224 |
try:
|
2230 |
try:
|
| 2225 |
inventoryClient = InventoryClient().get_client()
|
2231 |
inventoryClient = InventoryClient().get_client()
|
| 2226 |
for lineitem in order.lineitems:
|
2232 |
for lineitem in order.lineitems:
|
| 2227 |
inventoryClient.reduceReservationCount(lineitem.item_id, order.fulfilmentWarehouseId, lineitem.quantity)
|
2233 |
inventoryClient.reduceReservationCount(lineitem.item_id, order.fulfilmentWarehouseId, sourceId, order.id, lineitem.quantity)
|
| 2228 |
except:
|
2234 |
except:
|
| 2229 |
print "Unable to reduce reservation count"
|
2235 |
print "Unable to reduce reservation count"
|
| 2230 |
|
2236 |
|
| 2231 |
def __clone_order(order, should_copy_billing_info, is_cod):
|
2237 |
def __clone_order(order, should_copy_billing_info, is_cod):
|
| 2232 |
current_time = datetime.datetime.now()
|
2238 |
current_time = datetime.datetime.now()
|
| Line 2296... |
Line 2302... |
| 2296 |
new_order.lineitems[0].item_number = order.lineitems[0].item_number
|
2302 |
new_order.lineitems[0].item_number = order.lineitems[0].item_number
|
| 2297 |
new_order.accepted_timestamp = current_time
|
2303 |
new_order.accepted_timestamp = current_time
|
| 2298 |
new_order.billing_timestamp = current_time
|
2304 |
new_order.billing_timestamp = current_time
|
| 2299 |
new_order.status = OrderStatus.BILLED
|
2305 |
new_order.status = OrderStatus.BILLED
|
| 2300 |
new_order.statusDescription = 'Order Billed'
|
2306 |
new_order.statusDescription = 'Order Billed'
|
| 2301 |
else:
|
2307 |
else:
|
| - |
|
2308 |
session.commit()
|
| 2302 |
inventoryClient = InventoryClient().get_client()
|
2309 |
inventoryClient = InventoryClient().get_client()
|
| 2303 |
inventoryClient.reserveItemInWarehouse(item_id, logistics_info.fulfilmentWarehouseId, new_order.lineitems[0].quantity)
|
2310 |
inventoryClient.reserveItemInWarehouse(item_id, logistics_info.fulfilmentWarehouseId, sourceId, new_order.id, to_java_date(new_order.created_timestamp), to_java_date(new_order.promised_shipping_time), new_order.lineitems[0].quantity)
|
| 2304 |
|
2311 |
|
| 2305 |
return new_order
|
2312 |
return new_order
|
| 2306 |
|
2313 |
|
| 2307 |
def __create_return_order(order):
|
2314 |
def __create_return_order(order):
|
| 2308 |
ret_order = ReturnOrder(order)
|
2315 |
ret_order = ReturnOrder(order)
|
| Line 2522... |
Line 2529... |
| 2522 |
item = catalog_client.getItem(item_id)
|
2529 |
item = catalog_client.getItem(item_id)
|
| 2523 |
if old_item.catalogItemId != item.catalogItemId:
|
2530 |
if old_item.catalogItemId != item.catalogItemId:
|
| 2524 |
raise TransactionServiceException(121, "You can't ship a different item. You can only ship the same item in a different color.")
|
2531 |
raise TransactionServiceException(121, "You can't ship a different item. You can only ship the same item in a different color.")
|
| 2525 |
|
2532 |
|
| 2526 |
inventoryClient = InventoryClient().get_client()
|
2533 |
inventoryClient = InventoryClient().get_client()
|
| 2527 |
inventoryClient.reserveItemInWarehouse(item_id, order.fulfilmentWarehouseId, lineitem.quantity)
|
2534 |
inventoryClient.reserveItemInWarehouse(item_id, order.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 2528 |
__update_inventory_reservation(order)
|
2535 |
__update_inventory_reservation(order)
|
| 2529 |
#TODO: Check that this new item has the same price
|
2536 |
#TODO: Check that this new item has the same price
|
| 2530 |
|
2537 |
|
| 2531 |
lineitem.item_id = item_id
|
2538 |
lineitem.item_id = item_id
|
| 2532 |
lineitem.color = item.color
|
2539 |
lineitem.color = item.color
|
| Line 2579... |
Line 2586... |
| 2579 |
if goodWarehouse.vendor.id == item.preferredVendor:
|
2586 |
if goodWarehouse.vendor.id == item.preferredVendor:
|
| 2580 |
warehouse = goodWarehouse
|
2587 |
warehouse = goodWarehouse
|
| 2581 |
else:
|
2588 |
else:
|
| 2582 |
raise TransactionServiceException(119, "Shifting of warehouse allowed to GOOD inventory type warehouse with billing support")
|
2589 |
raise TransactionServiceException(119, "Shifting of warehouse allowed to GOOD inventory type warehouse with billing support")
|
| 2583 |
|
2590 |
|
| 2584 |
inventoryClient.reserveItemInWarehouse(lineitem.item_id, warehouse.id, lineitem.quantity)
|
2591 |
inventoryClient.reserveItemInWarehouse(lineitem.item_id, warehouse.id, order.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), lineitem.quantity)
|
| 2585 |
__update_inventory_reservation(order)
|
2592 |
__update_inventory_reservation(order)
|
| 2586 |
|
2593 |
|
| 2587 |
order.warehouse_id = warehouse.billingWarehouseId
|
2594 |
order.warehouse_id = warehouse.billingWarehouseId
|
| 2588 |
order.fulfilmentWarehouseId = warehouse.id
|
2595 |
order.fulfilmentWarehouseId = warehouse.id
|
| 2589 |
session.commit()
|
2596 |
session.commit()
|
| Line 3314... |
Line 3321... |
| 3314 |
lineitem = order.lineitems[0]
|
3321 |
lineitem = order.lineitems[0]
|
| 3315 |
if lineitem.item_id == itemId and lineitem.quantity <= quantity:
|
3322 |
if lineitem.item_id == itemId and lineitem.quantity <= quantity:
|
| 3316 |
warehouse = inventoryClient.getWarehouse(order.fulfilmentWarehouseId)
|
3323 |
warehouse = inventoryClient.getWarehouse(order.fulfilmentWarehouseId)
|
| 3317 |
if not warehouse.billingWarehouseId and warehouse.warehouseType == WarehouseType.THIRD_PARTY:
|
3324 |
if not warehouse.billingWarehouseId and warehouse.warehouseType == WarehouseType.THIRD_PARTY:
|
| 3318 |
if (inventory.availability[fulfilmentWarehouseId] >= inventory.reserved[fulfilmentWarehouseId] + lineitem.quantity) and inventory.availability[order.fulfilmentWarehouseId] < inventory.reserved[order.fulfilmentWarehouseId]:
|
3325 |
if (inventory.availability[fulfilmentWarehouseId] >= inventory.reserved[fulfilmentWarehouseId] + lineitem.quantity) and inventory.availability[order.fulfilmentWarehouseId] < inventory.reserved[order.fulfilmentWarehouseId]:
|
| 3319 |
inventoryClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, lineitem.quantity)
|
3326 |
inventoryClient.reduceReservationCount(itemId, order.fulfilmentWarehouseId, sourceId, order.id, lineitem.quantity)
|
| 3320 |
inventoryClient.reserveItemInWarehouse(itemId, fulfilmentWarehouseId, lineitem.quantity)
|
3327 |
inventoryClient.reserveItemInWarehouse(itemId, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), lineitem.quantity)
|
| 3321 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
3328 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| 3322 |
quantity -= lineitem.quantity
|
3329 |
quantity -= lineitem.quantity
|
| 3323 |
session.commit()
|
3330 |
session.commit()
|
| 3324 |
if not quantity:
|
3331 |
if not quantity:
|
| 3325 |
break
|
3332 |
break
|