Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Subtotal Calculation Incorrect

  • Resolved Alexander

    (@alexholsgrove)


    I have an order which displays an incorrect subtotal in the Invoice. I have included a screenshot of the WooCommerce order (https://ibb.co/GH2PCzR) and the Invoice (https://ibb.co/8sCgBTr). The calculation in WooCommerce is as follows:

    Item 1 £302.50 x 1 = £302.50 total, £60.50 VAT
    Item 2 £11.67 x 2 = £23.33 total, £4.67 VAT
    Item 3 £11.67 x 2 = £23.33 total, £4.67 VAT
    Item 4 £40.83 x 1 = £40.83 total, £8.17 VAT
    Shipping: 0.00
    VAT: £78.01
    Total: £468.00

    The invoice however, displays

    Item 1 x 1 = £363.00
    Item 2 x 2 = £28.00
    Item 3 x 2 = £28.00
    Item 4 x 1 = £49.00
    Subtotal: £468.01
    Total: £468.00 (includes £78.01 VAT)

    So the subtotal is taking the item values and adding the VAT:
    302.5 + 23.333333 + 23.333333 + 40.833333 + 78.01 = 468.009999 and then rounding to £468.01 which then doesn’t match WooCommerce

    Can you please tell me how to fix this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Ewout

    (@pomegranate)

    Can you show us a screenshot of the WooCommerce email? I expect this will show the same 468.01 value because the Simple template shows the same output as the email data from WooCommerce and doesn’t make any (re)calculations for the subtotal.

    Thread Starter Alexander

    (@alexholsgrove)

    Hello Ewout, thanks for replying so quickly.

    As you expected, the email does also show an incorrect subtotal value (https://ibb.co/0Z3mfFG). We are on WooCommerce version 3.6.4 but I have just tested with the latest 3.7.0 release and this is still an issue.

    So this isn’t an issue with your plugin, but a problem with the WooCommerce core.

    I appreciate this isn’t your issue, but do you know of a way to correct the rounding, just so that I can patch our client’s website?

    Thanks again,
    Alexander

    Thread Starter Alexander

    (@alexholsgrove)

    I’ve just noticed a setting in the admin ” Round tax at subtotal level, instead of rounding per line” which seems to correct this issue. ope that helps someone else!

    Plugin Author Ewout

    (@pomegranate)

    Hello Alexander,
    I believe that WooCommerce made some changes in version 3.7 to prevent rounding issues like this, but of course that will not automatically change existing orders (that would be bad). The only way I can think of is to edit the line items manually and apply your own rounding so that it adds up to the correct amount. It’s also possible that pressing the ‘recalculate’ button with the new 3.7 code also fixes this, but I’m not sure.

    My advice would be to:

    1. Make a backup
    2. Enable editing of paid orders with add_filter( 'wc_order_is_editable', '__return_true' );
    3. Check if recalculate fixes the subtotal
    4. If not, manually adjust
    5. Disable editing of paid orders again

    Hope that helps & good luck!

    Thread Starter Alexander

    (@alexholsgrove)

    I’ve given that a try on WC 3.7 but no luck sadly.
    If I edit the rounding to just 2 decimal places, it corrects the subtotal, but then the rounding down means the grand total is £0.01 less!

    The setting I mentioned before, to apply rounding at subtotal level does however seem to address my problem without having to change any other settings or editing any orders.

    Thanks again for your help.

    Plugin Author Ewout

    (@pomegranate)

    Glad to hear the rounding at subtotal setting works for you. Just out of curiosity: to verify the WooCommerce 3.7 calculations, did you also test a new order or only the existing order?

    Thread Starter Alexander

    (@alexholsgrove)

    Just as a follow up, updating to WooCommerce 3.7 did not fix this problem. Also, the checkbox to apply rounding at subtotal level doesn’t help; either the basket is correct (but checkout confirmation & customer email subtotal are wrong), or by checking the box – the subtotals are correct but the grand total is then wrong instead.

    For anyone interested, I’ve raised a new ticket against WooCommerce here: https://wordpress.org/support/topic/subtotal-calculation-incorrect-2/

    Thread Starter Alexander

    (@alexholsgrove)

    And to answer your question Ewout, I did place a new order – using the same products so that I could compare the calculations properly. It seems to be exactly the same unfortunately. I would have thought something as important as this would have been picked up on by many more users.

    Plugin Author Ewout

    (@pomegranate)

    Thanks for sharing this Alex, I hope they can resolve this once and for all because it has been a lingering issue for some time now: https://github.com/woocommerce/woocommerce/issues/24184 (this also links to other past issues)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Subtotal Calculation Incorrect’ is closed to new replies.