=== Keez Invoices for WooCommerce ===
Contributors: catcodestudio
Tags: keez, factura, invoice, woocommerce, romania
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

Issues invoices from WooCommerce orders in Keez (keez.ro): buyer CUI at the checkout, the invoice and its PDF from the order screen.

== Description ==

Connects a WooCommerce shop to the Keez invoicing service of a Romanian company. You press one button on an order and the invoice appears in Keez with the right buyer, the right VAT rates and the number of your series.

* **Invoice from the order screen:** the buyer, the rows (products, shipping, fees), the VAT rate of every row and the payment type are taken from the order. The rows must add up to what the buyer paid, to the cent; if they do not, the plugin tells you instead of sending a wrong document.
* **CUI and trade register number at the checkout** (classic checkout and the Checkout block). A buyer who enters a CUI is invoiced as a company; the check digit of a Romanian CUI is verified.
* **Company or private person:** Romanian VAT payers, companies without VAT, companies from other EU countries and private persons are sent in the shape Keez asks for.
* **Foreign currency:** an order in EUR or another currency becomes an invoice in RON with the order currency as the reference currency, at the rate you set.
* **The PDF** of the invoice downloads from the order screen; a list of invoices shows what was issued.
* **Safe by design:** a failed call is retried by itself; an invoice is never created twice, even when the answer of Keez was lost on the way; the secret is stored encrypted.
* HPOS (custom order tables) supported.
// @pro-begin
* Romanian translation included.
// @pro-end

// @pro-begin
= Pro =

* Invoices made by themselves when an order reaches the statuses you choose.
* The invoice e-mailed to the buyer from Keez, with the PDF attached.
* Submission to e-Factura (ANAF) for companies or for all invoices.
* Storno invoices for refunds, by themselves or with one click; cancelling or deleting an invoice.

The Pro build is sold on catcode.com.ua with a 7-day trial. 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

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. Open WooCommerce > Keez. In Keez create the API credentials (Settings > API) and enter the client EID, the application ID and the secret. Start with the staging environment.
3. Enter your invoice series exactly as it exists in Keez and press "Check the connection".
4. Open an order and press "Create the invoice in Keez".

== Frequently Asked Questions ==

= Does it work with the Cart and Checkout blocks? =

Yes. The CUI and the trade register number are added with the additional checkout fields API of WooCommerce. The classic checkout gets two billing fields.

= What happens when Keez is unreachable? =

The invoice waits and is tried again by itself (up to eight times, with growing pauses). Before anything is created again, the plugin asks Keez whether the earlier attempt had succeeded, so no invoice is made twice.

= An order has a discount or a fee that the invoice cannot show =

Rows are built from the VAT of every line, shipping and fee of the order. When their sum does not equal the order total the plugin stops with a message and sends nothing.

== External services ==

This plugin sends data to the Keez invoicing service (keez.ro), because that is what it is for. It only talks to Keez after you enter your own Keez API credentials and press the button to create an invoice (or, if you switch it on, when an order reaches a status you chose).

* **What is sent:** the API credentials (to get an access token from `https://app.keez.ro/idp/connect/token`, or `https://staging.keez.ro/idp/connect/token` for the test environment), then for every invoice the partner data of the buyer (name, address, CUI, trade register number), the order rows with prices and VAT, the payment type and the series. The PDF is downloaded from Keez on request.
* **When:** when you check the connection, create or validate an invoice, or download its PDF.
* Keez terms of service: https://www.keez.ro/termeni-si-conditii
* Keez privacy policy: https://www.keez.ro/politica-de-confidentialitate
// @pro-begin
* The Pro build also contacts catcode.com.ua to check its licence and to look for updates; the site address and the licence key are sent. Terms: https://catcode.com.ua/terms/
// @pro-end

== Changelog ==

= 1.0.0 =
* First release: invoice and PDF from the order screen, CUI and trade register number at the checkout, foreign currency, safe retries.
// @pro-begin
* Pro: automatic invoices, e-mail from Keez, e-Factura, storno invoices, updates from catcode.com.ua.
// @pro-end
