WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Print Invoice & Delivery Note
Show tax and tax rate per line? (16 posts)

  1. TartanLad
    Member
    Posted 1 year ago #

    My client has asked that her printed invoices show the price, tax rate and tax amount per line - to comply with UK law on VAT invoices over £250.

    This is particularly important as her shop sells 20% rated and zero rated items and these absolutely have to be shown clearly and separately on any invoice.

    I wasn't sure, so looked it up on HMRC.gov.uk and yes it's true!

    I'd wrongly assumed there would be an extension that did this straight off as it's the UK law (probably is elsewhere too) but haven't found one.

    So now I need to add the item tax rate and the item tax, each line per item on the invoice. I've spent literally 6 hrs today searching.

    Can anyone help please? It's pretty urgent - I'd pay if needed.

    http://wordpress.org/extend/plugins/woocommerce-delivery-notes/

  2. wp_hela
    Member
    Posted 9 months ago #

    @tartan lad: Still looking?

  3. TartanLad
    Member
    Posted 9 months ago #

    yes - I understand the plugin developer is working on it as there is pressure from German customers too for whom current setup is illegal.

    But any help before this comes out would be good.

  4. webby1973
    Member
    Posted 9 months ago #

    @TartanLad : could you please show me an exemple of what you are asking to be implemented? I think it's the same for the Italian market. Thank you.

  5. wp_hela
    Member
    Posted 9 months ago #

    This is what I did:

    1) copy order-details.php to your-child-theme/woocommerce/order/order-details.php

    2) look around line 72 for:
    echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';

    //hela this shows the vat
    //echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';

    $_tax = new WC_Tax();//looking for appropriate vat for specific product
    $rates = array_shift($_tax->get_rates( $_product->get_tax_class() ));
    if (isset($rates['rate'])) { //vat found
    if ($rates['rate'] == 0) { //if 0% vat
    $prima_tax_rate=$mehrwertsteuerBefreit;
    } else {
    $prima_tax_rate="inkl. ".round($rates['rate'])."% MwSt. ";
    }
    } else {//FailSafe: just in case ;-)
    $prima_tax_rate=$failSafe;
    }
    echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item,"" ) .'<span style="font-size:smaller; margin-left:1em;">(' .$prima_tax_rate . ')</span></td></tr>';

    This does the trick for me

    regards
    Heinz

  6. proxio
    Member
    Posted 8 months ago #

    Hi,

    Nothing changed for me when i put your code ... the pdf order is the same :(

    what did i do wrong ?

  7. wp_hela
    Member
    Posted 8 months ago #

    @proxio: I don't know ;-)

    1st check wether you are working on the correct file!

    e.g. 2) look around line 72 for:
    echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';

    and change it to:
    echo '</td><td class="product-total">@@@This is my file@@@' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';

  8. prepu
    Member
    Posted 8 months ago #

    @wp_hela, I have done what you say and I doens't work. First thing I am not sure is which line do I have to delete and replace it.
    Do I have to change anything to work with my theme or wordpress (I have to say that I have it in spanish).

    Your help is very appreciated because it is something that I am looking for a long time.

  9. wp_hela
    Member
    Posted 8 months ago #

    @prepu

    Did you find this line in your /woocommerce/order/order-details.php???

    echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item ) . '</td></tr>';

    I work here with this version of the file:
    /**
    * Order details
    *
    * @author WooThemes
    * @package WooCommerce/Templates
    * @version 2.0.3
    */

    I guess spanish doesn't make any difference

    regards
    Heinz

  10. prepu
    Member
    Posted 8 months ago #

    @wp_hela
    Actually, I have the order-details.php here: /wp-content/plugins/woocommerce/templates/order/

    I have found the line that you told me. I copied that file to my child's theme (and same directory).
    After that I wrote below that line the following:
    $_tax = new WC_Tax();//looking for appropriate vat for specific product
    $rates = array_shift($_tax->get_rates( $_product->get_tax_class() ));
    if (isset($rates['rate'])) { //vat found
    if ($rates['rate'] == 0) { //if 0% vat
    $prima_tax_rate=$mehrwertsteuerBefreit;
    } else {
    $prima_tax_rate="inkl. ".round($rates['rate'])."% MwSt. ";
    }
    } else {//FailSafe: just in case ;-)
    $prima_tax_rate=$failSafe;
    }
    echo '</td><td class="product-total">' . $order->get_formatted_line_subtotal( $item,"" ) .'<span style="font-size:smaller; margin-left:1em;">(' .$prima_tax_rate . ')</span></td></tr>';

    And it doesn't work. I think you have it for germany becuase of "mehrwertsteuerBefrei" it is something that I will translate later when it works.
    Am I doing something wrong?

    Thanks

  11. prepu
    Member
    Posted 8 months ago #

    @wp_hela, I worked partly!!
    I mean, in a new order now I see the % rate when I finish the order.
    What it is still not working is in the "invoice delivery note". There is without the % rate.
    Did you change also something in any of the .php of the plugin?

    Thank you.

  12. wp_hela
    Member
    Posted 8 months ago #

    @prepu:

    invoice delivery note? ... are talking about the woocommerce delivery notes plugin?

    If yes, see what I did:

    In .../plugins/woocommerce-delivery-notes/templates/print/print-delivery-note.php araound line 87

    //hela
    								//echo $item['price'].'<span style="font-size:smaller; margin-left:1em;">(inkl. ' .round($item['line_tax']/$item['line_subtotal']*100,0) . '%)</span>';
    $_tax = new WC_Tax();//MwSt.-Satz für Produkt raussuchen
    global $product;
    								$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
    $rates = array_shift($_tax->get_rates( $_product->get_tax_class() ));
    if (isset($rates['rate'])) {//Den zugewiesenen MwSt-Satz anzeigen
        if ($rates['rate'] == 0) {//Alternativtext, wenn 0% MwSt.
    	$prima_tax_rate=$mehrwertsteuerBefreit;
        } else {
            $prima_tax_rate="inkl. ".round($rates['rate'])."% MwSt. ";
        }
    } else {//FailSafe: Wenn irgendetwas schiefgeht, besser das anzeigen, als gar nichts.
        $prima_tax_rate=$failSafe;
    }
    
    echo $item['price'].'<span style="font-size:smaller; margin-left:1em;">(' .$prima_tax_rate . ')';

    So as you can see, I didn't change much of the previous code in the order-datails.php

    regards
    Heinz

  13. prepu
    Member
    Posted 8 months ago #

    @wp_hela

    Yes... I am using the same plugin but I wrote badly... hehehe.
    The code you wrote looks good but I have some problem to insert it in my print-delivery-note.php.
    Do you mind to send my the whole file by email? My email is davidkrema@yahoo.com

    My last question: With that code you edited the "delivery note". Do you have to edit also the print-invoice.php?

    Thank you in advance.

  14. prepu
    Member
    Posted 8 months ago #

    I don't know why but I cannot add your code to the file... grrrr!!

    Your file will be appreciated. :-)

  15. prepu
    Member
    Posted 8 months ago #

    @wp_hela,
    Please do not disappear now... hehehe.

  16. wp_hela
    Member
    Posted 7 months ago #

    sorry for the delay ... it's on the way ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic