Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2014
    Location
    United States
    Posts
    5
    Plugin Contributions
    0

    Default Fractional Quantity Sub-Total Rounding Discrepency

    We are selling fabric that is cut to length. There is a discrepancy between in the Sub-Total of the Items as they are displayed to the customer (2 decimal places) and the Sub-Total that is calculated using 4 decimal places. Here is the contents of an Invoice:

    Products Model Tax Price (ex) Price (inc) Total (ex) Total (inc)
    0.5 x Random Pencil Check in Linen CX4840-LINE-D 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Medium Cream Dot in Aqua C630-20-AQUA 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Medium Cream Dot in Gray C630-40-GRAY 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Small Cream Dot in Gray C610-40 GRAY 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Small Cream Dot in Orange C610-20 ORAN 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Ta Dot in Lime CX1492-LIME-D 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Ta Dot in Sea CX1492-SEAX-D 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Medium Cream Dot in Navy C630-21-NAVY 6% $9.75 $9.75 $4.88 $4.88
    0.5 x Boy Triangles in Aqua C3305-AQUA 6% $9.75 $9.75 $4.88 $4.88
    Sub-Total: $43.88
    Zone Rates (Shipping to US): $5.50
    PA Sales Tax: $2.96
    Total: $52.34

    Nine products were ordered, .5 yard of each.
    Using the price for each displayed to the customer: 9 * 4.88 = 43.92
    Using the price calculated under the hood: 9 * (.5 * 9.75) = 43.875

    I've been looking at other threads concerning rounding with discounts and taxes, but I have not seen any involving fractional quantities. I understand that in the database and in the code prices are stored to 4 decimal places. But, the invoice only displays 2, if someone adds it up it doesn't add up.

  2. #2
    Join Date
    Jun 2014
    Location
    United States
    Posts
    5
    Plugin Contributions
    0

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    Sorry for the messy invoice data. I added spaces to reformat it, but after I posted all my spaces got removed.

  3. #3
    Join Date
    Jul 2012
    Posts
    3,108
    Plugin Contributions
    5

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    Quote Originally Posted by saturate View Post
    Sorry for the messy invoice data. I added spaces to reformat it, but after I posted all my spaces got removed.
    So in this case you are concerned that a customer will feel like they have gotten away with a discount and owes you more money? I would say that the problem lies in the pricing not in the calculation. If offering something in partial amounts I would price to the smallest partial amount and multiply across to get the individual unit rather than be concerned that the part of the total doesn't come out, or add some sort of text somewhere to explain what is going on. Otherwise in your scenario, one may want to have the subtotals show up something like 4.88 for the first, and 4.87 for the second and repeat that process for every pair of that item/item type.

    Yeah, most conversations on the rounding calculation issues are about those regarding VAT tax where pricesare shown with tax already in the price and a portion of the price is to be shown as the tax that it is... A lot of "variables" and ways for the calculation to go wrong, depending on which organization gets the extra penny on each calculation and a number of other factors.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    3,520
    Plugin Contributions
    33

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    You might take a look at this thread (no verified solutions, yet, but acknowledgment that a fractional/multiplier/tax rounding issue is present): http://www.zen-cart.com/showthread.p...nding-error%29

  5. #5
    Join Date
    Jun 2014
    Location
    United States
    Posts
    5
    Plugin Contributions
    0

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    I looked at that post. It looked like a lot of code changes in a lot of files and is not yet a proven solution. I'm still new to PHP and trying to figure out the Zen Cart architecture. I've been writing code professionally for over 20 years, but mostly C/C++/C#/VB, motion control, and device interfacing. Did some HTML, Java, Perl, and SQL 19 years ago then my career track shifted. I'm not sure what function does what yet, so I'm cautiously approaching code changes. I'm looking forward to the day when I can answer questions instead of asking them.

    For now it's not a big deal, a few cents in the customer's favor. It's just that when math is wrong it may cause people to question the integrity of the site and business.

    Thanks, I'll keep studying the post you referenced.

  6. #6
    Join Date
    Aug 2009
    Location
    North Idaho, USA
    Posts
    770
    Plugin Contributions
    1

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    FWIW, PayPal doesn't like receiving those fractional quantities & associated rounding issues either.

    We sell in tenth units are in the process of editing all our product prices in dime increments instead of penny increments in an attempt to lessen the number of PayPal error files.... as suggested by mc12345678. TNX, that was a DUH moment for me.
    Rick
    ChainWeavers (dot) com

  7. #7
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    2,507
    Plugin Contributions
    7

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    Quote Originally Posted by lat9 View Post
    You might take a look at this thread (no verified solutions, yet, but acknowledgment that a fractional/multiplier/tax rounding issue is present): http://www.zen-cart.com/showthread.p...nding-error%29
    Thumbs up, I have implemented my solution (post #14 in that thread) on a couple of sites with satisfactory results
    Zen Cart with a Passion (Fair Dinkum Australian): iSO Network | frNT Online Dispensary
    Contribs: CSAR | German Language Pack | Local Delivery Only

  8. #8
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    2,507
    Plugin Contributions
    7

    Default Re: Fractional Quantity Sub-Total Rounding Discrepency

    Quote Originally Posted by saturate View Post
    I looked at that post. It looked like a lot of code changes in a lot of files and is not yet a proven solution. I'm still new to PHP and trying to figure out the Zen Cart architecture. I've been writing code professionally for over 20 years, but mostly C/C++/C#/VB, motion control, and device interfacing. Did some HTML, Java, Perl, and SQL 19 years ago then my career track shifted. I'm not sure what function does what yet, so I'm cautiously approaching code changes. I'm looking forward to the day when I can answer questions instead of asking them.

    For now it's not a big deal, a few cents in the customer's favor. It's just that when math is wrong it may cause people to question the integrity of the site and business.

    Thanks, I'll keep studying the post you referenced.
    Don't be afraid to make changes as long as you make backups of the files and DB before you hack some code.
    Zen Cart with a Passion (Fair Dinkum Australian): iSO Network | frNT Online Dispensary
    Contribs: CSAR | German Language Pack | Local Delivery Only

 

 

Similar Threads

  1. Sub Total not calculating correctly with quantity discounts
    By tbaquatics in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 16 Nov 2009, 10:38 PM
  2. Fractional Quantity Rounding Price
    By christianpatrick in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 1 Apr 2009, 03:57 PM
  3. Quantity Discounts not showing in Sub Total
    By beatnik in forum Basic Configuration
    Replies: 0
    Last Post: 14 Apr 2008, 04:19 PM
  4. [Done v1.3.7] Error when setting fractional quantity.
    By millo_magno in forum Bug Reports
    Replies: 5
    Last Post: 7 Mar 2007, 05:55 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
  •