=== FacturaLibre for WooCommerce ===
Contributors: facturalibrecl
Tags: boleta electronica, factura electronica, sii, chile, woocommerce
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
WC requires at least: 7.0
WC tested up to: 11.2
Stable tag: 1.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatic Chilean electronic receipts and invoices (SII) for every WooCommerce
sale, issued by FacturaLibre.

== Description ==

Every paid order issues its own tax document, with no manual work:

* **Electronic receipt ("boleta electrónica") by default**: the buyer receives
  it by email.
* **Electronic invoice ("factura electrónica")** when the buyer enters the RUT,
  company name and line of business of their company at checkout (optional
  fields the plugin adds to both the block-based and the classic checkout).
* **No waiting at checkout**: the document is issued in the background, moments
  after payment.
* **Exactly what was charged**: the document adds up to the order total,
  including shipping, fees and discounts.
* **Automatic retries** if your hosting or the network fails. The server is
  idempotent per order number, so a document is never duplicated.
* **Recorded on the order**: folio number and document type in the orders list
  and in the order notes, plus an "Emitir documento en FacturaLibre" order
  action in case a retry is needed.

You need a FacturaLibre account (https://facturalibre.cl) and an API key
(app.facturalibre.cl → Integraciones → API). Folio ranges (CAF) are managed for
you: FacturaLibre requests them from the SII before they run out.

FacturaLibre is an electronic invoicing service for Chile. The plugin and its
settings screens are in Spanish, the language of the stores it serves.

== External services ==

This plugin connects to the FacturaLibre API (https://app.facturalibre.cl), the
service that issues the documents with Chile's tax authority (Servicio de
Impuestos Internos, SII). The plugin cannot work without it: nothing is issued
otherwise.

What is sent and when: when an order moves to "Processing" (or to "Completed",
depending on the setting), the plugin sends the order number, the line items
with quantity and price, the shipping cost, and the buyer's details (name and
email; and, if they requested an invoice, their RUT, company name, line of
business, address and commune). When the settings are saved, the API key is
sent to verify the connection. Nothing else leaves your site.

The service is provided by FacturaLibre SpA: terms of service at
https://facturalibre.cl/terminos and privacy policy at
https://facturalibre.cl/privacidad.

== Installation ==

1. Download `facturalibre-for-woocommerce.zip` from
   https://facturalibre.cl/docs/woocommerce and upload it under Plugins → Add
   New Plugin → Upload Plugin (or upload the `facturalibre-for-woocommerce`
   folder to `/wp-content/plugins/`).
2. Activate it.
3. Go to WooCommerce → Settings → Integration → FacturaLibre: paste your API
   key, choose when to issue (on payment or on completion) and save. The screen
   confirms whether the connection works and which business it is linked to.
4. Place a test order: the document appears in the "Documento SII" column of
   the orders list and in your FacturaLibre dashboard.

== Frequently Asked Questions ==

= What if the SII is down? =
Nothing for you to do: FacturaLibre signs the document and retries on its own
until the SII receives it. The order keeps its folio number.

= Can a customer request an invoice? =
Yes. If they enter the RUT, company name and line of business of their company
at checkout (and the mode is "Automático"), an invoice is issued instead of a
receipt.

= What if I refund an order? =
The plugin leaves a note on the order reminding you to void the document with
a credit note from app.facturalibre.cl → Documentos. It does not void it by
itself.

= An order has said "En proceso" for a while =
Issuing runs through WordPress scheduled tasks (WP-Cron). If your hosting has
them disabled, the plugin shows a notice in the admin; check WooCommerce →
Status → Scheduled Actions.

= Where can I see the documents? =
In app.facturalibre.cl → Documentos. The folio number is also recorded on each
order.

== Changelog ==

= 1.2.1 =
* Renamed to "FacturaLibre for WooCommerce" (folder, main file and text domain
  `facturalibre-for-woocommerce`), the naming pattern the WordPress.org
  directory allows for the WooCommerce trademark. No functional changes. If you
  installed 1.2.0 (folder `facturalibre-para-woocommerce`), deactivate and
  delete it before uploading this one: the API key and settings are kept (they
  live in WooCommerce, not in the plugin folder).
* readme in English, as the directory requires.

= 1.2.0 =
* Test mode: with a test API key (fl_test_) the plugin issues documents in your
  business's test environment in FacturaLibre (simulated SII, no tax validity,
  no email to the buyer). The WooCommerce screens show a notice and each order
  is marked "PRUEBA · Boleta N° …".
* When a test key is replaced by a production key, the settings warn that
  documents issued in test mode are not reissued automatically; on a test
  order, "Emitir el documento real en FacturaLibre" issues the real document.
* Refunding an order with a test document no longer asks for a credit note.

= 1.1.1 =
* Folder, main file and text domain renamed to `facturalibre-para-woocommerce`.
  If you installed 1.1.0 (folder `facturalibre-woocommerce`), deactivate and
  delete it before uploading this one; the API key and settings are kept.
* The settings screen says where the key is created: Integraciones → API.
* The installation guide is public: https://facturalibre.cl/docs/woocommerce,
  with the downloadable ZIP.

= 1.1.0 =
* Issuing runs in the background: the buyer no longer waits for the SII when
  paying.
* Block-based checkout: asks for RUT, company name and line of business for the
  invoice.
* Classic checkout: also asks for the company name (the invoice no longer came
  out in the person's name).
* Compatible with High-Performance Order Storage (HPOS).
* The document adds up to exactly what was charged: unit price times quantity
  without rounding, fees and discounts included.
* An order that goes straight to "Completed" (downloadable products) also
  issues a document.
* A receipt without a RUT is emailed to the buyer.
* Honors the retry hints from the server; never asks to issue manually a
  document that was in fact issued.
* "Emitir documento en FacturaLibre" order action, connection test when saving
  the settings, and a notice on refund or cancellation.

= 1.0.0 =
* Initial release: receipt or invoice on order completion, RUT at checkout,
  retries with backoff, order column and notes.
