• In the tax rapport I get this error:

    Invalid country, check error log.

    Which error log? And how do I fix it?

Viewing 1 replies (of 1 total)
  • Plugin Author Diego

    (@daigo75)

    That error usually appears when there are tax rates configured with an invalid country code. When we designed the EU VAT Assistant, we assumed that the tax rates would always have a valid country (e.g. AT, DE, GB, FR, etc) for each row. If a row has a blank country code, or has an asterisk (i.e. “*”), the “invalid country code” can appear. The reason for that is that, without an actual country code, the EU VAT Assistant can’t group the taxes by country.

    The error log is stored in folder wp-content/uploads/wc-logs, and has a name like wc-aelia-eu-vat-assistant-[DATE].log. It should contain an entry saying “Tax rate contains an in invalid country code”, followed by the details of the tax rate that contains the invalid code.

    To prevent this issue, it’s sufficient to ensure that every tax rate is assigned to a specific country (i.e. no “*” lines exist). That will allow to track the taxes payable to each country, and show them in the reports.

    After updating the tax rates, the error might persists for orders whose data has already been collected. If this is the case, you should be able to update those orders in a couple of ways:
    1. By editing the order manually. If you enable option “collect VAT data for manual orders”, you can do it as follows:
    1. Edit the order
    2. Set the order status to “pending”.
    3. Click on “Recalculate” to update the VAT data stored against it.
    4. Restore the original order status.
    2. By updating the VAT meta using a code snippet. The VAT data is stored in order meta “_eu_vat_data”. The country for each rate is stored in that meta, which has a structure like the following:

    ['taxes'] = array()
      $tax_rate_id => = array(
        'label' => <value>,
        'vat_rate' => <value>,
        'country' => <value>, // This is the country used for the reports
        'tax_rate_class' => <value>,
      )
    )

    You can replace the value of the country attribute, e.g. by taking it from the order’s billing or shipping country, and save the meta.
    3. By using a script that processes past orders, re-fetching the data for them. We have an example of such script here: https://pastebin.com/Jg4MyP9b. Please note that this script should only be used after configuring the tax rates with the appropriate country code.

    Important
    We strongly recommend to take a full backup of your site, before trying to modify the order data. All the changes made to the orders, using any of the methods listed above, are permanent, and having a backup as safety net is always a good idea.
    It’s also a good idea to modify a couple of orders at a time, to verify that the changes are applied correctly.

Viewing 1 replies (of 1 total)
  • The topic ‘Invalid country’ is closed to new replies.