Europe : rounding tax to nearest .5 cents (eliminate pennies)
live in switzerland where penny/1 cent is nonexistant, so i need to find a way to get the TVA VAT tax to automaticall round to the nearest .0 or .5 or .55. does anyone have some advice?
found this block of code in functions and also simlar in classes and it seems like it could be here to find a solution but after a few tests can't figure it out:
// Calculates Tax rounding the result
function zen_calculate_tax($price, $tax) {
global $currencies;
// $result = bcmul($price, $tax, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
// $result = bcdiv($result, 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
// return $result;
return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
Not sure if this will work, but try it...
ADMIN >>> LOCALISATION >>> CURRENCIES
Select the relevant currency, click EDIT.
Set DECIMAL PLACES to "1".
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
tnaks for your reply. i tried that already and it works to some extent but what about when a price ot tax should display as for example 22.55?
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
sorry, dyslexic typist :-)
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
Quote:
Originally Posted by
nan
live in switzerland where penny/1 cent is nonexistant, so i need to find a way to get the TVA VAT tax to automaticall round to the nearest .0 or .5 or .55. does anyone have some advice?
found this block of code in functions and also simlar in classes and it seems like it could be here to find a solution but after a few tests can't figure it out:
// Calculates Tax rounding the result
function zen_calculate_tax($price, $tax) {
global $currencies;
// $result = bcmul($price, $tax, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
// $result = bcdiv($result, 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
// return $result;
return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
// return $result;
return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
Try changing to 10
I'm NO CODER - so I could be taking you far from where you want to be! Also, changing this will have a GLOBAL effect on all selected currencies.
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
I think that what you actually need could be a bit of javascript, for example, that rounds this up (or down) as you suggest.
But I can't help you there!
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
Hi there,
Did you have any luck finding a solution to get zencart rounding to the nearest 5 cts?
Cheers,
Ed
How to round TAX/VAT the swiss way?
Hello fellow Zenners,
I am desparately seeking hellp on a TAX/VAT rounding for a Swiss zencart (1.3.8). Apparently the Swiss do not use rappen( pennies, cents). In stead they round their totals to the nearest 5 cts. No amount less than 5 cents in cash or paid in the invoice. See details below
I spend a good few hours looking into the problem and trawling forums (even those of OSC) but no simple and consistent solution is available.
My cart is already configured with net prices and all prices are multiples of 5 already. Thus, the only thing I need is rounding of the tax component in both the catalog and admin section.
How do I do this? Where do I need to hook in? Your suggestions are most welcome.
Some more info on the rounding:
Crucial to the rounding is the middle between 0 and 5 cents, respectively 5 to the nearest 10 cents. If the number to be rounded is equal to or higher than the middle, the number is rounded up, otherwise it's are rounded down.
Beispiel: Example:
* 1,000–1,024 → 1,00 1,000-1,024 → 1.00
* 1,025–1,074 → 1,05 1,025-1,074 → 1.05
* 1,075–1,099 → 1,10 1,075-1,099 → 1.10
Suggested method: round(((amount+0.000001)*2),1) / 2;
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
In the following code (posted earlier)...
PHP Code:
// Calculates Tax rounding the result
function zen_calculate_tax($price, $tax) {
global $currencies;
// $result = bcmul($price, $tax, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
// $result = bcdiv($result, 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
// return $result;
return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
... all of the lines preceded with "// have no effect as they are commented.
The line that says:
PHP Code:
return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
Change:
$tax / 100
to
$tax / 20
I really don't know if this will work, but my logic is that 100 divided by 20 is 5 - and as you are looking for a rounding factor of 5, then dividing by 20 may give you the desired result.
In your currency setting in Admin, leave the number of decimal places at 2.
Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)
If you want to have all currencies round to 5 cents its the easiest when you change the zen_round() function in
/includes/functions/functions_general.php
line 173 - 179
Code:
// Wrapper function for round()
function zen_round($number, $precision) {
/// fix rounding error on GVs etc.
$number = round($number / 5, $precision) * 5;
return $number;
}
Replace the entire function or add the highlighted sections.