=== CatCode Facturae for WooCommerce ===
Contributors: catcodestudio
Tags: facturae, factura electronica, e-invoice, spain, woocommerce
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Facturae 3.2.2 e-invoices for Spanish public administrations from WooCommerce orders, checked against the official schema.

== Description ==

Spanish public administrations take invoices only as Facturae files. This plugin makes that file from a WooCommerce order, on your own server, without a third-party invoicing service.

* **Tax ID and DIR3 codes at the checkout** — the buyer types the NIF/CIF and, for a public administration, the three DIR3 codes: accounting office (oficina contable), managing body (órgano gestor) and processing unit (unidad tramitadora). Classic and block checkout. The control character of a Spanish tax ID is checked.
* **Facturae 3.2.2 from the order** — issuer and buyer, lines with quantity and unit price, coupons as line discounts, shipping and fees, taxes grouped by rate, payment term and IBAN. IVA, IGIC (Canary Islands) and IPSI (Ceuta and Melilla).
* **Checked against the official schema** — every file is validated against the Facturae 3.2.2 XSD published by the Spanish administration (bundled with the plugin) before it is saved. A file that does not pass is not saved, and you see why.
* **Numbering of your own** — a series and a counter that never gives the same number twice and never leaves a gap because of a refused invoice.
* **Corrections in the order** — the tax ID, the DIR3 codes, the proposing body and the file reference (expediente) can be typed or corrected in the Facturae box of the order; the invoice is made again with the same number.
* **Download** — the XML file from the order screen, ready for your signing tool or for the supplier portal of the entry point.
* HPOS and block checkout compatible.
* Translations included: English, Spanish.

The file made by this version is not signed. Entry points such as FACe ask for a signed file: sign it with the signing tool you already use before you send it.

= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/catcode-facturae-for-woocommerce/), with a 7-day trial that never starts by itself:

* **Signature with your certificate** — XAdES signature following the Facturae signature policy, with the certificate of your business (.p12/.pfx or PEM). The private key is stored encrypted; the signature is checked after signing.
* **Corrective invoices** — a refund of an invoiced order gets its factura rectificativa in a separate series, pointing at the invoice it corrects.
* **Automatic invoices** — made, and signed, when the order reaches the status you choose, and attached to the e-mails WooCommerce sends to the buyer.
* **Sending to FACe** — the signed invoice goes to FACe, the general entry point of the Spanish State administration; registry number and status are kept on the order and followed every hour; cancellation can be requested from the order.
* **Bulk export** — a zip with the invoices of the chosen orders or of a period.
* **Journal** — what was signed, sent and answered.
* Updates from catcode.com.ua.

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends. One key covers two sites: the shop and its test copy.

Facturae is the e-invoice format of the Spanish administration and FACe is its entry point for invoices. This plugin is an independent tool made by CatCode; it is not an official plugin of the Spanish administration and is not affiliated with or endorsed by it. You remain responsible for the content of your invoices.

== External services ==

Making and checking the invoice does not use any external service: it happens on your own server, and the schema files the invoice is checked against are bundled with the plugin.

Two Pro features do connect to external services:

**FACe** (the general entry point for e-invoices of the Spanish State administration, [face.gob.es](https://face.gob.es/)) at `api.face.gob.es`, or `se-api-face.redsara.es` for the test environment — only after you upload your certificate and press "Send to FACe", "Ask FACe for the status", "Request cancellation" or "Check connection", or switch on automatic sending:

* the signed invoice (your business data, the buyer's name, tax ID and address, the lines and amounts of the order), its file name and your notification e-mail address;
* the registry number of an invoice sent before, and the reason you typed when asking for a cancellation;
* a short-lived token signed with your certificate, which carries the public part of that certificate.

FACe is run by the Spanish administration. Its conditions of use are shown and accepted when you register in the [FACe integrators portal](https://integradores.face.gob.es/inicio); the service itself is at [face.gob.es](https://face.gob.es/).

**catcode.com.ua** — when you activate a licence key or start the trial, and once a day afterwards: the key, the address of your site and, for the trial, the e-mail address you typed; and the update check of the Pro version. [Terms](https://catcode.com.ua/terms/) · [privacy](https://catcode.com.ua/privacy/)

== Installation ==

1. Upload the plugin and activate it. WooCommerce must be active.
2. WooCommerce → **Facturae**: fill in the data of your business (tax ID, name, address), choose the series and save.
3. Open an order that has the buyer's tax ID and press **Make the invoice** in the Facturae box.
4. Download the XML file.

== Frequently Asked Questions ==

= Which version of Facturae does it write? =

3.2.2, the current version of the format.

= Is the file signed? =

Not in this version. Sign it with your own signing tool before you send it to an entry point.

= Where does the buyer find the DIR3 codes? =

The administration that orders gives them to its suppliers; they can also be looked up in the directory of the entry point (for FACe: face.gob.es, "Directorio").

= Can a private buyer still order? =

Yes. The fields are optional unless you make the tax ID required.

= What happens to invoices when the plugin is removed? =

Orders keep their invoice files, numbers and the data typed by the buyer. The counters of the series are kept as well, so a later installation does not give out a number twice.

= Does it replace my invoicing program? =

No. It writes the Facturae file that public administrations ask for. It does not send records to the tax agency.

== Changelog ==

= 1.0.0 =
* First release.
