Project:
UbercartCategory:
bug reportVersion:
Ubercart 1.6Priority:
normalAssigned:
UnassignedStatus:
activeIn the latest upgrade to 1.6, there has been a bug introduced into the Sales reports, specifically the "Sales per year" report (admin/store/reports/sales/year).
When looking at the report in the default view, the number of orders is listed one month off from the month the orders were completed. Therefore the total number of November orders shows up next to the "Dec 2008" link, number of October orders shows up next to the "Nov 2008" link, etc.
This used to work correctly in Ubercart 1.4.



Re: Sales per year report off by one month
I'll diff the source, but I don't remember any changes to those modules. I wonder if it's not actually the timing of the releases, such that Daylight Savings Time is throwing a fork in the whole operation. Thoughts?
Re: Re: Sales per year report off by one month
Possibly, but I would have thought we'd only see a one hour shift, or maybe at most one day?
We're seeing all of November's orders show up in the December line total, all of October's in November, etc. Also the total for the year is coming up empty. For example, we should be seeing this:
Month / Number of Orders
Sep 2008 / 561
Oct 2008 / 831
Nov 2008 / 352
Dec 2008 / 0
Total 2008 / (total # for the year)
But instead, we're seeing this:
Month / Number of Orders
Sep 2008 / 132
Oct 2008 / 561
Nov 2008 / 831
Dec 2008 / 352
Total 2008 / 0
Doesn't make sense why the total would be 0 ... I would expect it to be the running total for the year. Also obviously we haven't even reached December yet, but have 352 orders listed on the report.
Re: Re: Re: Sales per year report off by one month
Schnikes... yeah, if only Ubercart was able to plan orders for you before they ever happened. So this happened when you updated, correct? Did you update or add any other modules at the same time? Is your system time displaying the correct time? Like if you go place an order right now, will it show today's date?
I'm asking these sorts of questions, because I did a diff on the reports module and literally nothing has changed in it since the 1.4 release.
Re: Re: Re: Re: Sales per year report off by one month
Yes, this happened after update from 1.4 to 1.6. Pre-1.6 did not do this. Didn't update any other modules. Yes, the system time is displayed correctly, and yes an order right now shows the right date.
The orders are fine and assigned to the right dates. This problem is *only* on the "Sales per year" report. All other reports are good. Even the links on the "Sale per year" report are technically correct. If I attempt to click on the "Dec 2008" link, it tells me no orders can be found for that time period, which is right.
Re: Re: Re: Re: Re: Sales per year report off by one month
Quick non sequitur... I hate the name of that report. Seems like it should at least be "Monthly sales report" or something.
Anyways, you should see the following lines in the reports module starting at line 498:
<?php// For each month of the year...
for ($i = 1; $i <= 12; $i++) {
// Calculate the start and end timestamps for the month in local time.
$month_start = gmmktime(0, 0, 0, $i, 1, $year) - $timezone_offset;
$month_end = gmmktime(23, 59, 59, $i + 1, 0, $year) - $timezone_offset;
?>
I think this still may be a DST issue, so try making the following change:
<?php// For each month of the year...
for ($i = 1; $i <= 12; $i++) {
// Calculate the start and end timestamps for the month in local time.
$month_start = gmmktime(0, 0, 0, $i, 1, $year) - $timezone_offset - 3600;
$month_end = gmmktime(23, 59, 59, $i + 1, 0, $year) - $timezone_offset - 3600;
?>
Let's see where that gets us...
Re: Re: Re: Re: Re: Re: Sales per year report off by one month
Gave it a try and no change ... still the same. And yes, I agree it should be something like a "monthly sales report".
Re: Re: Re: Re: Re: Re: Re: Sales per year report off by one mon
Any chance I could get ya to play around with those month start and end dates until you find one that works?
Re: Re: Re: Re: Re: Re: Re: Re: Sales per year report off by one
I've seen oddities regarding reports and DST as well. Did you happen to update the default time zone at admin/settings/date-time whenever DST kicked in?
Another data point
FWIW, I was seeing this exact same thing -- orders off by one month in the Sales by Year report -- and it corrected itself when I went to Date&Time and set the timezone to be correct (EST instead of GMT) and set the "Configurable Time Zone" to disabled. Dunno why that would make a difference, but in my case it fixed the issue.
Re: Re: Re: Re: Re: Re: Re: Re: Sales per year report off by one
One thing I noticed was happening with Custom sales report parameters was that after I submitted something like December 1 2008 - December 2 2008 the page would reload with December 1 2008 - December 3 2008.
I think I tracked this down to an issue with the sales report trying to use _uc_reports_timezone_offset() which uses a site's timezone to generate a timestamp but then the date being output with format_date() which takes that timestamp and then applies the individual user's timezone to it. So if a user's timezone does not match the site's timezone you will see strange behavior.
Re: Re: Re: Re: Re: Re: Re: Re: Re: Sales per year report off by
Perhaps passing _uc_reports_timezone_offset() as the 4th parameter to format_date() would fix some things?
Patch posted
There's a patch posted on drupal.org for those who are interested in trying it: http://drupal.org/node/344890.