[0.7.9RC7] Products Purchased Report
3 posts
• Page 1 of 1
[0.7.9RC7] Products Purchased Report
In admin/controller/report_purchased.php (line 28), the database query --
multiplies the quantity twice returning an incorrect value.
Where the query says --
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 --
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.
- 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.

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?
-

fido-x - Posts: 1960
- Joined: Fri Jun 27, 2008 5:09 pm
- Location: Tasmania, Australia
Re: [0.7.9RC7] Products Purchased Report
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.
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.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [0.7.9RC7] Products Purchased Report

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18242
- Joined: Mon Jul 21, 2008 7:02 pm

3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest













