=== Etochi for WooCommerce ===
Contributors: praxisaurea
Tags: invoice, verifactu, spain, credit note, vat
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 8.1
Requires Plugins: woocommerce
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Issue Spanish invoices, credit notes and VeriFactu records for your WooCommerce orders with Etochi.

== Description ==

Etochi for WooCommerce connects your store to [Etochi](https://praxisaurea.com/portfolio/etochi-software-de-facturacion-electronica/), the invoicing service by Praxis Aurea. Every paid order gets a legal Spanish invoice, registered with the Spanish tax agency (AEAT) through VeriFactu, and every refund gets its credit note.

* Automatic invoice when the order reaches "Processing" or "Completed" (configurable).
* Full invoice (F1) when the customer ticks "I want a full invoice" and enters a NIF/CIF/NIE; simplified invoice (F2) otherwise.
* Tax ID and "I want an invoice" fields for both the classic and the block checkout, with DNI/NIE check letter validation.
* Optional: billing address required only for full invoices.
* Automatic credit notes from WooCommerce refunds (full and partial).
* Order box with number, type, VeriFactu status, QR code, PDF, retry and credit notes.
* Customers download their invoice from "My account" and from the completed order email.
* Automatic retries with Action Scheduler and no duplicates.
* Compatible with HPOS (custom order tables) and the block checkout. The API password is stored encrypted.

An Etochi account is required. The plugin itself is free; the invoicing service is a paid service by Praxis Aurea SL.

== External services ==

This plugin connects to the Etochi API, operated by Praxis Aurea SL, to create and retrieve invoices. Without it, the plugin cannot issue invoices.

* **Where:** the API URL set in WooCommerce → Settings → Etochi (default `https://facturas.praxisaurea.com`).
* **When:** when you press "Test connection"; when an order reaches one of the selected invoicing statuses; when an order is refunded; when you or a customer open an invoice or credit note PDF; and once an hour to update the VeriFactu status of pending invoices. Nothing is sent until you enter your Etochi credentials and enable automatic invoicing.
* **What is sent:** your Etochi username and password (to log in); the customer's name, email, phone, billing address and tax ID (NIF/CIF/NIE) if given; the order number, date, line items, quantities, prices, taxes and totals; and the refund amount, items and reason.
* **What is received:** invoice and credit note numbers, VeriFactu status, QR code URL and PDF files.

The data is used only to issue and store the invoices, as required by Spanish tax law. Etochi forwards the invoice records to the AEAT.

* Legal notice and terms: https://praxisaurea.com/aviso-legal/
* Privacy policy: https://praxisaurea.com/politica-de-privacidad/

== Installation ==

1. Plugins → Add New → search for "Etochi for WooCommerce" (or upload the zip) → Activate.
2. WooCommerce → Settings → Etochi: enter the API URL, your Etochi "api" user and password. Save and press "Test connection".
3. Enable "Issue invoices automatically".
4. Disable any other plugin that issues invoices, so orders are not invoiced twice.

== Frequently Asked Questions ==

= Do I need an Etochi account? =

Yes. The plugin is the connector; invoices are issued and stored by Etochi. Contact Praxis Aurea at https://praxisaurea.com/.

= When is a simplified invoice issued? =

When the customer does not ask for a full invoice or gives no tax ID. Simplified invoices are issued with the generic tax ID 00000000T. Spanish law limits simplified invoices to 400 € (3,000 € for some retail activities), VAT included.

= What happens with refunds? =

Each WooCommerce refund creates a credit note in Etochi: total if the whole order is refunded, partial otherwise.

= I am updating from version 1.1 ("Etochi para WooCommerce") =

Version 1.2 has a new folder name. Install it, then deactivate and delete the old plugin. Settings and invoice links are migrated automatically; nothing is lost.

== Screenshots ==

1. Settings tab with the connection test.
2. Etochi box in the order screen.

== Changelog ==

= 1.2.0 =
* Ready for WordPress.org: GPLv2 or later license, "etochi-for-woocommerce" slug and text domain, unique "etochi_" prefix.
* Scripts moved to enqueued files.
* Automatic migration of settings and order data from 1.1.

= 1.1.0 =
* New brand: Etochi.

= 1.0.1 =
* "Test connection" uses the unsaved form values and says which field is missing.

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.2.0 =
New plugin folder. After installing, deactivate and delete the old 1.1 plugin. Settings are migrated automatically.
