Does this copy have something to do with it? To use as a reference.
$date_where .= $wpdb->prepare( ' AND post_date_gmt <= %s', $date_end );
$orders_query = "
SELECT ID FROM $wpdb->posts
AND post_type = 'shop_order' AND post_status IN ('wc-processing', 'wc-completed')
$order_status = (array) apply_filters( 'atum/get_sold_last_days/orders_status', [
$format = implode(', ', array_fill(0, count($order_status), '%s'));
$orders_query = $wpdb->prepare("
AND post_type = 'shop_order' AND post_status IN ($format)
", $order_status );
$query_columns = $query_joins = ;
$use_lookup_table = FALSE;
Also, I don't understand if the states work well for me, because the stock is reduced sometimes but at no time have we used the completed state, so the stock should not have been subtracted.