=== Billin ES for WooCommerce ===
Contributors: catcodestudio
Tags: billin, ts facturas, invoice, spain, woocommerce
Requires at least: 6.2
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

Sends WooCommerce orders to Billin (TS Facturas) as invoices or simplified receipts, with IVA, IGIC or IPSI per line, in your own Billin business.

== Description ==

Spanish web shops that issue their invoices in Billin (TS Facturas) end up retyping web orders. This plugin does it through the public Billin API with the API credentials of your own account:

* **Order to document in one click** — from the order edit screen (the Billin ES box or the order actions menu) the plugin creates an invoice with every order line, shipping and fee, or a simplified receipt when the customer has no tax id.
* **Customer data** — name or company, address (with the province code Billin asks for in Spain), email, phone and, if you store it in an order meta field, the NIF / CIF / VAT number.
* **Tax per line** — the rate comes from the WooCommerce tax rate of each line and is sent as a Billin tax key (IVA, IGIC or IPSI); a line with 0 % can be a 0 % rate, exempt, not subject or reverse charge.
* **Discounts kept** — unit price before discounts, the discount amount and the tax of every line are sent, so the totals in Billin match the order.
* **PDF from the order** — download the PDF of the document from the order screen.
* **No double documents** — the document id is kept on the order; pressing the button again does nothing twice, and a send that failed halfway continues where it stopped.
* **Failures are visible** — the reason Billin gave is written to the order notes and shown in the box. A tax rate Billin has no key for stops the order before anything is sent.
* **Refunds** — a refund on a sent order leaves a note to issue the corrective invoice in Billin (corrective invoices are not created automatically).
* HPOS (custom order tables) supported. Spanish translation included.

// @pro-begin
= Pro =

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

* **Automatic sending** when an order reaches the statuses you choose, with retries.
* **Payment registered** against the document in Billin, with the method of the payment gateway (transfer, cash, card, Bizum).
* **Bulk action** in the order list.

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.
// @pro-end

= Not accounting or tax advice =

The plugin sends what your shop and your settings describe. Check the documents in Billin before you rely on them for bookkeeping or tax returns. Businesses with a tax domicile in the Basque Country (TicketBAI) are not supported yet. Billin and TS Facturas are trademarks of their owner; this plugin is made by CatCode and is not made or endorsed by Billin or TeamSystem.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. In your Billin account open the Integrations module and create API credentials (client id and client secret).
3. WooCommerce → Billin ES: paste them, save (the connection is tested), choose the tax and the document type.
4. Open an order and press "Send to Billin".

== Frequently Asked Questions ==

= Where do I get the client id and secret? =

In your Billin (TS Facturas) account, in the Integrations module. They belong to one business and send documents to that business only.

= Invoice or simplified receipt? =

By default an order becomes an invoice when the customer has a tax id (set the order meta key that holds it in the settings) and a simplified receipt otherwise. You can force one type. Which one you may issue is a question for your adviser.

= Which tax rates work? =

The rates Billin lists for IVA, IGIC and IPSI (for example IVA 21, 10, 5, 4 and 0). If an order has another rate, it is not sent and the order note says which line has it.

= Does it create corrective invoices for refunds? =

Not yet. The order gets a note so the refund is not forgotten; the corrective invoice is issued in Billin.

= Does it work in the Basque Country? =

Not yet: businesses with a tax domicile there need extra TicketBAI fields that this version does not send.

== Changelog ==

= 1.0.0 =
* First release: invoice or simplified receipt from a WooCommerce order, tax key per line, PDF download.
// @pro-begin
* Pro: automatic sending with retries, payment registration, bulk action.
* Pro: updates from catcode.com.ua.
// @pro-end
