| Line 430... |
Line 430... |
| 430 |
if OrderType.B2B == order.orderType:
|
430 |
if OrderType.B2B == order.orderType:
|
| 431 |
#get state
|
431 |
#get state
|
| 432 |
stateMaster = fetchStateMaster()
|
432 |
stateMaster = fetchStateMaster()
|
| 433 |
stateId = -1
|
433 |
stateId = -1
|
| 434 |
for k, v in stateMaster.iteritems():
|
434 |
for k, v in stateMaster.iteritems():
|
| 435 |
if v.state == order.customer_state:
|
435 |
if v.stateName == order.customer_state:
|
| 436 |
stateId = k
|
436 |
stateId = k
|
| 437 |
break
|
437 |
break
|
| 438 |
if stateId == -1:
|
438 |
if stateId == -1:
|
| 439 |
raise TransactionServiceException(108, "No such State")
|
439 |
raise TransactionServiceException(108, "No such State")
|
| - |
|
440 |
if not inventory_client.isAlive():
|
| - |
|
441 |
inventory_client = InventoryClient().get_client()
|
| - |
|
442 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
443 |
if stateId!= ffWarehouse.stateId:
|
| 440 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
444 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| 441 |
if goodWhIds is None or len(goodWhIds) == 0:
|
445 |
if goodWhIds is None or len(goodWhIds) == 0:
|
| 442 |
raise TransactionServiceException(108, "No availability from this location")
|
446 |
raise TransactionServiceException(108, "No availability from this location")
|
| 443 |
fulfilmentWarehouseId = goodWhIds[0]
|
447 |
fulfilmentWarehouseId = goodWhIds[0]
|
| 444 |
for goodWhId in goodWhIds:
|
448 |
for goodWhId in goodWhIds:
|
| 445 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
449 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| 446 |
if availability > 0:
|
450 |
if availability > 0:
|
| 447 |
fulfillmentWh = inventory_client.getWarehouse(goodWhId)
|
451 |
fulfillmentWh = inventory_client.getWarehouse(goodWhId)
|
| 448 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
452 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| 449 |
fulfilmentWarehouseId = goodWhId
|
453 |
fulfilmentWarehouseId = goodWhId
|
| 450 |
break
|
454 |
break
|
| 451 |
|
455 |
|
| 452 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
456 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| 453 |
|
457 |
|
| 454 |
|
458 |
|
| 455 |
|
459 |
|
| 456 |
|
460 |
|
| 457 |
if order.pickupStoreId:
|
461 |
if order.pickupStoreId:
|
| Line 519... |
Line 523... |
| 519 |
if OrderType.B2B == order.orderType:
|
523 |
if OrderType.B2B == order.orderType:
|
| 520 |
#get state
|
524 |
#get state
|
| 521 |
stateMaster = fetchStateMaster()
|
525 |
stateMaster = fetchStateMaster()
|
| 522 |
stateId = -1
|
526 |
stateId = -1
|
| 523 |
for k, v in stateMaster.iteritems():
|
527 |
for k, v in stateMaster.iteritems():
|
| 524 |
if v.state == order.customer_state:
|
528 |
if v.stateName == order.customer_state:
|
| 525 |
stateId = k
|
529 |
stateId = k
|
| 526 |
break
|
530 |
break
|
| 527 |
if stateId == -1:
|
531 |
if stateId == -1:
|
| 528 |
raise TransactionServiceException(108, "No such State")
|
532 |
raise TransactionServiceException(108, "No such State")
|
| - |
|
533 |
if not inventory_client.isAlive():
|
| - |
|
534 |
inventory_client = InventoryClient().get_client()
|
| - |
|
535 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
536 |
if stateId!= ffWarehouse.stateId:
|
| 529 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
537 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| 530 |
|
538 |
|
| 531 |
if goodWhIds is None or len(goodWhIds) == 0:
|
539 |
if goodWhIds is None or len(goodWhIds) == 0:
|
| 532 |
raise TransactionServiceException(108, "No availability from this location")
|
540 |
raise TransactionServiceException(108, "No availability from this location")
|
| 533 |
fulfilmentWarehouseId = goodWhIds[0]
|
541 |
fulfilmentWarehouseId = goodWhIds[0]
|
| 534 |
for goodWhId in goodWhIds:
|
542 |
for goodWhId in goodWhIds:
|
| 535 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
543 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| 536 |
if availability > 0:
|
544 |
if availability > 0:
|
| 537 |
fulfillmentWh = inventory_client.getWarehouse(goodWhId)
|
545 |
fulfillmentWh = inventory_client.getWarehouse(goodWhId)
|
| 538 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
546 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| 539 |
fulfilmentWarehouseId = goodWhId
|
547 |
fulfilmentWarehouseId = goodWhId
|
| 540 |
break
|
548 |
break
|
| 541 |
|
549 |
|
| 542 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
550 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| 543 |
|
551 |
|
| 544 |
if order.productCondition != ProductCondition.BAD:
|
552 |
if order.productCondition != ProductCondition.BAD:
|
| 545 |
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)
|
553 |
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)
|
| 546 |
|
554 |
|
| 547 |
try:
|
555 |
try:
|