Page 1 of 1

Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Mon Dec 15, 2014 8:44 pm
by SelfSus
Hey guys.

Our tax year run 1 March to end Feb every year.

OC's default runs 1 jan to end Dec.

is there a simple way to change the "Total Sales This Year" Date range?

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Mon Jan 05, 2015 3:54 pm
by SelfSus
Bump

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Mon Jan 05, 2015 6:09 pm
by soundzgood-nz
Nope there isn't a simple change - however I'd recommend using the Sales Report under Reports > Sales > Orders where you can set the date range and also importantly the order statuses so you get the range you want and actual valid orders in the total sales (the dashboard total includes ALL order statuses, around 10 of which are invalid eg canceled orders)

Simon

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Mon Jan 05, 2015 10:11 pm
by SelfSus
Hey Simon.

Thanks for the response. Yeah I do have Sales Reporting and it works.

The dash would just be nicer if it is customisable as well.

Saffa regards.

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Wed Jan 07, 2015 12:37 am
by webvet
SelfSus

Just noticed your thread - I haven't used OC v1.5.5.1 for a while, but you can change the model for the getTotalSalesByYear query that runs in the database.

If you go to admin/model/sale/order.php and look for the line:

Code: Select all

public function getTotalSalesByYear($year)
Change the NEXT line to:

Code: Select all

$query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND date_added BETWEEN '2014-03-01' AND '2015-02-28'");
I haven't double checked this so PLEASE back up your original admin/model/sale/order.php file (and everything!) or alternatively create a quick vqmod to do this without changing any core files.

This will hard code the dates to your specific tax year - so after the 28th Feb you will need to change the dates for the 2015-16 tax year manually.

Give me a shout if you need the vqmod version - otherwise good luck, hope this helps...

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Wed Jan 07, 2015 7:34 am
by soundzgood-nz
I think if you're going to manually keep the date range up to date then you might want to exclude all the 'non-sale' order ids as well because that query at the moment will include canceled, processing, invalid, failed etc orders which would pretty much make the sales total on the dashboard invalid.

Not sure what order statuses you're running of course but you'd change the WHERE order_status_id > 0 bit to
WHERE order_status_id = <whatever status id COMPLETED is>
or
WHERE order_status_id not in (order status ids not wanted)

Simon

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Wed Jan 07, 2015 8:05 am
by webvet
Fair point - but it is difficult to provide code that will work for everyone as order_status_id's might be different for different stores.

For the OP I kept the query the same as the Opencart core, just changed the dates to match his tax year as opposed to a calendar year.

I have changed my Dashboard reports by vqmod to show what I want, but that won't necessarily work exactly the same for everyone.

Re: Changing Date range on Dashboard Total Sales (1.5.5.1)

Posted: Tue Mar 10, 2015 5:55 pm
by SelfSus
Hey Guys.

Thank you for the feedback much appreciated, I'll implement.