Report
Duplicate order report for handling order duplications in OMS
In cases where HotWax Commerce imports an order twice due to synchronization error, each order is processed independently, leading to separate fulfillments for what was originally a single order. This duplication often results in inventory discrepancies as it generates two reserved items instead of one. To address this issue and enhance visibility concerning duplicated orders within the OMS, we've introduced the Duplicate Order Report.
Report Structure
The Duplicate Order Report comprises the following sections
Field Header | Description |
---|---|
Order Name | This field refers to the Shopify order name. |
Preferred Order ID | It denotes the order ID of the preferred duplicate order, which should be fulfilled over others based on order attributes. |
Preferred Order Status | This indicates the status of the preferred duplicate order. |
Other Order ID | Represents the order ID of the other duplicate order, which is less preferred for fulfillment. |
Other Order Status | Specifies the status of the other duplicate order. |
Recent Order Date | Reflects the date of the most recent order among the duplicates. |
Query Logic
The SQL query selects data from the order_header
table. It joins the order_attribute
table to retrieve additional attributes like customerId
and municipio
for each order.
Calculation of Weight
A weight is calculated for each order based on the presence of customerId
, municipio
, and the status of the order (ORDER_COMPLETED
). If customerId
or municipio
is not null, it contributes 1 to the weight. If the order status is ORDER_COMPLETED
, it contributes 10. This weighting scheme prioritizes completed orders and those with customer information.
Aggregation
The innermost subquery groups the data by order_name
and calculates aggregates for each group. For each group, it selects the order with the highest weight as the preferred order. This is done using group_concat
to concatenate order IDs and statuses sorted by weight and order ID, and then substring_index
to select the first (highest weighted) order ID and status.
Selection of Preferred Order
The preferred order is the one with the highest weight within each group order_name
. This order is selected based on its highest weight, prioritizing completed orders and those with customer information. The prefered_order_id
and prefered_order_status
columns store the ID and status of the preferred order that needs to be fulfilled.
All other orders are considered secondary and are analyzed in conjunction with the preferred orders. These are the orders that have less weight as compared to the preferred order because they have fewer attributes and should be cancelled.
Handling of Duplicate Order
Less preferred orders need to be manually cancelled and the order items should be transferred to the general ops parking, preventing further processing. If order items are transferred to general ops parking without the order being marked as cancelled, they will still be included in the report.
Last updated