Post by simrae » Wed May 27, 2009 8:50 pm

Everything seems to be working fine on my test site, apart from something screwy with the "Total" column in the Products Purchased Report. It looks like the Total is taking the total for the order and then multiplying it by the quatity - but this isn't necessary as the total has already been multiplied by the quatity factor - it ends up squaring the result!

I don't believe I have modified anything in my code to introduce this effect, but could you please confirm this for me?

I'm using version 1.2.8

Kindest regards,

Simon...

Attachments

Products.jpg

Products report (WRONG) - Products.jpg (15.76 KiB) Viewed 1165 times

Sales.jpg

Sales report (correct) - Sales.jpg (19.04 KiB) Viewed 1165 times

Order.jpg

Original Order - Order.jpg (46.01 KiB) Viewed 1165 times


Newbie

Posts

Joined
Wed May 27, 2009 8:41 pm

Post by simrae » Thu May 28, 2009 6:42 pm

simrae wrote:It looks like the Total is taking the total for the order and then multiplying it by the quatity - but this isn't necessary as the total has already been multiplied by the quatity factor - it ends up squaring the result!...
I think I've found an answer to the problem here! Follow this fix at your own risk, until it is confirmed!

I found what I think is the problem in the "report.php" file found in \sitename\admin\model\report.

Find the follwoing section and delete the section highlighted in RED:

public function getProductPurchasedReport($start = 0, $limit = 20) {
$query = $this->db->query("SELECT op.name, op.model, SUM(op.quantity) AS quantity, SUM((op.total + op.tax) * op.quantity) AS total FROM order_product op LEFT JOIN `order` o ON (op.order_id = o.order_id) WHERE o.order_status_id > '0' GROUP BY model ORDER BY total DESC LIMIT " . (int)$start . "," . (int)$limit);

return $query->rows;


I am not claiming that this IS the bug, but it corrects the output as far as I can see. I'll monitor this fix and report back if I find any unforseen repercussions...

Good luck

Simon...

Newbie

Posts

Joined
Wed May 27, 2009 8:41 pm

Post by yogesh84 » Mon Dec 17, 2012 2:19 pm

I got the same problem that the product purchase report shows the wrong calculation for the total product purchased
Then i checked my admin/model/report/product.php and found query.......

SELECT op.name, op.model, SUM( op.quantity ) AS quantity, SUM( op.total + ( op.total * op.tax /100 ) ) AS total
FROM order_product op
LEFT JOIN `order` o ON ( op.order_id = o.order_id )

i found miss caculation logic applied in query as SUM( op.total + ( op.total * op.tax /100 ) . The mistake i seen that instead of picking the tax rate calulated tax amount has been picked in this query .

Solution that applied that is

SUM( op.total + ( op.tax *op.quantity ) )

this solution works fine for me..................

Newbie

Posts

Joined
Mon Dec 17, 2012 1:51 pm
Who is online

Users browsing this forum: No registered users and 4 guests