Plugin Author
Diego
(@daigo75)
Hi Alex,
The EU VAT Assistant doesn’t automatically alter invoices, but it provides functions that you can call to determine if an order was exempt from VAT under the reverse charge rules. You can then use such functions to customise your invoices, and show the “reverse charge” message.
Here’s a brief example of how you can call such functions.
1. Initialise the integration
// Use the Order class from the EU VAT Assistant, which provides functions to fetch VAT data
$euva_order = new \Aelia\WC\EU_VAT_Assistant\WCPDF\EU_Invoice_Order($order_id);
// Initialise the EU VAT Assistant helper,
$eu_invoice_helper = \Aelia\WC\EU_VAT_Assistant\WCPDF\EU_Invoice_Helper($euva_order);
2. Fetch and print VAT information
// Fetch the invoice currency
$invoice_currency = $eu_invoice_helper->invoice_currency();
// Fetch the exchange rate used to convert the total from the order currency
// to the VAT currency
$vat_currency_exchange_rate = $eu_invoice_helper->vat_currency_exchange_rate;
// If the order is subject to the reverse charge rules, display a note
if($eu_invoice_helper->reverse_charge()) {
echo 'VAT reverse charged';
}
// Fetch the VAT data from the EU VAT Assistant
$vat_data = $euva_order->get_vat_data();
// Print VAT details
// - $tax_info['label'] contains the label (name) of the tax rate
// - $tax_info['amounts']['total'] contains the total tax for a specific tax rate
foreach($vat_data['taxes'] as $tax_info) {
echo "Tax rate: " . $tax_info['label'];
echo "Tax total: " . wc_price($tax_info['amounts']['total']);
}
Should you have any questions on how to use the functions, please feel free to ask. Thanks.
Hi Diego,
thanks for your feedback. I reviewed your intructions and all information contained in a sample order layout. It seems that only the VAT exempt functionality is missing. However, I am not familiar with the initialisation process (I am not a developer). Where should I access this initialisation working environment in order to be able to enter the VAT exempt string?
One additional question. I see 2 versions of the VAT EXEMPT String.
One on the forum which reads:
// If the order is subject to the reverse charge rules, display a note
if($eu_invoice_helper->reverse_charge()) {
echo ‘VAT reverse charged’;
}
One on the msg that I received on my Outlook client, which reads:
// If the order is subject to the reverse charge rules, display a note
if($eu_invoice_helper->reverse_charge()) {
echo 'VAT reverse charged';
}
Which is the correct one? does 039 code have a specific meaning?
Best regards
Alex
Sorry, that’s the string I see on the Outlook msg.
'VAT reverse charged'
Best regards
Alex
Plugin Author
Diego
(@daigo75)
Character #039 is just a single quote. It’s most likely how Outlook displays that special character. The correct character is the one at the beginning of this 'VAT reverse charged'.
Regarding the place where to use the code, that depends on the invoicing plugin you use. Most of them offer filters and actions to add information to the invoices. If you contact the plugin’s authors, they should be able to tell you which actions are available, to show the information where you need it. That’s where you will place your code, to verify if the order is VAT exempt and display the “reverse charge” note.
If you need assistance implementing this customisation, you can contact us and send us the information you received from the authors of the invoicing plugin, and we can prepare an estimate for you.
Quick note for anyone attempting to use the above examples, there is a small error in the code:
// Initialise the EU VAT Assistant helper,
$eu_invoice_helper = \Aelia\WC\EU_VAT_Assistant\WCPDF\EU_Invoice_Helper($euva_order);
should be replaced with:
// Initialise the EU VAT Assistant helper,
$eu_invoice_helper = new \Aelia\WC\EU_VAT_Assistant\WCPDF\EU_Invoice_Helper($euva_order);