Great great set of modules. Thank you.
Sales Reports By Year for seller reports income in November instead of October...
Problem with module? Database?
Has anyone else experienced this?
Reporting is correct under Ubercart Orders but not in marketplace reporting.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pixlkat’s picture

I see this with the latest dev version (downloaded today, 11/26/2010) as well. In addition, the year total at the end is off by one year.

I am migrating an existing non Drupal/Ubercart site and have been adding old orders. I have a seller with one sale in December 2008. That shows up in January 2009 along with her other 2009 sales (but both off by one month). Year total shows the one sale from 2008 instead of the two that should be there for 2009 (even though they are in the month listing). Seems everything is off by one.

After a bit more investigating, I figured something out. The order created used is stored as a unix timestamp which is in GMT format. The code uses gmmktime() to create a timestamp for each of the months as so --gmmktime(0,0,0,$year, $month, 1). Then it uses format_date() to get the month, day, and year out. That is converting the GMT time to the local timezone so (for me anyway) the month is now wrong. I set the $timezone parameter in format_date to 0 and the reports were correct.

rgs’s picture

Wow pixlkat, finally. Thank you. Which file is this changed in? Would you mind sending a snippet of code? Thank you!!

rgs’s picture

Jeez I really owe you one pixlkat. Found and made the change and two months of hunting for a solution are over. Worked like a charm. I can't thank you enough. Best, Ray.

jeffl8n’s picture

Status: Active » Needs review
FileSize
1.14 KB

This is also in the latest dev, as of today. Attaching a patch for the fix based off dev.

sokrplare’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
Techexpert29’s picture

Issue summary: View changes

Hi,

Thanks for all the info you guys provided regarding the issue. I found it all helpful.

I am using drupal 6 and facing similar issue in seller report when i look at sales summary by year, it shows Oct sales in November and total sales for year 2014 is showing under total sales of 2015.

Post applying the below changes to my file "mp_reports.admin.inc", it fixed the monthly issue i.e. now oct sales is showing in oct instead of nov but my yearly sales still showing wrong. Can you help me all steps and all files need to be modified to fix this issue.

Thanks in advance.

--- mp_reports\mp_reports.admin.inc
+++ mp_reports\mp_reports.admin.inc
@@ -180,12 +566,12 @@
- $timezone_offset = time() + variable_get('date_default_timezone', 0);
+ $timezone_offset = variable_get('date_default_timezone', 0);
$order_statuses = "('complete')";

// Get the year for the report from the URL.
if (intval(arg(5)) == 0) {
- $year = format_date($timezone_offset, 'custom', 'Y', 0);
+ $year = format_date(time() + $timezone_offset, 'custom', 'Y', 0);
}
else {
$year = arg(5);
}

// Build the header for the report table.
@@ -194,8 +580,8 @@
// Build the header to the csv export.
$csv_rows = array(array(t('Month'), t('Number of orders'), t('Total revenue'), t('Average order')));

// 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);
- $month_end = gmmktime(23, 59, 59, $i + 1, 0, $year);
+ $month_start = gmmktime(0, 0, 0, $i, 1, $year) - $timezone_offset;
+ $month_end = gmmktime(23, 59, 59, $i + 1, 0, $year) - $timezone_offset;