Auperator Flow for Unfulfillable Orders
1. Marketplace: When the order arrives from the marketplace such as Flipkart, Amazon etc then it is created using Create Order API as mentioned below:
POST API:
https://wms.eshopbox.com/api/order
Sample Request Body:
{
"dimension_height": "0.99",
"vendorOrderNumber": "405-7078626-4156354",
"balanceDue": 0,
"externalChannelID": "CH1200",
"dimension_width": "23.98",
"expectedShipDate": "2021-11-17T14:00:00",
"externalShipmentID": "UJZy8sn4N",
"dimension_length": "36.98",
"weight": "276.69",
"customerOrderNumber": "dfb4b442-ebc5-43cc-87c4-d46e383f2143",
"orderTotal": 489.00,
"paymentType": "Prepaid",
"isCOD": "0",
"locationId": "d1391379-8283-4335-a43c-0a2eb2fe2d21",
"subtotal": 449.00,
"shipMethod": "ATS_STANDARD",
"shippingAddress": {
"city": "visakhapatnam",
"countryCode": "IN",
"postalCode": "530017",
"addressLine1": "Test Address",
"countryName": "India",
"state": "ANDHRA PRADESH",
"contactPhone": "0000000000",
"customerName": "xyz",
"email": "xyz@test.com"
},
"thirdPartyShipping": true,
"billingAddress": {
"city": "visakhapatnam",
"countryCode": "IN",
"postalCode": "530017",
"addressLine1": "Test Address",
"countryName": "India",
"state": "ANDHRA PRADESH",
"contactPhone": "0000000000",
"customerName": "xyz",
"email": "xyz@test.com"
},
"taxAmount": 21.38,
"orderDate": "2021-11-16T23:18:34",
"externalWarehouseID": "ESBMUM_112",
"items": [
{
"quantity": 1,
"discount": 0.0,
"lineItemTotal": 449.00,
"customerPrice": 449.00,
"productName": "testProduct",
"itemID": "BBAPLPU136043_81",
"taxRate": 0.05,
"giftWrapCharges": 0.0,
"lineItemSequenceNumber": "1",
"invoiceNumber": "XWRA-18887",
"isGift": "0",
"isPriorityShipment": true,
"taxAmount": 0.0
}
],
"shipChargeAmount": 40.00
}
Once the Order is created and API returns 200 OK response, an event is published to Middleware using PubSub topic: “create-order-middleware“
2. Middleware: At middleware, once the event arrives from Create Order API Service, the inventory allocation rule process the items present in the event. It checks the available inventory for the items and there can be multiple scenarios as explained below:
If all the items are fulfillable then the Shipment is created
If any item is Unfulfillable and the warehouse is configured to Auperator then in that case shipment will not be created. Instead, ESB-WMS-Order Service API will be called which will create an entry in the orders_unfulfillable table
2. ESB-WMS-Order Service: This Service is basically an API that will create an entry in the table known as orders_unfulfillable. The path of the API is as mentioned below:
Working:
1. If the order_id is already present in “orders_unfulfillable” table then check its shipmentStatus
a. If it is equal to CREATED then change it to PENDING
b. if it is equal to PENDING then return.
2. If the order_id is not present then save the model the “orders_unfulfillable“ table.
POST API:
https://esb-wms-order-dot-esb-integration-engine-prod.el.r.appspot.com/_ah/api/esb/v1/order/unfulfillable
Request Body:
{
"order_data": {
"externalChannelID": "CH1162",
"customerOrderNumber": "4400efcd-ad37-4346-83be-793704b792e3",
"shipMethod": "STD",
"orderDate": "2021-11-28 17:46:09",
"expectedShipDate": "2021-12-08T14:00:00.000+05:30",
"promiseDeliveryDate": "2021-11-30 17:46:09",
"isCOD": "1",
"paymentType": "COD",
"taxAmount": 0,
"shipChargeAmount": 0,
"subtotal": 897,
"orderTotal": 897,
"balanceDue": 897.0,
"thirdPartyShipping": true,
"onHold": "1",
"vendorOrderNumber": "OD123495703891717000",
"orderStatus": "onhold",
"packageID": "SS-1",
"dispatchAfterDate": "2021-12-07T14:01:00.000+05:30",
"shippingAddress": {
"customerName": "Binudhar",
"addressLine1": "dudhnoi",
"addressLine2": "dohela market",
"city": "Goalpara",
"postalCode": "783125",
"countryCode": "IN",
"countryName": "India",
"contactPhone": "9999999999",
"email": "xyz@gmail.com",
"state": "Assam"
},
"billingAddress": {
"customerName": "Binudhar",
"addressLine1": "dudhnoi",
"addressLine2": "dohela market",
"city": "Goalpara",
"postalCode": "783125",
"countryCode": "IN",
"countryName": "India",
"contactPhone": "9999999999",
"email": "xyz@gmail.com",
"state": "Assam"
},
"items": [
{
"lineItemSequenceNumber": "12349570389171700",
"status": "ONHOLD",
"quantity": 1,
"sku": "2180100352-1-38",
"itemID": "TSHF7VQMQPYA7CNW",
"productName": "Rock.it Sporty Men High Neck Grey T-Shirt M 2180100352-1_Grey",
"dispatchAfterDate": "2021-12-07T14:01:00.000+05:30",
"lineItemOrderStatus": "CREATED",
"productAdditionalInfo": {
"breadth": 29.1,
"length": 26.7,
"weight": 0.45,
"height": 2.9
},
"mrp": 897.0,
"lineItemTotal": 897.0,
"shippingCharges": 0.0,
"customerPrice": 897.0,
"discount": 0.0,
"externalWarehouseID": "MJPAT_109"
}
]
},
"account_id": 550,
"account_slug": "glance",
"channel_id": 1314,
"integrationType": "12"
}
Mapping:
DB Keys | Event |
---|---|
id | Auto incremented |
order_id |
|
warehouse_id |
|
dimension_length | items[]. |
dimension_width | items[]. |
dimension_height | items[]. |
weight | items[]. |
courierName |
|
trackingID |
|
packageID |
|
boxAdditionalRecommendation |
|
labels |
|
shippingInfo |
|
invoiceNumber |
|
invoiceDate |
|
shipmentStatus |
|
created_at | current Timestamp |
updated_at | current Timestamp |
Success Case Response Body:
{
"order_data": {
"customerOrderNumber": "f593e712-7778-407e-9bde-ef5be555d05b",
"orderSiteID": "",
"vendorOrderNumber": "OD124141551880757000",
"externalShipmentID": "OD124141551880757000-1055-697",
"externalWarehouseID": "Kolkata_FC",
"externalChannelID": "CH1055",
"externalWmsChannelName": "FLIPKART_PIDILITE_XCCU_1337",
"external_wms_channel_id": 1337,
"channelLabel": "Flipkart",
"integrationType": "6",
"defaultWarehouseCode": "Kolkata_FC",
"facilityLabel": "Kolkata (XCCU)",
"facilityType": "auperator",
"orderDate": "2022-02-11 11:47:08",
"portal_id": 1,
"paymentType": "COD",
"expectedShipDate": "2022-02-11 14:00:00",
"dispatchAfterDate": "2022-02-11 11:52:08",
"order_id": 42461271,
"channel_id": 1055,
"warehouse_id": 652,
"channel_account_id": 0,
"account_id": 439,
"connectionId": 144,
"locationId": "LOC399e0b487f764465b43cf663b06e3637",
"region": "",
"isMetro": "0",
"isSpecialplace": "0",
"invoiceNumber": "null1311",
"boxType": "UNKNOWN",
"isPriorityShipment": "0",
"isGift": "0",
"invoice_url": "https://storage.googleapis.com/invoicefiles-prod/invoice/OD124141551880757000-1055-697-1644560420898.pdf",
"invoiceDate": "2022-02-11 11:50:18",
"label_url": "",
"labels": "",
"shippingInfo": [],
"boxAdditionalRecommendation": [],
"dimension_length": "23.2",
"dimension_width": "12.1",
"dimension_height": "7.2",
"weight": "1000",
"trackingID": "5962857392192",
"trackingDomain": "",
"packageID": "",
"barcode": "",
"taxAmount": 0,
"shipChargeAmount": 0,
"courierName": "Delhivery COD",
"cp_id": 0,
"created_at": "2022-02-11 11:50:17",
"updated_at": "2022-02-11 11:50:21",
"status": "created",
"remarks": "fulfillment_cancel",
"warehousePincode": "711411",
"thirdPartyShipping": true,
"customerName": "Akash",
"customerContactNumber": "9999999999",
"email": "xyz@gmail.com",
"status_updated_at": "2022-02-11 12:07:19",
"status_log": {
"created": "2022-02-11 11:50:17",
"rejected": "2022-02-11 12:07:19"
},
"status_log_count": {
"created": 1,
"rejected": 1
},
"status_log_id": "76198937",
"orderExternalCreatedAt": "2022-02-11 11:50:12",
"shippingAddress": {
"customerName": "Akash",
"addressLine1": "Mailani kheri, Mohalla eed gaha ward no 12",
"addressLine2": "Marwady colony",
"city": "Mailani",
"state": "Uttar Pradesh",
"postalCode": "262803",
"countryCode": "IN",
"countryName": "India",
"contactPhone": "9999999999",
"email": "xyz@gmail.com"
},
"warehouseAddress": {
"addressLine1": "Bipranapara, Jalan Complex Domjur",
"addressLine2": "Howrah",
"city": "Kolkata",
"state": "West Bengal",
"postalCode": "711411"
},
"id": 10413196,
"isCOD": "1",
"track_payload": [],
"items": [
{
"lineItemSequenceNumber": "12414155188075700",
"orderItemID": "12414155188075700-22736442",
"itemID": "BCRFZTDTASCF3G6V",
"sku": "01C6Z3GQM73",
"asin": "",
"productName": "Pidilite T16 Roff Cera Clean Professional Tile, Floor and Ceramic Cleaner (1 Litre) NA 1 L",
"quantity": 1,
"customerPrice": 159,
"lineItemTotal": 159,
"invoiceTotal": 159,
"cashOnDeliveryCharges": 0,
"discount": 0,
"taxRate": 0,
"taxAmount": 0,
"inventoryItemCode": "",
"giftMessage": "",
"giftLabelContent": "",
"lineItemOrderStatus": "created",
"orderItemIDs": [
"12414155188075700-22736442"
],
"productImageUrl": "https://images-na.ssl-images-amazon.com/images/I/41jv64F8g1L.jpg",
"productAdditionalInfo": {
"breadth": 12.1,
"length": 23.2,
"weight": 1,
"height": 7.2
},
"shippingCharges": 0,
"isVirtualKit": "0",
"onhold": "0",
"cancellationAdditionalReason": "",
"cancellationReason": "",
"customerOrderItemID": "",
"externalWarehouseID": "Kolkata_FC",
"inventoryStatus": "Unfulfillable"
}
]
},
"account_slug": "pidilite",
"integrationType": "6",
"account_id": 439,
"channel_id": 1055,
"id": 111500
}
Failure Case Response Body:
3. Cron-Order Service: A cron will be implemented which will fetch all the entries/records from orders_unfulfillable table having shipmentStatus='PENDING', along with which we need to prepare a Shipment Event which will be pushed on a PubSub topic. After retrieving records from orders_unfulfillable the orders data will be pushed into TaskQueue in batches of 10
PubSub Topic: 'order_unfulfillable'
API Path:
GET API:
https://esb-wms-order-dot-esb-integration-engine-prod.el.r.appspot.com/_ah/api/esb/v1/get/unfulfillableOrders
Order Event to be Prepared:
{
"order_data": {
"externalChannelID": "CH1162",
"customerOrderNumber": "4400efcd-ad37-4346-83be-793704b792e3",
"shipMethod": "STD",
"orderDate": "2021-11-28 17:46:09",
"expectedShipDate": "2021-12-08T14:00:00.000+05:30",
"promiseDeliveryDate": "2021-11-30 17:46:09",
"isCOD": "1",
"paymentType": "COD",
"taxAmount": 0,
"shipChargeAmount": 0,
"subtotal": 897,
"orderTotal": 897,
"balanceDue": 897.0,
"thirdPartyShipping": true,
"onHold": "1",
"vendorOrderNumber": "OD123495703891717000",
"orderStatus": "onhold",
"packageID": "SS-1",
"dispatchAfterDate": "2021-12-07T14:01:00.000+05:30",
"shippingAddress": {
"customerName": "Binudhar",
"addressLine1": "dudhnoi",
"addressLine2": "dohela market",
"city": "Goalpara",
"postalCode": "783125",
"countryCode": "IN",
"countryName": "India",
"contactPhone": "9999999999",
"email": "xyz@gmail.com",
"state": "Assam"
},
"billingAddress": {
"customerName": "Binudhar",
"addressLine1": "dudhnoi",
"addressLine2": "dohela market",
"city": "Goalpara",
"postalCode": "783125",
"countryCode": "IN",
"countryName": "India",
"contactPhone": "9999999999",
"email": "xyz@gmail.com",
"state": "Assam"
},
"items": [
{
"lineItemSequenceNumber": "12349570389171700",
"status": "ONHOLD",
"quantity": 1,
"sku": "2180100352-1-38",
"itemID": "TSHF7VQMQPYA7CNW",
"productName": "Rock.it Sporty Men High Neck Grey T-Shirt M 2180100352-1_Grey",
"dispatchAfterDate": "2021-12-07T14:01:00.000+05:30",
"lineItemOrderStatus": "CREATED",
"productAdditionalInfo": {
"breadth": 29.1,
"length": 26.7,
"weight": 0.45,
"height": 2.9
},
"mrp": 897.0,
"lineItemTotal": 897.0,
"shippingCharges": 0.0,
"customerPrice": 897.0,
"discount": 0.0,
"externalWarehouseID": "MJPAT_109"
}
]
},
"account_id": 550,
"account_slug": "glance",
"channel_id": 1314,
"integrationType": "12",
"orderUnfulfillable":"1"
}
SQL Query to get details as shown in the above sample Order Event:
SELECT
channels.externalChannelID,
orders.customerOrderNumber,
orders.shipMethod,
orders.orderDate,
orders_unfulfillable.expectedShipDate,
order_items.promiseDeliveryDate,
orders.isCOD,
orders.paymentType,
orders.taxAmount,
orders.shipChargeAmount,
orders.subtotal,
orders.orderTotal,
orders.balanceDue,
orders.thirdPartyShipping,
orders.onHold,
orders.vendorOrderNumber,
orders.status,
orders_unfulfillable.packageID,
orders.dispatchAfterDate,
orders.shipping_customerName,
orders.shipping_addressLine1,
orders.shipping_addressLine2,
orders.shipping_city,
orders.shipping_state,
orders.shipping_postalCode,
orders.shipping_countryCode,
orders.shipping_countryName,
orders.shipping_contactPhone,
orders.shipping_email,
orders.billing_customerName,
orders.billing_addressLine1,
orders.billing_addressLine2,
orders.billing_city,
orders.billing_state,
orders.billing_postalCode,
orders.billing_countryCode,
orders.billing_countryCode,
orders.billing_countryName,
orders.billing_email,
orders.billing_contactPhone,
order_items.lineItemSequenceNumber,
order_items.status,
order_items.quantity,
order_items.sku,
order_items.itemID,
order_items.productName,
order_items.lineItemOrderStatus,
order_items.mrp,
order_items.lineItemTotal,
order_items.shippingCharges,
order_items.customerPrice,
order_items.discount,
orders_unfulfillable.externalWarehouseID,
orders_unfulfillable.dimension_length,
orders_unfulfillable.dimension_width,
orders_unfulfillable.dimension_height,
orders_unfulfillable.weight,
orders_unfulfillable.weight_unit,
orders_unfulfillable.dimension_unit,
channels.id,
channels.integrationType,
channels.account_id,
orders_unfulfillable.account_slug
FROM
orders_unfulfillable
LEFT JOIN
orders
ON orders.id = orders_unfulfillable.order_id
LEFT JOIN
order_items
ON order_items.order_id = orders_unfulfillable.order_id
LEFT JOIN
channels
ON channels.id = orders.channel_id
WHERE
orders_unfulfillable.shipmentStatus='PENDING'
AND order_items.shipment_id = '0'
AND orders_unfulfillable.order_id IS NOT NULL
AND orders_unfulfillable.account_slug IS NOT NULL
Note: We need to add constant key-value pair in the Shipment Event which will be pushed as given below:
Key | Value |
---|---|
|
|
Success Response Body:
Now this shipment event will be pushed on a PubSub topic as mentioned above. The listener for this PubSub topic is Middleware service only which will consume this event and will check whether the inventory is now available or not for the items present in the shipment event. Following scenarios can take place:
If the Inventory is available now for all the items present in the Shipment Event then simply create the shipment and mark the shipmentStatus as “
CREATED
" in the orders_unfulfillable tableIf any of the item is Unfulfillable and the warehouse belongs/configured to Auperator then check for
"orderUnfulfillable"
if this exists in the Shipment event with value'1'
then ignore and return otherwise call the ESB-WMS-Order Service
Cancelled event in: if any "inventoryStatus" = unfulfillable, then prepare wms cancel order request body and make a request
Remarks = "fulfillment_cancel".
For integrationType = "8",
shipmentStatusLog.status must be "rejected" but only the item which is unfulfillable, set it's order_items.lineItemOrderStatus = "failure" and order_items.status="cancelled" (eventSubType="rejected" must be published).
no further shipment creation will be done for the remaining items.
For integrationType(4,11) run the inventory location and shipment creation for all items.
For other integrationType run the shipment creation for remaining items.
shipment must be cancelled but only the item which is unfulfillable, set it's lineItemOrderStatus = "failure" and status="cancelled".
New shipment will be created for the remaining items.