Forums / Currencies & Sales Taxes, VAT, GST, etc. / Sales Report / Tax Issue

Sales Report / Tax Issue

Locked

Started by urbankaiote on 22 Oct 2007, 7:47 AM · Views: 2,305

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
22 Oct 2007, 7:47 AM
#1
urbankaiote avatar

urbankaiote

New Zenner

Join Date:
Oct 2007
Posts:
2
Plugin Contributions:
0

Sales Report / Tax Issue

The sales report in my build of zen cart sets the decimal places in the tax to 00 regardles of the actual tax:

I am having an issue in the sales report section. The figures aren't adding up. I have set it up for Australia with a GST of 10% and separate GST for freight of 10% as described in another thread. I have tried a fresh install. None of these measures have worked for me. I have tried editing the PHP file myself and casting the quantity to be a float as I thought that perhaps multiplication involving an int would truncate the decimals altogether, only to be readded when formatted as currency. However, fiddling around with this has yielded not only no positive results but no changes whatsoever. If anyone can help me before I tear my hair completely out I would be stoked.

Cheers,

Kai

PS, my version details are as follows.

Zen Cart 1.3.7
Database Patch Level: 1.3.7
v1.3.7 [2007-04-30 14:51:42] (Fresh Installation)

PHP Version 4.4.7

System Windows NT WIN9 5.2 build 3790
Build Date May 3 2007 10:02:27
Server API CGI/FastCGI
Virtual Directory Support enabled
Configuration File (php.ini) Path E:\hshome\echo0\electronicsnow.com.au\php.ini
PHP API 20020918
PHP Extension 20020429
Zend Extension 20050606
Debug Build no
Zend Memory Manager enabled
Thread Safety enabled
Registered PHP Streams php, http, ftp, compress.zlib

23 Oct 2007, 5:35 AM
#2
murrah avatar

murrah

New Zenner

Join Date:
Oct 2007
Posts:
12
Plugin Contributions:
0

Re: Sales Report / Tax Issue

Kai,

I just installed the Sales Reports module and noticed the same thing.

What I have discovered is as follows:

in {root}\includes\functions\general.php there is a function:

function zen_calculate_tax($price, $tax) {
global $currencies;
return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}

Now, it seems that the problem is that the currencies[DEFAULT_CURRENCY]['decimal_places'] is blank instead of having 2 (which is what is in the database table) and after testing I find that if you pass a blank to the zen_round function it rounds to 00 (which is what you'd expect).

The sales report shows the correct tax if you change the above call to:
return zen_round($price * $tax / 100, 2);

Now, I cant figure out why the default currency is returning blank, but at least we are progressing.

Any ideas ?

Murray (also in Oz)

23 Oct 2007, 7:36 AM
#3
murrah avatar

murrah

New Zenner

Join Date:
Oct 2007
Posts:
12
Plugin Contributions:
0

Re: Sales Report / Tax Issue

OK,

I seem to have solved the tax rounding problem (but there are still problems with the calculation of the tax allowing for coupons and freight?? More on that later, I hope.)

In the template \admin\stats_sales_report.php at line 592 you will find:

require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

Move those two lines to the top of the page (c line 33) after
require('includes/application_top.php');

so it reads:

require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

The problem was that the $currencies variable was not being declared until AFTER the tax was being calculated so it didnt know how many decimal places to round to and therefore rounded it to 0 decimals instead of 2.

Now.... what is going on with the actual calculations???? Stay tuned.

Murray

23 Oct 2007, 8:51 AM
#4
urbankaiote avatar

urbankaiote

New Zenner

Join Date:
Oct 2007
Posts:
2
Plugin Contributions:
0

Re: Sales Report / Tax Issue

Murray - you are a legend. I'll add those lines in a minute. As for the actual calculations, it appears to be the issue that it is using the totals stored in the database to add work out the GST for each item, whereas each item is also calculating it's own GST. I think this would be fine except what it appears to be doing is rounding for each item separately when calculating the GST, but then using the total ex GST for the price for the total at the end and calculating the price for that and rounding. This usually results in a difference of a couple of cents at my end. I'm currently checking that out as well, so will post if I get it before you do (If we've got the same issue here).