Last month filter

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Last month filter

Post by jmestep » Wed Jan 20, 2010 9:14 am

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.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Last month filter

Post by mazhar » Wed Jan 20, 2010 12:21 pm

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.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Last month filter

Post by jmestep » Wed Jan 20, 2010 2:48 pm

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;
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Last month filter

Post by mazhar » Thu Jan 21, 2010 8:55 am

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();

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Last month filter

Post by jmestep » Thu Jan 21, 2010 12:35 pm

Thanks, but it didn't work.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Last month filter

Post by mazhar » Thu Jan 21, 2010 1:01 pm

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();

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Last month filter

Post by jmestep » Thu Jan 21, 2010 5:37 pm

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.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply