Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Feb 2008
    Posts
    5
    Plugin Contributions
    0

    Default 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']);
    }

  2. #2
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    10,275
    Plugin Contributions
    3

    Default 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".
    We host with Terranetwork.

  3. #3
    Join Date
    Feb 2008
    Posts
    5
    Plugin Contributions
    0

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

  4. #4
    Join Date
    Feb 2008
    Posts
    5
    Plugin Contributions
    0

    Default Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)

    sorry, dyslexic typist :-)

  5. #5
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    10,275
    Plugin Contributions
    3

    Default Re: Europe : rounding tax to nearest .5 cents (eliminate pennies)

    Quote Originally Posted by nan View Post
    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.
    We host with Terranetwork.

  6. #6
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    10,275
    Plugin Contributions
    3

    Default 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!
    We host with Terranetwork.

  7. #7
    Join Date
    Sep 2008
    Posts
    20
    Plugin Contributions
    0

    Default 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

  8. #8
    Join Date
    Sep 2008
    Posts
    20
    Plugin Contributions
    0

    Default 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,0001,024 → 1,00 1,000-1,024 → 1.00
    * 1,0251,074 → 1,05 1,025-1,074 → 1.05
    * 1,0751,099 → 1,10 1,075-1,099 → 1.10

    Suggested method: round(((amount+0.000001)*2),1) / 2;

  9. #9
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    10,275
    Plugin Contributions
    3

    Default 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.
    We host with Terranetwork.

  10. #10
    Join Date
    Nov 2007
    Location
    Melbourne, Australia
    Posts
    552
    Plugin Contributions
    0

    Default 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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v138a SQL: Rounding Up All prices to nearest pound
    By MeltDown in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 9 Jun 2012, 09:20 AM
  2. Sale Price: Round off to nearest 5 cents
    By cocolala in forum Setting Up Specials and SaleMaker
    Replies: 2
    Last Post: 9 Jan 2012, 03:57 AM
  3. Can I round prices to the nearest 5 cents?
    By xeontranq in forum General Questions
    Replies: 0
    Last Post: 3 May 2010, 04:47 AM
  4. Rounding tax rates, result wrong tax.
    By Swech in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 1
    Last Post: 7 Jul 2009, 02:22 PM
  5. Aust Post Module not rounding up to 5 cents.
    By Lollyworld in forum Addon Shipping Modules
    Replies: 0
    Last Post: 20 Aug 2008, 05:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR