Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Posts
    4
    Plugin Contributions
    0

    bug incorrect subtotal calculation with Swedish Krona with 0 decimal symbols

    ZenCart 1.5.0, fresh install

    I have some difference between sum of all products and subtotal amount. In last research it's 1 Swedish Krona with 0 decimal symbols (integer amounts).

    BUG #1:
    It caused by calculating subtotal in default currency (e.g. euro), and converting to Krona at the end.

    So in abstract formula we have:

    convert(price1+price2+price3) != convert(price1)+convert(price2)+convert(price3)

    BUG #2:
    Other bug in zen_round. It doesn't wrap all use cases of types casting. I loose 0.01 in euro on subtotal in this case:
    Qty. Item Name Tax Total
    1 x Disciples: Sacred Lands Linked 7.25% €96.53
    1 x A Bug's Life "Multi Pak" Special 2003 Collectors Edition
    Color: Green
    Size: Medium
    Version: 20th Century
    Media Type: DVD 7.25% €39.67
    2 x Microsoft IntelliMouse Explorer
    Model: USB 7.25% €152.19

    Subtotal: €288.38 (Should be 288.39)

    Feel free to use my solution, it works perfectly for me:
    PHP Code:
    function zen_round($fNum$iPrec 2) {
            return empty(
    $fNum) ? (int): (int)(string)(round($fNum$iPrec) * pow(10$iPrec));
        } 

  2. #2
    Join Date
    Apr 2012
    Posts
    4
    Plugin Contributions
    0

    Default Re: incorrect subtotal calculation with Swedish Krona with 0 decimal symbols

    Quote Originally Posted by j_vovus View Post
    I have some difference between sum of all products and subtotal amount. In last research it's 1 Swedish Krona with 0 decimal symbols (integer amounts).
    I want to clarify some moments:

    Quoted line is related to BUG #1 with Krona.

    Besides, BUG #2 is tested in Euro with two decimal places (I think it's not depend on currency).

  3. #3
    Join Date
    Apr 2012
    Posts
    4
    Plugin Contributions
    0

    bug Re: incorrect subtotal calculation with Swedish Krona with 0 decimal symbols

    Also, I'm sure, this bugs do not depend on the exact currency.
    BUG #1 depends on any currency conversion (where ratio is not 1:1).
    BUG #2 depends on PHP type casting during rounding.

    Best regards,
    Vladimir

 

 

Similar Threads

  1. Subtotal incorrect since adding tax to shipping
    By ericvanwenkop in forum General Questions
    Replies: 1
    Last Post: 28 Aug 2010, 01:49 PM
  2. cart subtotal display incorrect by a pence
    By kitcorsa in forum General Questions
    Replies: 2
    Last Post: 18 Mar 2010, 05:01 PM
  3. Replies: 4
    Last Post: 14 Jan 2009, 11:45 AM
  4. Group pricing per item plug-in for v1.3.7 has incorrect cart subtotal
    By monkle in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 15 Jun 2008, 01:00 AM
  5. Subtotal incorrect
    By gschep in forum General Questions
    Replies: 2
    Last Post: 30 Jul 2007, 02:35 PM

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