Before answering your question, we must clarify that modifying the data recorded by the EU VAT Assistant is not an officially supported operation. In some jurisdictions, it’s also not allowed by law to change the details of an invoice that has already been generated. Due to that, we strongly advise to contact your tax consultant before making any modifications.
Technical details
The EU VAT Assistant stored a set of data in the following custom meta:
1. _eu_vat_data
. This meta is an array that contains the details of the tax applied to an order.
2. _eu_vat_evidence
. This meta is an array that contains evidence about customer’s location and VAT number.
3. vat_number
. This is a copy of the VAT number stored in the _eu_vat_evidence
. This copy is stored to make it easier for 3rd parties or custom code to access it.
If you wish to change the VAT number used by the EU VAT Assistant for the reports, you will have to modify it in two places:
1. You will need to modify the _eu_vat_evidence
meta. Something like the following could work:
$eu_vat_evidence = $order->get_meta('_eu_vat_evidence');
$eu_vat_evidence['exemption']['vat_number'] = '<NEW VAT NUMBER>';
$order->update_meta_data('_eu_vat_evidence', $eu_vat_evidence);
$order->save_meta_data();
This is not an officially supported operation, therefore we can’t guarantee that it will work as you expect.
2. You will need to modify the vat_number
meta, to keep it in sync with the evidence, which is the one that actually matters:
$order->update_meta_data('var_number', '<NEW VAT NUMBER>');
$order->save_meta_data();
The above will replace the data in the database, and the new data will be used by the reports.
Important
Please keep in mind that this won’t apply a VAT exemption on an order, nor will it refund any VAT that has been paid. Due to that, to have a cleaner status, it might be better to simply cancel the order and create a new one with the correct VAT number.
-
This reply was modified 2 years, 10 months ago by
Diego. Reason: Formatting