WordPress.org

Support

Support » Plugins and Hacks » Show tax and tax rate per line?

Show tax and tax rate per line?

  • 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/

Viewing 15 replies - 1 through 15 (of 15 total)
  • wp_hela

    @wp_hela

    @tartan lad: Still looking?

    TartanLad

    @tartanlad

    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.

    webby1973

    @webby1973

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

    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

    Hi,

    Nothing changed for me when i put your code … the pdf order is the same πŸ™

    what did i do wrong ?

    @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>’;

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

    @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

    @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

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

    @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

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

    I don’t know why but I cannot add your code to the file… grrrr!!

    Your file will be appreciated. πŸ™‚

    @wp_hela,
    Please do not disappear now… hehehe.

    sorry for the delay … it’s on the way πŸ˜‰

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Show tax and tax rate per line?’ is closed to new replies.