/
Document for "STATUS" update logic (EXPORTS)

Document for "STATUS" update logic (EXPORTS)

What is the currently implemented logic?

According to the current logic, the status is getting updated as follows:

  • ACTUAL OUTCOME FROM CURRENT IMPLEMENTATION:

    PSEUDO CODE: FOR reference order_items is a table in our Database Various conditions according to which the current status is updated: 1. if (order_items.status == "ONHOLD") the condition is true then update the current status to ONHOLD 2. if (order_items.status=="CANCELLED") the condition is true then update the current status to CANCELLED 3. if (check if return flag is true means return is created){ and latestStatus is not null means it has a value then we update the current status to a status from RETURN } 4. else case { if latestStatus is not null we update the current status again to "NEW" in our case according to the logic }
    • Firstly it checks if the current status is “ON HOLD” and if it is true then we update the status to “ON HOLD”.

    • Secondly, if the current status is “CANCELLED” and if it is true then we again update the status so the final status after two movements is “CANCELLED”.

    • After the first two steps, we check if the return is created for the same order or not and if the return is created we check if “latestStatus” is not null means it has a value in it we update the current status again so, final status moves again to “RETURN ON THE WAY”

    • If the return is not created, we are again updating the status here which is in our case “NEW”

  • EXPECTED:

Value required for the below logic to execute

  1. order_items.onhold

  2. order_items.status

  3. order_items.returnFlag

  4. order_items.reversePickupReason

  5. order_items.warehouseInboundStatus

  6. shipment_status_logs.latestReturnStatus

  7. shipment_status_logs.latestOrderStatus

  8. shipment_status_logs.latestOrderStatusBeforeDispatched

  9. return_shipment_status_logs.latestReturnStatus

  10. orders.thirdPartyShipping

PSEUDO CODE Order STATUS for export: if (order_items.status == "CANCELLED") { currentOrderStatus == "CANCELLED" return currentOrderStatus; } if (order_items.shipment_id == 0) { currentOrderStatus == "UNFULFILLABLE" return currentOrderStatus; } if ((order_items.status == "ONHOLD" OR order_items.onhold == "1") && order_items.returnFlag == "0") { currentOrderStatus == "ONHOLD" return currentOrderStatus; } if (order_items.returnFlag == "1" AND order_items.warehouseInboundStatus == “received”) { currentOrderStatus == "RETURN IN PROCESSING" return currentOrderStatus; } if (order_items.returnFlag == "1" AND order_items.warehouseInboundStatus == “complete”) { if (order_items.reversePickupReason == “good_inventory”) currentOrderStatus == "RESTOCKED" return currentOrderStatus; if (order_items.reversePickupReason == “bad_inventory”) currentOrderStatus == "QUARANTINED" return currentOrderStatus; if (order_items.reversePickupReason == “lost” OR order_items.reversePickupReason == “partial_lost”) currentOrderStatus == "LOST IN PROCESSING" return currentOrderStatus; } if (order_items.returnFlag == "1" AND order_items.return_shipment_id != 0) { if (return shipment status log == NULL ) { if (order.thirdPartyShipping == 0) { currentorderStatus = Awaiting Pickup } else { currentorderStatus = return on the way } } else { latestStatus (return shipment status) currentOrderStatus = latestStatus if (order.thirdPartyShipping == 1 AND (currentOrderStatus == "awaiting_pickup", "return_lost", "pickup_cancelled", "return_damaged")){ currentOrderStatus = "Return on the way" } return currentOrderStatus; } } if (order_items.returnFlag == "1" AND order_items.return_shipment_id == 0 ) { if (shipmentStatusLogDto != null) { latestReturnStatus (shipment status log) currentOrderStatus = latestStatus return currentOrderStatus; } else { currentOrderStatus == "UNFULFILLABLE" return currentOrderStatus; } } if (order_items.returnFlag == "0") { if (shipmentStatusLogDto != null){ if (statuslogs.contains("cancelled")){ currentOrderStatus == "CANCELLED" return currentOrderStatus; } if (orders.thirdPartyShipping == 0 && "dispatched" == latestForwardOrderStatus){ latestStatus = latestForwardOrderStatusBeforeDispatched } else { latestStatus = latestForwardStatus } currentOrderStatus = latestStatus if (order.thirdPartyShipping == 1 AND (currentOrderStatus == "on the way", "out for delivery", "delivered", "delivery cancelled", "order lost")){ currentOrderStatus = "HANDOVER DONE" } } else { currentOrderStatus == "UNFULFILLABLE" return currentOrderStatus; } return currentOrderStatus; } AWAITING_PICKUP : "created", "order_placed", "pickup_pending", "approved", "out_for_pickup", "pickup_cancelled", "pickup_failed" RETURN_LOST : "lost", "rto_lost", "damaged", "rto_damaged" PICKUP_CANCELLED : "return_cancelled", "cancelled_order", "order_cancelled", "cancelled" RETURN_DAMAGED ON THE WAY : "picked_up", "intransit", "shipment_delayed", "not_serviceable", "failed_delivery", "shipment_held", "ndr_resolution_submitted" OUT_FOR_DELIVERY : "out_for_delivery" DELIVERED : "delivered" DELIVERY_CANCELLED : "rto", "rto_created", "rto_requested", "return_expected" ORDER_LOST : "lost", "damaged"
  • First, we will check whether order_item.status == “CANCELLED” AND returnFlag == 0, then show the current status as “CANCELLED” on export (break out of the function) cases should be made

  • Check if shipment_id == 0 AND returnFlag == 0 then set the current status as “UNFULFILLABLE” (break)

  • Now based order_item.status, check if order_item.onhold == 1 AND returnFlag == 0 set the current status to “ONHOLD” (break)

  • When order_item.returnFlag == 1 AND order_item.warehouseInboundStatus == “received” set the current status as “RETURN IN PROCESSING” and then (break)

  • When order_item.returnFlag == 1 AND order_item.warehouseInboundStatus == “complete”

    • Now check if order_item.reversePickupReason == “good_inventory” then set the current status as “RESTOCKED” and then (break)

    • Now check if order_item.reversePickupReason == “bad_inventory” then set the current status as “QUARANTINED” and then (break)

    • Now check if order_item.reversePickupReason == “lost” OR “partial_lost” then set the current status as “LOSTINPROCESSING” then (break)

  • Fetch latestStatus of return shipment status log if order_item.returnFlag == 1 AND order_item.return_shipment_id != 0, set current order status on the basis of latestStatus and then (break).

  • Fetch latest return status of shipment status log if order_item.returnFlag == 1 AND order_item.return_shipment_id == 0, set current order status on the basis latestReturnStatus and then (break)

  • Fetch latest order status of shipment status log if order_item.returnFlag == 0, set current order status on the basis of latestOrderStatus (break)

//return shipment status logs DTO if (status.created) { dto.setReturnCreatedDateTime(); } else if (status.picked_up) { dto.setReturnPickedUpDateTime(); } else if (status.out_for_pickup) { if (!isFirstOutForPickupCovered) { isFirstOutForPickupCovered = true; dto.setFirstOutForPickupDateTime(); } outForPickupAttempts++; dto.setPickupAttempts(outForPickupAttempts); dto.setLatestOutForPickupDateTime(); } else if (status.pickup_cancelled) { failedPickupAttempts++; dto.setFailedPickupAttempts(failedPickupAttempts); dto.setFailedPickupDateTime(); dto.setLatestFailedPickupRemarks(); dto.setLatestFailedPickupReason(); } else if (status.delivered) { dto.setReturnDeliveredDateTime(); } else if (status.received) { dto.setReturnReceivedDateTime(); } else if (status.approved) { dto.setExpectedPickupDateTime(); } dto.setLatestReturnStatus(status);
shipmentStatusLogDTO forward shipment status logs boolean isPackedCovered = false; boolean isDispatchedCovered = false; if (status.created) { //we set createdDateTime dto.setCreatedDateTime //fetch remark in next step //check if pincode is serviceable if not set if(remark == "pincode unserviceable") dto.setonholdReason } else if (status.picking) { dto.setPickingDateTime(); } else if (status.failedtoRts) { if (!isRtsFirstAttemptDone) { //if rtsFirstAttemptDone == true then dto.setFirstRtsDateTime() } failedRtsAttempts++; dto.setFailedRtsAttempts(failedRtsAttempts); dto.setLatestRtsDateTime(); //check remark if (remark == "error message dummy"){ //fetch details of map } dto.setLatestFailedToRtsReason(remark); //handling if received failed_to_rts after packed if(isPackedCovered) { continue; } } else if (status.picked) { dto.setPickedDateTime(); } else if (status.packed) { //case where failed_to_rts after packed isPacked = true; dto.setPackedDateTime(); } else if (status.failed_to_handover) { dto.setfailedtohandoverDateTime(); if(isDispatchedCovered) { continue; } } else if (status.dispatched) { dto.setdispatchedDateTime(); isDispatchedCovered = true; } else if (status.shipped) { dto.setShippedDateTime(); } else if (status.cancelled) { dto.setIsCancelled(true); dto.setCancelledDateTime(); if (fulfillment_cancel) { dto.setCancelledBy("Seller") } else { dto.setCancelledBy("Customer") } } else if (status.picked_up) { dto.setPickedUpDateTime(); } else if (status.out_for_delivery) { if (!isOutForDeliveryFirstAttemptDone) { isOutForDeliveryFirstAttemptDone = true; dto.setFirstOutForDeliveryDateTime(); } outForDeliveryAttempts++; dto.setOutForDeliveryAttempts(outForDeliveryAttempts); dto.setLatestOutForDeliveryDateTime(); isDispatchedCovered = true; } else if (status.failed_delivery) { if (!isFirstFailedDeliveryCovered) { isFirstFailedDeliveryCovered = true; dto.setFirstFailedDeliveryDateTime(); } failedDeliveryAttempts++; dto.setDeliveryFailedAttempts(failedDeliveryAttempts); dto.setLatestFailedDeliveryDateTime(); dto.setLatestFailedDeliveryRemark(); dto.setLatestFailedDeliveryReason("ndr_status_description"); } else if (status.ndr_resolution_submitted) { dto.setFailedDeliveryAction(); } else if (status.delivered) { dto.setDeliveredDateTime(); } else if (status.rto && status.rto_created) { isRTOCovered = true; dto.setReturnCreatedDateTime(); } else if (status.rto_received && status.received) { dto.setReturnReceivedDateTime(); } else if (status.rto_delivered) { dto.setReturnDeliveredDateTime(); } if (AlgoliaOrderItemEnum.isStatusByCategory(Category.RETURNS, status)) { dto.setLatestReturnStatus(status); } if (AlgoliaOrderItemEnum.ON_THE_WAY.getStatusLogs().contains(status)) { if (!isFirstOnTheWayCovered) { isFirstOnTheWayCovered = true; dto.setFirstOnTheWayDateTime(); } if (status.dispatched) { dto.setForwardStatusBeforeDispatched(); } dto.setShipmentStatusLatestCreatedAt(); dto.setLatestForwardOrderStatus(status); } if (dto.getDispatchedDateTime() == null)) { dto.setDispatchedDateTime(shippedDateTime); } if (dto.getLatestForwardOrderStatus() != null && dto."failed_delivery")) { dto.setFailedDeliveryActionStatus(); } else if (dto.getLatestForwardOrderStatus() != null && dto."ndr_resolution_submitted") { dto.setFailedDeliveryActionStatus(); }
Add label

Related content