| Line 329... |
Line 329... |
| 329 |
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)
|
329 |
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)
|
| 330 |
|
330 |
|
| 331 |
try:
|
331 |
try:
|
| 332 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
332 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 333 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
333 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| - |
|
334 |
order.lineitems[0].nlc = item_pricing.nlc
|
| 334 |
except:
|
335 |
except:
|
| 335 |
print "Not able to get transfer price. Skipping"
|
336 |
print "Not able to get transfer price. Skipping"
|
| 336 |
|
337 |
|
| 337 |
catalog_client = CatalogClient().get_client()
|
338 |
catalog_client = CatalogClient().get_client()
|
| 338 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
339 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
| Line 380... |
Line 381... |
| 380 |
inventory_client = InventoryClient().get_client()
|
381 |
inventory_client = InventoryClient().get_client()
|
| 381 |
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)
|
382 |
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)
|
| 382 |
|
383 |
|
| 383 |
try:
|
384 |
try:
|
| 384 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
385 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 385 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
386 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| - |
|
387 |
order.lineitems[0].nlc = item_pricing.nlc
|
| 386 |
except:
|
388 |
except:
|
| 387 |
print "Not able to get transfer price. Skipping"
|
389 |
print "Not able to get transfer price. Skipping"
|
| 388 |
|
390 |
|
| 389 |
catalog_client = CatalogClient().get_client()
|
391 |
catalog_client = CatalogClient().get_client()
|
| 390 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
392 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
| Line 1169... |
Line 1171... |
| 1169 |
|
1171 |
|
| 1170 |
catalog_client = CatalogClient().get_client()
|
1172 |
catalog_client = CatalogClient().get_client()
|
| 1171 |
item = catalog_client.getItem(item_id)
|
1173 |
item = catalog_client.getItem(item_id)
|
| 1172 |
if order.status == OrderStatus.ACCEPTED:
|
1174 |
if order.status == OrderStatus.ACCEPTED:
|
| 1173 |
order.jacket_number = jacketNumber
|
1175 |
order.jacket_number = jacketNumber
|
| - |
|
1176 |
|
| - |
|
1177 |
if itemNumbers:
|
| - |
|
1178 |
lineitem.item_number = itemNumbers[0]
|
| - |
|
1179 |
if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
|
| - |
|
1180 |
raise TransactionServiceException(110, "No Serial Number supplied")
|
| - |
|
1181 |
if serialNumbers:
|
| - |
|
1182 |
lineitem.serial_number = serialNumbers[0]
|
| - |
|
1183 |
|
| 1174 |
if billingType == BillingType.OURS:
|
1184 |
if billingType == BillingType.EXTERNAL or billingType == BillingType.OURS_EXTERNAL:
|
| 1175 |
if itemNumbers:
|
1185 |
if itemNumbers:
|
| 1176 |
lineitem.item_number = itemNumbers[0]
|
1186 |
lineitem.item_number = itemNumbers[0]
|
| 1177 |
|
- |
|
| 1178 |
if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
|
1187 |
if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
|
| 1179 |
raise TransactionServiceException(110, "No Serial Number supplied")
|
1188 |
raise TransactionServiceException(110, "No Serial Number supplied")
|
| 1180 |
if serialNumbers:
|
1189 |
if serialNumbers:
|
| 1181 |
lineitem.serial_number = serialNumbers[0]
|
1190 |
lineitem.serial_number = serialNumbers[0]
|
| 1182 |
|
- |
|
| 1183 |
order.invoice_number = get_next_invoice_number(order.orderType)
|
- |
|
| 1184 |
else:
|
1191 |
|
| 1185 |
order.invoice_number = invoice_number
|
- |
|
| 1186 |
# In case of hotspot billing, we should try to verify that color billed in ETP is same as color in order.
|
- |
|
| 1187 |
if billedOrdersColorMap.has_key(orderId):
|
1192 |
if billedOrdersColorMap.has_key(orderId):
|
| 1188 |
etpColor = billedOrdersColorMap.get(orderId)
|
1193 |
etpColor = billedOrdersColorMap.get(orderId)
|
| 1189 |
ourColor = order.lineitems[0].color
|
1194 |
ourColor = order.lineitems[0].color
|
| 1190 |
if ourColor and etpColor != ourColor and not authorize:
|
1195 |
if ourColor and etpColor != ourColor and not authorize:
|
| 1191 |
raise TransactionServiceException(777, "ETP color: " + etpColor + " and Order color: " + ourColor)
|
1196 |
raise TransactionServiceException(777, "ETP color: " + etpColor + " and Order color: " + ourColor)
|
| 1192 |
else:
|
1197 |
else:
|
| 1193 |
billedOrdersColorMap.pop(orderId)
|
1198 |
billedOrdersColorMap.pop(orderId)
|
| - |
|
1199 |
|
| - |
|
1200 |
if billingType == BillingType.EXTERNAL:
|
| - |
|
1201 |
order.invoice_number = invoice_number
|
| - |
|
1202 |
|
| - |
|
1203 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
| - |
|
1204 |
order.invoice_number = get_next_invoice_number(order.orderType)
|
| 1194 |
|
1205 |
|
| 1195 |
order.status = OrderStatus.BILLED
|
1206 |
order.status = OrderStatus.BILLED
|
| 1196 |
order.statusDescription = "Order Billed"
|
1207 |
order.statusDescription = "Order Billed"
|
| 1197 |
order.billing_timestamp = datetime.datetime.now()
|
1208 |
order.billing_timestamp = datetime.datetime.now()
|
| 1198 |
order.billed_by = billedBy
|
1209 |
order.billed_by = billedBy
|
| Line 1202... |
Line 1213... |
| 1202 |
try:
|
1213 |
try:
|
| 1203 |
inventory_client = InventoryClient().get_client()
|
1214 |
inventory_client = InventoryClient().get_client()
|
| 1204 |
warehouse = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
1215 |
warehouse = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| 1205 |
item_pricing = inventory_client.getItemPricing(item_id, warehouse.vendor.id)
|
1216 |
item_pricing = inventory_client.getItemPricing(item_id, warehouse.vendor.id)
|
| 1206 |
lineitem.transfer_price = item_pricing.transferPrice
|
1217 |
lineitem.transfer_price = item_pricing.transferPrice
|
| - |
|
1218 |
lineitem.nlc = item_pricing.nlc
|
| 1207 |
lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, lineitem.unit_price)
|
1219 |
lineitem.vatRate = catalog_client.getVatPercentageForItem(lineitem.item_id, lineitem.unit_price)
|
| 1208 |
order.vendorId = warehouse.vendor.id
|
1220 |
order.vendorId = warehouse.vendor.id
|
| 1209 |
except InventoryServiceException as e:
|
1221 |
except InventoryServiceException as e:
|
| 1210 |
print sys.exc_info()[0]
|
1222 |
print sys.exc_info()[0]
|
| 1211 |
print e.message
|
1223 |
print e.message
|
| Line 1242... |
Line 1254... |
| 1242 |
catalog_client = CatalogClient().get_client()
|
1254 |
catalog_client = CatalogClient().get_client()
|
| 1243 |
except WarehouseServiceException as e:
|
1255 |
except WarehouseServiceException as e:
|
| 1244 |
print sys.exc_info()[0]
|
1256 |
print sys.exc_info()[0]
|
| 1245 |
print 'Could not scan out orders due to: ' + e.message
|
1257 |
print 'Could not scan out orders due to: ' + e.message
|
| 1246 |
raise TransactionServiceException(110, e.message)
|
1258 |
raise TransactionServiceException(110, e.message)
|
| - |
|
1259 |
'''elif billingType == BillingType.OURS_EXTERNAL:
|
| - |
|
1260 |
try:
|
| - |
|
1261 |
serialNumber = serialNumbers[0]
|
| - |
|
1262 |
warehouse_client = WarehouseClient().get_client()
|
| - |
|
1263 |
inventoryItem = warehouse_client.scanForOursExternalSale(lineitem.item_number, serialNumber, invoice_number, order.fulfilmentWarehouseId, lineitem.transfer_price)
|
| - |
|
1264 |
lineitem.transfer_price = inventoryItem.unitPrice
|
| - |
|
1265 |
order.vendorId = inventoryItem.supplierId
|
| - |
|
1266 |
except WarehouseServiceException as e:
|
| - |
|
1267 |
print sys.exc_info()[0]
|
| - |
|
1268 |
print 'Could not scan out orders due to: ' + e.message
|
| - |
|
1269 |
raise TransactionServiceException(110, e.message)
|
| - |
|
1270 |
'''
|
| 1247 |
else:
|
1271 |
else:
|
| 1248 |
if not warehouse.isAvailabilityMonitored:
|
1272 |
if not warehouse.isAvailabilityMonitored:
|
| 1249 |
inventory_client = InventoryClient().get_client()
|
1273 |
inventory_client = InventoryClient().get_client()
|
| 1250 |
inventory_client.addInventory(item.id, warehouse.id, -1 * lineitem.quantity)
|
1274 |
inventory_client.addInventory(item.id, warehouse.id, -1 * lineitem.quantity)
|
| 1251 |
|
1275 |
|
| Line 1254... |
Line 1278... |
| 1254 |
session.commit()
|
1278 |
session.commit()
|
| 1255 |
return True
|
1279 |
return True
|
| 1256 |
else:
|
1280 |
else:
|
| 1257 |
return False
|
1281 |
return False
|
| 1258 |
|
1282 |
|
| 1259 |
def add_invoice_number(orderId, invoiceNumber, color):
|
1283 |
def add_invoice_number(orderId, invoiceNumber, color, serialNumber, itemNumber):
|
| 1260 |
order = Order.get_by(id=orderId)
|
1284 |
order = Order.get_by(id=orderId)
|
| 1261 |
if not order:
|
1285 |
if not order:
|
| 1262 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
1286 |
raise TransactionServiceException(101, "No order found for the given order id" + str(orderId))
|
| 1263 |
|
1287 |
|
| 1264 |
if order.status == OrderStatus.ACCEPTED:
|
1288 |
if order.status == OrderStatus.ACCEPTED:
|
| 1265 |
order.invoice_number = invoiceNumber
|
1289 |
order.invoice_number = invoiceNumber
|
| 1266 |
if color:
|
1290 |
if color:
|
| 1267 |
billedOrdersColorMap[orderId] = color;
|
1291 |
billedOrdersColorMap[orderId] = color;
|
| - |
|
1292 |
if serialNumber:
|
| - |
|
1293 |
order.lineitems[0].serial_number = serialNumber
|
| - |
|
1294 |
if itemNumber:
|
| - |
|
1295 |
order.lineitems[0].item_number = itemNumber
|
| 1268 |
session.commit()
|
1296 |
session.commit()
|
| 1269 |
|
1297 |
|
| 1270 |
def batch_orders(warehouseId):
|
1298 |
def batch_orders(warehouseId):
|
| 1271 |
if not warehouseId:
|
1299 |
if not warehouseId:
|
| 1272 |
raise TransactionServiceException(101, "bad warehouse id")
|
1300 |
raise TransactionServiceException(101, "bad warehouse id")
|
| Line 2467... |
Line 2495... |
| 2467 |
litem.unit_price = line_item.unit_price
|
2495 |
litem.unit_price = line_item.unit_price
|
| 2468 |
litem.unit_weight = line_item.unit_weight
|
2496 |
litem.unit_weight = line_item.unit_weight
|
| 2469 |
litem.total_price = line_item.total_price
|
2497 |
litem.total_price = line_item.total_price
|
| 2470 |
litem.total_weight = line_item.total_weight
|
2498 |
litem.total_weight = line_item.total_weight
|
| 2471 |
litem.transfer_price = line_item.transfer_price
|
2499 |
litem.transfer_price = line_item.transfer_price
|
| - |
|
2500 |
litem.nlc = line_item.nlc
|
| 2472 |
litem.dealText = line_item.dealText
|
2501 |
litem.dealText = line_item.dealText
|
| 2473 |
litem.vatRate = line_item.vatRate
|
2502 |
litem.vatRate = line_item.vatRate
|
| 2474 |
litem.order = new_order
|
2503 |
litem.order = new_order
|
| 2475 |
|
2504 |
|
| 2476 |
logistics_client = LogisticsClient().get_client()
|
2505 |
logistics_client = LogisticsClient().get_client()
|