Community Forums

[0.7.9RC7] Products Purchased Report

Enter all OpenCart 0.x bugs here

[0.7.9RC7] Products Purchased Report

Postby fido-x » Fri Jan 23, 2009 4:19 pm

In admin/controller/report_purchased.php (line 28), the database query --
Code: Select all
$results = $database->getRows("select name, model, sum(quantity) as quantity, sum((total + tax) * quantity) as total from order_product group by model order by total desc");

multiplies the quantity twice returning an incorrect value.

Where the query says --
Code: Select all
sum((total + tax) * quantity) as total from order_product

The "total" field in the order_product table already contains the value of unit price multiplied by the quantity purchased, subsequently the end value returned by the query is equal to "((unit price times quantity) plus tax) times quantity)".

Changing the query to --
Code: Select all
$results = $database->getRows("select name, model, sum(quantity) as quantity, sum(total) as total from order_product group by model order by total desc");

returns a correct value if tax is included in the unit price (like the GST in Australia) or if no tax is applied.

Since there are a variety of ways that tax can be applied (eg. fixed amount, percentage, applied to the product, applied to the total order), it makes it difficult to suggest a fix. But it does beg the question, is it necessary to include taxation in this particular report?

Fido-X.
Image
If you're not living on the edge ... you're taking up too much space!
Multi-Vendor Plugin for OpenCart 1.5.1.x
Have I helped you?
User avatar
fido-x
 
Posts: 1960
Joined: Fri Jun 27, 2008 5:09 pm
Location: Tasmania, Australia

Re: [0.7.9RC7] Products Purchased Report

Postby Qphoria » Fri Jan 23, 2009 4:54 pm

Ah wow.. great catch! Yea i see i have sold 4 x $10 products and it totals $80!

And perhaps you are right about the tax thing as well, as this is at the product level, it doesn't include coupons, tax, etc. So it should likely only calculate product total (which includes discounts) * qty. The full order total is handled on the sales report.
Last edited by Qphoria on Fri Jan 23, 2009 5:06 pm, edited 1 time in total.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [0.7.9RC7] Products Purchased Report

Postby Qphoria » Tue Jan 27, 2009 3:19 pm

Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18242
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

Hosted by Arvixe Web Hosting