Hi there,
It seems that the scheduled task QueuedOrdersSyncScheduledTask doesn't take the "Finished for X minutes" setting into account appropriately. I tracked it down to an issue in OrderRepository line 1311.
The scheduled task sets up the filter as follows:
if (MinutesCompleted > 0)
{
  filter.ToCompletedDate = DateTime.Now.AddMinutes(-1 * MinutesCompleted);
}
That looks alright and creates a date that is X minutes in the past.
Then OrderRepository does this around line 1311:
if (filter.ToCompletedDate.HasValue)
{                
  var sqlToDate = filter.ToCompletedDate.Value.Add(new TimeSpan(23, 59, 59));
  if (sqlToDate > SqlDateTime.MaxValue.Value)
      sqlToDate = SqlDateTime.MaxValue.Value;
  sql.Add("AND EcomOrders.OrderCompletedDate <= {0} ", sqlToDate);
}
I think there are two issues with this code:
1. It just adds (almost) 24 hours to the date and time passed in which essentially sets the date to 24 hours in the future minus the configured "Finished for X minutes" in minutes. This then includes all orders that are in the database. Looks like the intend here was to make this midnight on the requested date which should have pulled the date from the Date property:
var sqlToDate = filter.ToCompletedDate.Value.Date.Add(new TimeSpan(23, 59, 59));
2. However, for the ToCompletedDate we don't want midnight on the requested date, we want the exact time passed in. So I believe the correct implementation would be this:
if (filter.ToCompletedDate.HasValue)
{                
  var sqlToDate = filter.ToCompletedDate.Value);
  if (sqlToDate > SqlDateTime.MaxValue.Value)
      sqlToDate = SqlDateTime.MaxValue.Value;
  sql.Add("AND EcomOrders.OrderCompletedDate <= {0} ", sqlToDate);
}
which takes the date as-is and caps it if needed.
I believe the same issue is present with the ToDate filter in the same repo which is used by standard order list filtering. It adds 24 hours to the current date, giving you orders for the next day when you filter by a specific end date:
Can this be fixed please?
I think as a work around we can set the finished minutes to 1440 (a whole day) + whatever value we need (i.e. 1445 for a 5 minutes delay).
We're on DW 9.
Imar
 
                                             
                                         
                                                     
                             
                                                     
                        							 
                                                     
                                                     
                             
                             
                             
                     
                                                            