| Line 428... |
Line 428... |
| 428 |
|
428 |
|
| 429 |
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
|
429 |
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
|
| 430 |
transaction = get_transaction(transaction_id)
|
430 |
transaction = get_transaction(transaction_id)
|
| 431 |
transaction.status = new_status
|
431 |
transaction.status = new_status
|
| 432 |
transaction.status_message = description
|
432 |
transaction.status_message = description
|
| - |
|
433 |
expectedDelayMap = {}
|
| - |
|
434 |
billingWarehouseIdMap = {}
|
| - |
|
435 |
billingWarehouseTxnMap = {}
|
| 433 |
## Assign runner in case of delhi pincodes
|
436 |
## Assign runner in case of delhi pincodes
|
| 434 |
if transaction.orders[0].pickupStoreId:
|
437 |
if transaction.orders[0].pickupStoreId:
|
| 435 |
logistics_client = LogisticsClient().get_client()
|
438 |
logistics_client = LogisticsClient().get_client()
|
| 436 |
store = logistics_client.getPickupStore(transaction.orders[0].pickupStoreId)
|
439 |
store = logistics_client.getPickupStore(transaction.orders[0].pickupStoreId)
|
| 437 |
if delhi_pincodes.__contains__(store.pin):
|
440 |
if delhi_pincodes.__contains__(store.pin):
|
| Line 439... |
Line 442... |
| 439 |
|
442 |
|
| 440 |
if new_status == TransactionStatus.FAILED:
|
443 |
if new_status == TransactionStatus.FAILED:
|
| 441 |
for order in transaction.orders:
|
444 |
for order in transaction.orders:
|
| 442 |
order.status = OrderStatus.PAYMENT_FAILED
|
445 |
order.status = OrderStatus.PAYMENT_FAILED
|
| 443 |
order.statusDescription = "Payment Failed"
|
446 |
order.statusDescription = "Payment Failed"
|
| 444 |
elif new_status == TransactionStatus.AUTHORIZED or new_status == TransactionStatus.FLAGGED:
|
447 |
elif new_status == TransactionStatus.AUTHORIZED or new_status == TransactionStatus.FLAGGED:
|
| 445 |
|
- |
|
| - |
|
448 |
expectedDelayMap = {}
|
| - |
|
449 |
billingWarehouseIdMap = {}
|
| - |
|
450 |
billingWarehouseTxnMap = {}
|
| 446 |
for order in transaction.orders:
|
451 |
for order in transaction.orders:
|
| 447 |
if new_status == TransactionStatus.AUTHORIZED:
|
452 |
if new_status == TransactionStatus.AUTHORIZED:
|
| 448 |
order.status = OrderStatus.SUBMITTED_FOR_PROCESSING
|
453 |
order.status = OrderStatus.SUBMITTED_FOR_PROCESSING
|
| 449 |
order.statusDescription = "Submitted to warehouse"
|
454 |
order.statusDescription = "Submitted to warehouse"
|
| 450 |
elif new_status == TransactionStatus.FLAGGED:
|
455 |
elif new_status == TransactionStatus.FLAGGED:
|
| Line 454... |
Line 459... |
| 454 |
order.orderType = orderType
|
459 |
order.orderType = orderType
|
| 455 |
#After we got payment success, we will set logistics info also
|
460 |
#After we got payment success, we will set logistics info also
|
| 456 |
logistics_client = LogisticsClient().get_client()
|
461 |
logistics_client = LogisticsClient().get_client()
|
| 457 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
462 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
| 458 |
item_id = order.lineitems[0].item_id
|
463 |
item_id = order.lineitems[0].item_id
|
| - |
|
464 |
if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF or order.source!=OrderSource.WEBSITE:
|
| 459 |
logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.PREPAID, pickUp)
|
465 |
logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.PREPAID, pickUp)
|
| 460 |
|
- |
|
| 461 |
current_time = datetime.datetime.now()
|
466 |
current_time = datetime.datetime.now()
|
| 462 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
467 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
| 463 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
468 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
| 464 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
469 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
| 465 |
|
470 |
|
| 466 |
order.otg = logistics_info.otgAvailable
|
471 |
order.otg = logistics_info.otgAvailable
|
| 467 |
order.warehouse_id = logistics_info.warehouseId
|
472 |
order.warehouse_id = logistics_info.warehouseId
|
| 468 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
473 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| 469 |
order.logistics_provider_id = logistics_info.providerId
|
474 |
order.logistics_provider_id = logistics_info.providerId
|
| 470 |
#Start:- Added by Manish Sharma for FedEx Integration - Shipment Creation on 31-Jul-2013
|
475 |
#Start:- Added by Manish Sharma for FedEx Integration - Shipment Creation on 31-Jul-2013
|
| 471 |
#order.airwaybill_no = logistics_info.airway_billno
|
476 |
#order.airwaybill_no = logistics_info.airway_billno
|
| 472 |
#order.tracking_id = order.airwaybill_no
|
477 |
#order.tracking_id = order.airwaybill_no
|
| 473 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
478 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
| 474 |
if order.source != OrderSource.AMAZON or order.source != OrderSource.JUNGLEE:
|
479 |
if order.source != OrderSource.AMAZON or order.source != OrderSource.JUNGLEE:
|
| 475 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
480 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 476 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
481 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 477 |
order.promised_shipping_time = order.expected_shipping_time
|
482 |
order.promised_shipping_time = order.expected_shipping_time
|
| 478 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
483 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 479 |
order.promised_delivery_time = order.expected_delivery_time
|
484 |
order.promised_delivery_time = order.expected_delivery_time
|
| - |
|
485 |
|
| - |
|
486 |
inventory_client = InventoryClient().get_client()
|
| - |
|
487 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| - |
|
488 |
if OrderType.B2B == order.orderType:
|
| - |
|
489 |
#get state
|
| - |
|
490 |
stateMaster = fetchStateMaster()
|
| - |
|
491 |
stateId = -1
|
| - |
|
492 |
for k, v in stateMaster.iteritems():
|
| - |
|
493 |
if v.stateName == order.customer_state:
|
| - |
|
494 |
stateId = k
|
| - |
|
495 |
break
|
| - |
|
496 |
if stateId == -1:
|
| - |
|
497 |
raise TransactionServiceException(108, "No such State")
|
| - |
|
498 |
if not inventory_client.isAlive():
|
| - |
|
499 |
inventory_client = InventoryClient().get_client()
|
| - |
|
500 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
501 |
if stateId!= ffWarehouse.stateId:
|
| - |
|
502 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| - |
|
503 |
if goodWhIds is None or len(goodWhIds) == 0:
|
| - |
|
504 |
raise TransactionServiceException(108, "No availability from this location")
|
| - |
|
505 |
fulfilmentWarehouseId = goodWhIds[0]
|
| - |
|
506 |
for goodWhId in goodWhIds:
|
| - |
|
507 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| - |
|
508 |
if availability > 0:
|
| - |
|
509 |
fulfilmentWarehouseId = goodWhId
|
| - |
|
510 |
break
|
| - |
|
511 |
|
| - |
|
512 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| - |
|
513 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| - |
|
514 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| - |
|
515 |
|
| - |
|
516 |
if order.pickupStoreId:
|
| - |
|
517 |
order.otg = False
|
| - |
|
518 |
|
| - |
|
519 |
if order.productCondition != ProductCondition.BAD:
|
| - |
|
520 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 480 |
|
521 |
|
| 481 |
inventory_client = InventoryClient().get_client()
|
- |
|
| 482 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
- |
|
| 483 |
if OrderType.B2B == order.orderType:
|
522 |
elif order.source == OrderSource.WEBSITE:
|
| 484 |
#get state
|
523 |
try:
|
| 485 |
stateMaster = fetchStateMaster()
|
- |
|
| 486 |
stateId = -1
|
- |
|
| 487 |
for k, v in stateMaster.iteritems():
|
- |
|
| 488 |
if v.stateName == order.customer_state:
|
- |
|
| 489 |
stateId = k
|
- |
|
| 490 |
break
|
- |
|
| 491 |
if stateId == -1:
|
- |
|
| 492 |
raise TransactionServiceException(108, "No such State")
|
524 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
| 493 |
if not inventory_client.isAlive():
|
- |
|
| 494 |
inventory_client = InventoryClient().get_client()
|
525 |
inventory_client = InventoryClient().get_client()
|
| 495 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
526 |
fulfilmentWhId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = inventory_client.getItemAvailabilityAtLocation(item_id, 1)
|
| 496 |
if stateId!= ffWarehouse.stateId:
|
527 |
except Exception as ex:
|
| 497 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
528 |
raise TransactionServiceException(103, "Unable to fetch inventory information about this item.")
|
| - |
|
529 |
|
| 498 |
if goodWhIds is None or len(goodWhIds) == 0:
|
530 |
expectedDelayMap[item_id] = expected_delay
|
| 499 |
raise TransactionServiceException(108, "No availability from this location")
|
531 |
if billingWarehouseIdMap.has_key(billingWarehouseId):
|
| 500 |
fulfilmentWarehouseId = goodWhIds[0]
|
532 |
ordersList = billingWarehouseIdMap.get(billingWarehouseId)
|
| 501 |
for goodWhId in goodWhIds:
|
533 |
ordersList.append(order)
|
| 502 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
534 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
| 503 |
if availability > 0:
|
535 |
else:
|
| 504 |
fulfilmentWarehouseId = goodWhId
|
536 |
ordersList = []
|
| 505 |
break
|
537 |
ordersList.append(order)
|
| - |
|
538 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
| 506 |
|
539 |
|
| 507 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
540 |
if billingWarehouseTxnMap.has_key(billingWarehouseId):
|
| 508 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
541 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
| 509 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
542 |
transactionAmount = transactionAmount+order.total_amount
|
| - |
|
543 |
transactionWeight = transactionWeight+order.total_weight
|
| - |
|
544 |
billingWarehouseTxnMap[billingWarehouseId] = transactionAmount , transactionWeight
|
| 510 |
|
545 |
else:
|
| - |
|
546 |
billingWarehouseTxnMap[billingWarehouseId] = order.total_amount , order.total_weight
|
| 511 |
if order.pickupStoreId:
|
547 |
|
| 512 |
order.otg = False
|
548 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
| 513 |
|
549 |
|
| - |
|
550 |
fulfilmentWarehouseId = fulfilmentWhId
|
| - |
|
551 |
if OrderType.B2B == order.orderType:
|
| - |
|
552 |
#get state
|
| - |
|
553 |
stateMaster = fetchStateMaster()
|
| - |
|
554 |
stateId = -1
|
| - |
|
555 |
for k, v in stateMaster.iteritems():
|
| - |
|
556 |
if v.stateName == order.customer_state:
|
| - |
|
557 |
stateId = k
|
| - |
|
558 |
break
|
| - |
|
559 |
if stateId == -1:
|
| - |
|
560 |
raise TransactionServiceException(108, "No such State")
|
| - |
|
561 |
if not inventory_client.isAlive():
|
| - |
|
562 |
inventory_client = InventoryClient().get_client()
|
| - |
|
563 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
564 |
if stateId!= ffWarehouse.stateId:
|
| - |
|
565 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| - |
|
566 |
if goodWhIds is None or len(goodWhIds) == 0:
|
| - |
|
567 |
raise TransactionServiceException(108, "No availability from this location")
|
| - |
|
568 |
fulfilmentWarehouseId = goodWhIds[0]
|
| - |
|
569 |
for goodWhId in goodWhIds:
|
| - |
|
570 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| - |
|
571 |
if availability > 0:
|
| - |
|
572 |
fulfilmentWarehouseId = goodWhId
|
| - |
|
573 |
break
|
| - |
|
574 |
|
| - |
|
575 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| - |
|
576 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| - |
|
577 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| - |
|
578 |
|
| - |
|
579 |
if order.pickupStoreId:
|
| - |
|
580 |
order.otg = False
|
| - |
|
581 |
|
| 514 |
if order.productCondition != ProductCondition.BAD:
|
582 |
if order.productCondition != ProductCondition.BAD:
|
| 515 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
583 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 516 |
|
584 |
|
| 517 |
try:
|
585 |
try:
|
| 518 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
586 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 519 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
587 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 520 |
order.lineitems[0].nlc = item_pricing.nlc
|
588 |
order.lineitems[0].nlc = item_pricing.nlc
|
| 521 |
except:
|
589 |
except:
|
| Line 534... |
Line 602... |
| 534 |
|
602 |
|
| 535 |
creditObj = __creditHistoryObj(singleOrder.customer_id, 1, transaction.id, total_amount, CreditTxnType.BLOCKED, str(transaction.id))
|
603 |
creditObj = __creditHistoryObj(singleOrder.customer_id, 1, transaction.id, total_amount, CreditTxnType.BLOCKED, str(transaction.id))
|
| 536 |
creditTxns = []
|
604 |
creditTxns = []
|
| 537 |
creditTxns.append(creditObj)
|
605 |
creditTxns.append(creditObj)
|
| 538 |
process_credit_transaction(transaction.id, singleOrder.customer_id, 1, creditTxns)
|
606 |
process_credit_transaction(transaction.id, singleOrder.customer_id, 1, creditTxns)
|
| - |
|
607 |
|
| - |
|
608 |
for billingWarehouseId, orders in billingWarehouseIdMap.items():
|
| - |
|
609 |
logistics_client = LogisticsClient().get_client()
|
| - |
|
610 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
| - |
|
611 |
costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, transactionAmount, False, transactionWeight, billingWarehouseId)
|
| - |
|
612 |
logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
|
| - |
|
613 |
logisticsCostInOrders = 0
|
| - |
|
614 |
current_time = datetime.datetime.now()
|
| - |
|
615 |
#delivery_delay
|
| - |
|
616 |
for order in orders:
|
| - |
|
617 |
expectedDelay = expectedDelayMap.get(order.lineitems[0].item_id)
|
| - |
|
618 |
shipping_delay = 24 * expectedDelay
|
| - |
|
619 |
if shipping_delay < 0:
|
| - |
|
620 |
shipping_delay = costingAndDeliveryEstimateObj.shippingTime
|
| - |
|
621 |
else:
|
| - |
|
622 |
shipping_delay = shipping_delay + 24 * costingAndDeliveryEstimateObj.shippingTime
|
| - |
|
623 |
shipping_delay = int(math.ceil(shipping_delay/24.0))
|
| - |
|
624 |
costingAndDeliveryEstimateObj.deliveryTime = adjust_delivery_time(current_time, costingAndDeliveryEstimateObj.deliveryTime+shipping_delay)
|
| - |
|
625 |
costingAndDeliveryEstimateObj.shippingTime = adjust_delivery_time(current_time, shipping_delay)
|
| - |
|
626 |
costingAndDeliveryEstimateObj.delivery_delay = adjust_delivery_time(current_time, shipping_delay+costingAndDeliveryEstimateObj.delivery_delay)
|
| - |
|
627 |
order.otg = costingAndDeliveryEstimateObj.otgAvailable
|
| - |
|
628 |
|
| - |
|
629 |
order.logistics_provider_id = costingAndDeliveryEstimateObj.logistics_provider_id
|
| - |
|
630 |
#Start:- Added by Manish Sharma for FedEx Integration - Shipment Creation on 31-Jul-2013
|
| - |
|
631 |
#order.airwaybill_no = logistics_info.airway_billno
|
| - |
|
632 |
#order.tracking_id = order.airwaybill_no
|
| - |
|
633 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
| - |
|
634 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=costingAndDeliveryEstimateObj.delivery_delay)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
635 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=costingAndDeliveryEstimateObj.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
636 |
order.promised_shipping_time = order.expected_shipping_time
|
| - |
|
637 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=costingAndDeliveryEstimateObj.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
638 |
order.promised_delivery_time = order.expected_delivery_time
|
| - |
|
639 |
itemLevelLogisticsCost = round((order.total_amount *logisticsCost)/transactionAmount, 0)
|
| - |
|
640 |
logisticsCostInOrders = logisticsCostInOrders + itemLevelLogisticsCost
|
| - |
|
641 |
order.lineitems[0].logisticsCost = itemLevelLogisticsCost
|
| - |
|
642 |
order.lineitems[0].codCollectionCharges = 0
|
| - |
|
643 |
|
| - |
|
644 |
orders[0].lineitems[0].logisticsCost = orders[0].lineitems[0].logisticsCost + (logisticsCost-logisticsCostInOrders)
|
| 539 |
|
645 |
|
| 540 |
elif new_status == TransactionStatus.COD_IN_PROCESS:
|
646 |
elif new_status == TransactionStatus.COD_IN_PROCESS:
|
| - |
|
647 |
expectedDelayMap = {}
|
| - |
|
648 |
billingWarehouseIdMap = {}
|
| - |
|
649 |
billingWarehouseTxnMap = {}
|
| 541 |
for order in transaction.orders:
|
650 |
for order in transaction.orders:
|
| 542 |
order.status = OrderStatus.COD_VERIFICATION_PENDING
|
651 |
order.status = OrderStatus.COD_VERIFICATION_PENDING
|
| 543 |
order.statusDescription = "Verification Pending"
|
652 |
order.statusDescription = "Verification Pending"
|
| 544 |
order.cod = True
|
653 |
order.cod = True
|
| 545 |
order.orderType = orderType
|
654 |
order.orderType = orderType
|
| Line 555... |
Line 664... |
| 555 |
#logistics_info.airway_billno = prepaid_logistics_info.airway_billno
|
664 |
#logistics_info.airway_billno = prepaid_logistics_info.airway_billno
|
| 556 |
#logistics_info.providerId = prepaid_logistics_info.providerId
|
665 |
#logistics_info.providerId = prepaid_logistics_info.providerId
|
| 557 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
666 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
| 558 |
# Will not provide OTG in pickup store
|
667 |
# Will not provide OTG in pickup store
|
| 559 |
order.otg = False
|
668 |
order.otg = False
|
| - |
|
669 |
|
| - |
|
670 |
current_time = datetime.datetime.now()
|
| - |
|
671 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
| - |
|
672 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
| - |
|
673 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
| - |
|
674 |
|
| - |
|
675 |
order.warehouse_id = logistics_info.warehouseId
|
| - |
|
676 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| - |
|
677 |
order.logistics_provider_id = logistics_info.providerId
|
| - |
|
678 |
#Start:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
| - |
|
679 |
#order.airwaybill_no = logistics_info.airway_billno
|
| - |
|
680 |
#order.tracking_id = order.airwaybill_no
|
| - |
|
681 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
| - |
|
682 |
if order.source != OrderSource.AMAZON or order.source != OrderSource.JUNGLEE:
|
| - |
|
683 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
684 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
685 |
order.promised_shipping_time = order.expected_shipping_time
|
| - |
|
686 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
687 |
order.promised_delivery_time = order.expected_delivery_time
|
| - |
|
688 |
|
| - |
|
689 |
inventory_client = InventoryClient().get_client()
|
| - |
|
690 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| - |
|
691 |
if OrderType.B2B == order.orderType:
|
| - |
|
692 |
#get state
|
| - |
|
693 |
stateMaster = fetchStateMaster()
|
| - |
|
694 |
stateId = -1
|
| - |
|
695 |
for k, v in stateMaster.iteritems():
|
| - |
|
696 |
if v.stateName == order.customer_state:
|
| - |
|
697 |
stateId = k
|
| - |
|
698 |
break
|
| - |
|
699 |
if stateId == -1:
|
| - |
|
700 |
raise TransactionServiceException(108, "No such State")
|
| - |
|
701 |
if not inventory_client.isAlive():
|
| - |
|
702 |
inventory_client = InventoryClient().get_client()
|
| - |
|
703 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
704 |
if stateId!= ffWarehouse.stateId:
|
| - |
|
705 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| - |
|
706 |
|
| - |
|
707 |
if goodWhIds is None or len(goodWhIds) == 0:
|
| - |
|
708 |
raise TransactionServiceException(108, "No availability from this location")
|
| - |
|
709 |
fulfilmentWarehouseId = goodWhIds[0]
|
| - |
|
710 |
for goodWhId in goodWhIds:
|
| - |
|
711 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| - |
|
712 |
if availability > 0:
|
| - |
|
713 |
fulfilmentWarehouseId = goodWhId
|
| - |
|
714 |
break
|
| - |
|
715 |
|
| - |
|
716 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| - |
|
717 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| - |
|
718 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| - |
|
719 |
if order.productCondition != ProductCondition.BAD:
|
| - |
|
720 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| - |
|
721 |
|
| 560 |
else:
|
722 |
else:
|
| 561 |
logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.COD, pickUp)
|
- |
|
| 562 |
order.otg = logistics_info.otgAvailable
|
- |
|
| 563 |
|
723 |
|
| 564 |
current_time = datetime.datetime.now()
|
- |
|
| 565 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
- |
|
| 566 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
- |
|
| 567 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
- |
|
| 568 |
|
- |
|
| 569 |
order.warehouse_id = logistics_info.warehouseId
|
- |
|
| 570 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
- |
|
| 571 |
order.logistics_provider_id = logistics_info.providerId
|
- |
|
| 572 |
#Start:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
- |
|
| 573 |
#order.airwaybill_no = logistics_info.airway_billno
|
- |
|
| 574 |
#order.tracking_id = order.airwaybill_no
|
- |
|
| 575 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
- |
|
| 576 |
if order.source != OrderSource.AMAZON or order.source != OrderSource.JUNGLEE:
|
- |
|
| 577 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
- |
|
| 578 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
- |
|
| 579 |
order.promised_shipping_time = order.expected_shipping_time
|
- |
|
| 580 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
- |
|
| 581 |
order.promised_delivery_time = order.expected_delivery_time
|
- |
|
| 582 |
|
- |
|
| 583 |
inventory_client = InventoryClient().get_client()
|
- |
|
| 584 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
- |
|
| 585 |
if OrderType.B2B == order.orderType:
|
- |
|
| 586 |
#get state
|
724 |
try:
|
| 587 |
stateMaster = fetchStateMaster()
|
- |
|
| 588 |
stateId = -1
|
- |
|
| 589 |
for k, v in stateMaster.iteritems():
|
- |
|
| 590 |
if v.stateName == order.customer_state:
|
- |
|
| 591 |
stateId = k
|
- |
|
| 592 |
break
|
- |
|
| 593 |
if stateId == -1:
|
- |
|
| 594 |
raise TransactionServiceException(108, "No such State")
|
725 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
| 595 |
if not inventory_client.isAlive():
|
- |
|
| 596 |
inventory_client = InventoryClient().get_client()
|
726 |
inventory_client = InventoryClient().get_client()
|
| - |
|
727 |
fulfilmentWhId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = inventory_client.getItemAvailabilityAtLocation(item_id, 1)
|
| - |
|
728 |
except Exception as ex:
|
| - |
|
729 |
raise TransactionServiceException(103, "Unable to fetch inventory information about this item.")
|
| - |
|
730 |
|
| - |
|
731 |
expectedDelayMap[item_id] = expected_delay
|
| - |
|
732 |
if billingWarehouseIdMap.has_key(billingWarehouseId):
|
| 597 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
733 |
ordersList = billingWarehouseIdMap.get(billingWarehouseId)
|
| - |
|
734 |
ordersList.append(order)
|
| - |
|
735 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
| - |
|
736 |
else:
|
| - |
|
737 |
ordersList = []
|
| 598 |
if stateId!= ffWarehouse.stateId:
|
738 |
ordersList.append(order)
|
| 599 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
739 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
| 600 |
|
740 |
|
| 601 |
if goodWhIds is None or len(goodWhIds) == 0:
|
741 |
if billingWarehouseTxnMap.has_key(billingWarehouseId):
|
| 602 |
raise TransactionServiceException(108, "No availability from this location")
|
742 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
| - |
|
743 |
transactionAmount = transactionAmount+order.total_amount
|
| - |
|
744 |
transactionWeight = transactionWeight+order.total_weight
|
| - |
|
745 |
billingWarehouseTxnMap[billingWarehouseId] = transactionAmount , transactionWeight
|
| - |
|
746 |
else:
|
| - |
|
747 |
billingWarehouseTxnMap[billingWarehouseId] = order.total_amount , order.total_weight
|
| - |
|
748 |
|
| - |
|
749 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
| - |
|
750 |
|
| 603 |
fulfilmentWarehouseId = goodWhIds[0]
|
751 |
fulfilmentWarehouseId = fulfilmentWhId
|
| - |
|
752 |
if OrderType.B2B == order.orderType:
|
| - |
|
753 |
#get state
|
| - |
|
754 |
stateMaster = fetchStateMaster()
|
| 604 |
for goodWhId in goodWhIds:
|
755 |
stateId = -1
|
| 605 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
756 |
for k, v in stateMaster.iteritems():
|
| 606 |
if availability > 0:
|
757 |
if v.stateName == order.customer_state:
|
| 607 |
fulfilmentWarehouseId = goodWhId
|
758 |
stateId = k
|
| 608 |
break
|
759 |
break
|
| - |
|
760 |
if stateId == -1:
|
| - |
|
761 |
raise TransactionServiceException(108, "No such State")
|
| - |
|
762 |
if not inventory_client.isAlive():
|
| - |
|
763 |
inventory_client = InventoryClient().get_client()
|
| - |
|
764 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| - |
|
765 |
if stateId!= ffWarehouse.stateId:
|
| - |
|
766 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| - |
|
767 |
if goodWhIds is None or len(goodWhIds) == 0:
|
| - |
|
768 |
raise TransactionServiceException(108, "No availability from this location")
|
| - |
|
769 |
fulfilmentWarehouseId = goodWhIds[0]
|
| - |
|
770 |
for goodWhId in goodWhIds:
|
| - |
|
771 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| - |
|
772 |
if availability > 0:
|
| - |
|
773 |
fulfilmentWarehouseId = goodWhId
|
| - |
|
774 |
break
|
| - |
|
775 |
|
| - |
|
776 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| - |
|
777 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| - |
|
778 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| - |
|
779 |
|
| - |
|
780 |
if order.pickupStoreId:
|
| - |
|
781 |
order.otg = False
|
| 609 |
|
782 |
|
| 610 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
- |
|
| 611 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
- |
|
| 612 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
- |
|
| 613 |
|
- |
|
| 614 |
if order.productCondition != ProductCondition.BAD:
|
783 |
if order.productCondition != ProductCondition.BAD:
|
| 615 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
784 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
| 616 |
|
785 |
|
| 617 |
try:
|
786 |
try:
|
| 618 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
787 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 619 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
788 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 620 |
order.lineitems[0].nlc = item_pricing.nlc
|
789 |
order.lineitems[0].nlc = item_pricing.nlc
|
| 621 |
except:
|
790 |
except:
|
| Line 624... |
Line 793... |
| 624 |
catalog_client = CatalogClient().get_client()
|
793 |
catalog_client = CatalogClient().get_client()
|
| 625 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
794 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
| 626 |
if voucherAmount:
|
795 |
if voucherAmount:
|
| 627 |
__create_recharge_voucher_tracker(order, voucherAmount, VoucherType.SPICEDECK_MOBILE)
|
796 |
__create_recharge_voucher_tracker(order, voucherAmount, VoucherType.SPICEDECK_MOBILE)
|
| 628 |
|
797 |
|
| - |
|
798 |
for billingWarehouseId, orders in billingWarehouseIdMap.items():
|
| - |
|
799 |
logistics_client = LogisticsClient().get_client()
|
| - |
|
800 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
| - |
|
801 |
costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, transactionAmount, True, transactionWeight, billingWarehouseId)
|
| - |
|
802 |
current_time = datetime.datetime.now()
|
| - |
|
803 |
logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
|
| - |
|
804 |
logisticsCostInOrders = 0
|
| - |
|
805 |
codCollectionCharges = costingAndDeliveryEstimateObj.codCollectionCharges
|
| - |
|
806 |
codCollectionChargesInOrders = 0
|
| - |
|
807 |
#delivery_delay
|
| - |
|
808 |
for order in orders:
|
| - |
|
809 |
expectedDelay = expectedDelayMap.get(order.lineitems[0].item_id)
|
| - |
|
810 |
shipping_delay = 24 * expectedDelay
|
| 629 |
|
811 |
if shipping_delay < 0:
|
| - |
|
812 |
shipping_delay = costingAndDeliveryEstimateObj.shippingTime
|
| - |
|
813 |
else:
|
| - |
|
814 |
shipping_delay = shipping_delay + 24 * costingAndDeliveryEstimateObj.shippingTime
|
| - |
|
815 |
shipping_delay = int(math.ceil(shipping_delay/24.0))
|
| - |
|
816 |
costingAndDeliveryEstimateObj.deliveryTime = adjust_delivery_time(current_time, costingAndDeliveryEstimateObj.deliveryTime+shipping_delay)
|
| - |
|
817 |
costingAndDeliveryEstimateObj.shippingTime = adjust_delivery_time(current_time, shipping_delay)
|
| - |
|
818 |
costingAndDeliveryEstimateObj.delivery_delay = adjust_delivery_time(current_time, shipping_delay+costingAndDeliveryEstimateObj.delivery_delay)
|
| - |
|
819 |
order.otg = costingAndDeliveryEstimateObj.otgAvailable
|
| - |
|
820 |
|
| - |
|
821 |
order.logistics_provider_id = costingAndDeliveryEstimateObj.logistics_provider_id
|
| - |
|
822 |
#Start:- Added by Manish Sharma for FedEx Integration - Shipment Creation on 31-Jul-2013
|
| - |
|
823 |
#order.airwaybill_no = logistics_info.airway_billno
|
| - |
|
824 |
#order.tracking_id = order.airwaybill_no
|
| - |
|
825 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
| - |
|
826 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=costingAndDeliveryEstimateObj.delivery_delay)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
827 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=costingAndDeliveryEstimateObj.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
828 |
order.promised_shipping_time = order.expected_shipping_time
|
| - |
|
829 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=costingAndDeliveryEstimateObj.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| - |
|
830 |
order.promised_delivery_time = order.expected_delivery_time
|
| - |
|
831 |
itemLevelLogisticsCost = round((order.total_amount *logisticsCost)/transactionAmount, 0)
|
| - |
|
832 |
logisticsCostInOrders = logisticsCostInOrders + itemLevelLogisticsCost
|
| - |
|
833 |
itemLevelCodCollectionCharges = round((order.total_amount *codCollectionCharges)/transactionAmount, 0)
|
| - |
|
834 |
codCollectionChargesInOrders = codCollectionChargesInOrders + itemLevelCodCollectionCharges
|
| - |
|
835 |
order.lineitems[0].logisticsCost = itemLevelLogisticsCost
|
| - |
|
836 |
order.lineitems[0].codCollectionCharges = itemLevelCodCollectionCharges
|
| - |
|
837 |
|
| - |
|
838 |
orders[0].lineitems[0].logisticsCost = orders[0].lineitems[0].logisticsCost + (logisticsCost-logisticsCostInOrders)
|
| - |
|
839 |
orders[0].lineitems[0].codCollectionCharges = orders[0].lineitems[0].codCollectionCharges + (codCollectionCharges-codCollectionChargesInOrders)
|
| 630 |
session.commit()
|
840 |
session.commit()
|
| 631 |
|
841 |
|
| 632 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
842 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
| 633 |
try:
|
843 |
try:
|
| 634 |
if order.source == OrderSource.WEBSITE:
|
844 |
if order.source == OrderSource.WEBSITE:
|
| Line 8263... |
Line 8473... |
| 8263 |
conn.close()
|
8473 |
conn.close()
|
| 8264 |
|
8474 |
|
| 8265 |
conn.close()
|
8475 |
conn.close()
|
| 8266 |
|
8476 |
|
| 8267 |
print 'Process completed'
|
8477 |
print 'Process completed'
|
| - |
|
8478 |
'''
|
| 8268 |
deltype = DeliveryType.PREPAID
|
8479 |
deltype = DeliveryType.PREPAID
|
| 8269 |
if ordersList[0].cod:
|
8480 |
if ordersList[0].cod:
|
| 8270 |
deltype = DeliveryType.COD
|
8481 |
deltype = DeliveryType.COD
|
| 8271 |
if not logistics_client.isAlive():
|
8482 |
if not logistics_client.isAlive():
|
| 8272 |
logistics_client = LogisticsClient().get_client()
|
8483 |
logistics_client = LogisticsClient().get_client()
|
| 8273 |
awbNumber = logistics_client.getNewEmptyAwb(provider.id, deltype, totalOrderQuantity)
|
8484 |
awbNumber = logistics_client.getNewEmptyAwb(provider.id, deltype, totalOrderQuantity)
|
| - |
|
8485 |
'''
|
| 8274 |
|
8486 |
|
| 8275 |
txnSeqRequired = 0
|
8487 |
txnSeqRequired = 0
|
| 8276 |
txnShipSeq = TransactionShipmentSequence.query.filter(TransactionShipmentSequence.transactionId==ordersList[0].transaction_id).order_by(desc(TransactionShipmentSequence.id)).first()
|
8488 |
txnShipSeq = TransactionShipmentSequence.query.filter(TransactionShipmentSequence.transactionId==ordersList[0].transaction_id).order_by(desc(TransactionShipmentSequence.id)).first()
|
| 8277 |
if txnShipSeq is None:
|
8489 |
if txnShipSeq is None:
|
| 8278 |
txnShipSeq = TransactionShipmentSequence()
|
8490 |
txnShipSeq = TransactionShipmentSequence()
|
| Line 8286... |
Line 8498... |
| 8286 |
txnShipSeqNew.createdTimestamp = datetime.datetime.now()
|
8498 |
txnShipSeqNew.createdTimestamp = datetime.datetime.now()
|
| 8287 |
txnShipSeqNew.sequence = txnShipSeq.sequence + 1
|
8499 |
txnShipSeqNew.sequence = txnShipSeq.sequence + 1
|
| 8288 |
txnSeqRequired = txnShipSeq.sequence + 1
|
8500 |
txnSeqRequired = txnShipSeq.sequence + 1
|
| 8289 |
|
8501 |
|
| 8290 |
for order in ordersList:
|
8502 |
for order in ordersList:
|
| 8291 |
update_order_AWB(order.id, awbNumber)
|
8503 |
#update_order_AWB(order.id, awbNumber)
|
| 8292 |
order.logisticsTransactionId = str(order.transaction_id)+"-"+str(txnSeqRequired)
|
8504 |
order.logisticsTransactionId = str(order.transaction_id)+"-"+str(txnSeqRequired)
|
| 8293 |
|
8505 |
|
| 8294 |
session.commit()
|
8506 |
session.commit()
|
| 8295 |
|
8507 |
|
| 8296 |
singleOrder = ordersList[0]
|
8508 |
singleOrder = ordersList[0]
|
| Line 9476... |
Line 9688... |
| 9476 |
creditObj.amount = amount
|
9688 |
creditObj.amount = amount
|
| 9477 |
creditObj.credit_type = credit_type
|
9689 |
creditObj.credit_type = credit_type
|
| 9478 |
creditObj.shipping_id = shipping_id
|
9690 |
creditObj.shipping_id = shipping_id
|
| 9479 |
return creditObj
|
9691 |
return creditObj
|
| 9480 |
|
9692 |
|
| - |
|
9693 |
def set_order_attribute_for_master_order_id(logisticsTransactionId, attributes):
|
| - |
|
9694 |
orders = get_group_orders_by_logistics_txn_id(logisticsTransactionId)
|
| - |
|
9695 |
for order in orders:
|
| - |
|
9696 |
for attribute in attributes :
|
| - |
|
9697 |
existingAttribute = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == attribute.name).first()
|
| - |
|
9698 |
if existingAttribute:
|
| - |
|
9699 |
existingAttribute.value = attribute.value
|
| - |
|
9700 |
else :
|
| - |
|
9701 |
attr = Attribute()
|
| - |
|
9702 |
attr.orderId = order.id
|
| - |
|
9703 |
attr.name = attribute.name
|
| - |
|
9704 |
attr.value = attribute.value
|
| - |
|
9705 |
session.commit()
|
| - |
|
9706 |
|
| - |
|
9707 |
def update_master_order_awb(logisticsTransactionId, airwaybill_no):
|
| - |
|
9708 |
orders = get_group_orders_by_logistics_txn_id(logisticsTransactionId)
|
| - |
|
9709 |
for order in orders:
|
| - |
|
9710 |
order.airwaybill_no = airwaybill_no
|
| - |
|
9711 |
order.tracking_id = airwaybill_no
|
| - |
|
9712 |
session.commit()
|
| - |
|
9713 |
return True
|
| - |
|
9714 |
|
| 9481 |
if __name__ == '__main__':
|
9715 |
if __name__ == '__main__':
|
| 9482 |
print get_orders_by_mobile_number("9650889334")
|
9716 |
print get_orders_by_mobile_number("9650889334")
|