=== Faro Factu – Tax Details ===
Contributors: farowp
Tags: woocommerce, invoices, vat, tax, billing
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Validates Spanish tax IDs (NIF, NIE, CIF) at WooCommerce checkout, saves them on the order and exports them for your accountant.

== Description ==

Faro Factu – Datos fiscales adds the fiscal data a Spanish invoice needs and validates it before the customer pays. It does not issue invoices and it does not send anything to the Spanish tax agency (AEAT): it makes sure the data you are going to invoice is correct.

**What it does**

* Adds a tax ID field (NIF, NIE or CIF) to the checkout, in both the block checkout and the classic checkout.
* Validates the document for real, not with a regular expression: it checks the control letter of a NIF or NIE and the control digit of a CIF, so a typo or an invented number is rejected before payment.
* Optionally asks for the company name and the intra-EU VAT number.
* Saves the data on the order (compatible with HPOS) and shows it in the order screen, in the order emails and in the orders list.
* Lets the shop staff correct the tax ID of an existing order without touching the database.
* Exports the fiscal data of any date range to a CSV that opens cleanly in Excel and LibreOffice.
* Generates the AEAT verification QR for invoices issued with another system, following the four mandatory parameters (NIF, serial number, date and amount).

**What it does not do**

* It does not issue invoices, it does not chain records and it does not send anything to the AEAT.
* It does not call any external service. No data leaves your server.

**Requirements**

* WordPress 6.5 or later.
* WooCommerce 8.6 or later.
* PHP 7.4 or later.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`, or install it from the Plugins screen.
2. Activate it through the Plugins screen in WordPress.
3. Go to WooCommerce → Tax details and set your tax ID, your territory and whether the tax ID is mandatory.
4. Open WooCommerce → Diagnostics to check the store is ready.

== Frequently Asked Questions ==

= Does this plugin issue invoices? =

No. It collects and validates the fiscal data. Issuing, chaining and sending invoices to the AEAT is the job of a billing system (a SIF, in Spanish).

= Is it mandatory for my customers to enter a tax ID? =

No, it is optional by default. You can make it mandatory in the settings, but for a shop selling to the general public it is usually better to leave it optional and only validate it when it is filled in.

= Does it work with the block checkout? =

Yes. It registers the fields through the WooCommerce Additional Checkout Fields API, so they appear in the block checkout, and it also supports the classic checkout.

= Does it work with HPOS? =

Yes. The plugin declares compatibility with WooCommerce custom order tables.

= What happens to the data if I uninstall the plugin? =

The plugin settings are deleted. The fiscal data stored in each order is kept, because it is part of the record of the sale.

= Does it validate VAT numbers against VIES? =

No. It validates the format and, for Spanish numbers, the control digit. Checking a VAT number against VIES requires an online call to the European Commission, which this plugin does not make.

== Screenshots ==

1. Checkout with the tax ID field and its validation.
2. Fiscal data shown in the order screen.
3. Readiness check for Spanish e-invoicing rules.
4. AEAT verification QR generator.
5. CSV export of the fiscal data.

== Changelog ==

= 0.4.0 =
* New: three-step getting started guide when the plugin is activated.
* New: customer type selector (individual, Spanish company, EU company) with conditional fields.
* Fix: the CSV export now includes orders that only carry an EU VAT number.

= 0.3.1 =
* The diagnostics and the product card adapt to the store territory: the paid product is not advertised where Veri*factu does not apply or the tax is not covered.

= 0.3.0 =
* Diagnostics: new check for an active Veri*factu billing system, with an informational card about the paid product.

= 0.2.3 =
* WordPress notices are back in their natural place, above the plugin header.

= 0.2.2 =
* WordPress and third-party notices were shown below the header (reverted in 0.2.3).

= 0.2.1 =
* Header with the official FaroWP lighthouse icon.
* WordPress notices no longer overlap the header.

= 0.2.0 =
* Panel redesign: brand header, tabs and cards shared by all four screens.
* CSV export now includes orders that only carry an EU VAT number.
* Fixed the block-checkout field registration (unsupported attribute).

= 0.1.0 =
* First version: tax ID fields for block and classic checkout, real NIF/NIE/CIF validation, order meta, emails, admin correction, readiness check, QR generator and CSV export.

== Upgrade Notice ==

= 0.4.0 =
Adds the getting started guide and the customer type selector with conditional fields.

== External services ==

This plugin does not connect to any external service and does not send data anywhere.

== Credits ==

* QR generation uses [qrcode-generator](https://github.com/kazuhikoarase/qrcode-generator) by Kazuhiko Arase, licensed under the MIT license. The library is bundled in `assets/js/qrcode.js`.
