Page 1 of 1

Last month filter

Posted: Wed Jan 20, 2010 9:14 am
by jmestep
One of our clients brought this to our attention. In the tax report on all versions I tested and in the order management page in versions older than 7.0.4, the Last month filter doesn't work. In the tax report, it doesn't show any results and in the header it shows 12/31/09 to 12/31/08.
mazhar, have you got a quick fix? I've posted a bug report.

Re: Last month filter

Posted: Wed Jan 20, 2010 12:21 pm
by mazhar
Judy I have already posted a fix for Last Month on order admin. Please have a look at it
viewtopic.php?f=42&t=12658
I guess very similar fix would apply on Tax report as well.

Re: Last month filter

Posted: Wed Jan 20, 2010 2:48 pm
by jmestep
Thank you. I didn't even think of searching for it!
Edit:
I looked in the Taxes report and it is different, and I don't have time to figure it out, especially since it's an Able bug and a possibly minor thing.
What should I change there?
case 4:
//last month
DateTime lastMonth = DateTime.Now.AddMonths(-1);
HiddenStartDate.Value = new DateTime(lastMonth.Year, lastMonth.Month, 1).ToString();
DateTime lastDayOfLastMonth = new DateTime(lastMonth.Year, DateTime.Now.Month, 1).AddDays(-1);
HiddenEndDate.Value = lastDayOfLastMonth.ToString();
break;

Re: Last month filter

Posted: Thu Jan 21, 2010 8:55 am
by mazhar
Try updating the all code statement with Last month case block of switch statement with following code lines for Tax report.

Code: Select all

DateTime lastMonth = DateTime.Now.AddMonths(-1);
HiddenStartDate.Value = new DateTime(lastMonth.Year, lastMonth.Month, 1,0,0,0).ToString();
DateTime lastDayOfLastMonth = new DateTime(lastMonth.Year, DateTime.Now.Month, 1).AddDays(-1);
lastDayOfLastMonth = new DateTime(lastDayOfLastMonth.Year, lastDayOfLastMonth.Month, lastDayOfLastMonth.Day, 23, 59, 59);
HiddenEndDate.Value = lastDayOfLastMonth.ToString();

Re: Last month filter

Posted: Thu Jan 21, 2010 12:35 pm
by jmestep
Thanks, but it didn't work.

Re: Last month filter

Posted: Thu Jan 21, 2010 1:01 pm
by mazhar
I have looked into the matter by debugging the code and it seems its a different issue although time part fix will make it more accurate. The code in Last Month block was calculating wrong year. Here is complete fix

Code: Select all

HiddenStartDate.Value = new DateTime(lastMonth.Year, lastMonth.Month, 1,0,0,0).ToString();
int numberOfDays = DateTime.DaysInMonth(lastMonth.Year, lastMonth.Month);
DateTime lastDayOfLastMonth = new DateTime(lastMonth.Year, lastMonth.Month, numberOfDays);
lastDayOfLastMonth = new DateTime(lastDayOfLastMonth.Year, lastDayOfLastMonth.Month, lastDayOfLastMonth.Day, 23, 59, 59);
HiddenEndDate.Value = lastDayOfLastMonth.ToString();

Re: Last month filter

Posted: Thu Jan 21, 2010 5:37 pm
by jmestep
Thanks, that worked.
I had to add DateTime lastMonth = DateTime.Now.AddMonths(-1); on the line after
case 4:
//last month.

I was able to patch it into the manage orders page also.