=== CatCode Invoices with Cuéntica for WooCommerce ===
Contributors: catcodestudio
Tags: cuentica, invoices, facturas, accounting, 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 Cuéntica as invoices and creates the customer there without duplicates, with your numbering series and the right Spanish VAT rates.

== Description ==

You sell with WooCommerce and keep the books in Cuéntica. This plugin turns each order into a Cuéntica invoice, so nobody types it in by hand.

Cuéntica is a third-party product. This is an independent integration, not affiliated with or endorsed by Cuéntica or its owner.

= What it does =

* **Invoice from each order**, created in Cuéntica as a draft for you to check, when the order reaches the statuses you choose.
* **Customers are found or created.** The plugin looks for the customer by tax number, or else by e-mail, and creates one only if there is none. A customer already in Cuéntica is never changed.
* **Customers without a tax number.** A Spanish private customer with no NIF goes to "Clientes varios", which Cuéntica uses when an invoice names no customer. Foreign customers are created with an empty tax id.
* **The tax rates of the order, as they are.** Cuéntica accepts 0, 3, 4, 7, 9.5, 10, 12, 13.5, 20 and 21 percent on a line. An order with another rate is held back with a clear message, instead of an invoice with a wrong rate.
* **Your numbering series.** The plugin never sets a number by hand.
* **Totals are checked before sending.** If the lines do not add up to what the customer paid, nothing is sent and you are told why.
* **Foreign currencies** that Cuéntica supports are sent as such. Cuéntica applies the exchange rate.

= Built not to issue an invoice twice =

* Jobs wait in a queue and run one at a time.
* If Cuéntica does not answer while an invoice is being created, the next attempt first looks for it in Cuéntica, and creates it only if it is not there.
* A staging copy stays quiet. If the site's address changes, sending stops until you confirm that this is the real store, otherwise a test order would become a real invoice.

= Built for the Cuéntica limits =

Cuéntica allows 600 API calls every 5 minutes and 7,200 a day on every account, and all tools on one account share them.

* An order costs 2 to 4 calls. Returning customers cost the fewest, because the plugin remembers them.
* When Cuéntica says to wait, the plugin waits as long as it was told and keeps every job.
* The Activity tab shows the calls made today and the jobs waiting.

= Try it without risk =

Every Cuéntica account can create a sandbox company, a copy with its own tokens. Connect the plugin to the sandbox first, place a test order, and move to the real company by pasting a new token.

= What it does not do =

* It does not submit anything to the tax authorities itself. Cuéntica registers invoices with Verifactu or TicketBAI according to the setting of your company.
* It does not change or cancel a Cuéntica invoice when an order changes afterwards. It leaves a note on the order, and the decision is yours.

= Pro =

Sold on [catcode.com.ua](https://catcode.com.ua/modules/cuentica-invoices-woocommerce/) with a 7-day trial:

* **Issue invoices** straight away instead of leaving drafts. Off by default, so that you can check a few drafts first.
* **Mark the charge as paid**, with the payment method taken from the gateway and the company account you choose for each.
* **E-mail the invoice** to the customer through Cuéntica, with the PDF, with a subject and text you write.
* **Void the invoice** when an order is fully refunded.
* **NIF / VAT number field at checkout**, classic and block, with the Spanish check digit validated.
* **Invoice PDF** on the order screen and, if you want, under My account > Orders.
* **Send past orders** in bulk from the orders list.
* **E-mail alerts** when Cuéntica refuses the token, the allowance runs out or a job gives up.

Partial refunds are not turned into rectifying invoices: correct those in Cuéntica.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. In Cuéntica, open the user menu, choose API, create a token with read and write permissions on your company (or on a sandbox company first).
3. Open **WooCommerce > Cuéntica** and paste the token. It is kept encrypted with your site's keys.
4. On the **Invoices** tab choose the statuses, the account the invoices are collected into and the numbering series.
5. Place a test order and check the draft in Cuéntica before relying on it.

== Frequently Asked Questions ==

= Does this need a CatCode account? =

No. The plugin talks to Cuéntica directly, with your own token.

= Will old orders be sent when I connect? =

No. Only orders placed after connecting are sent automatically. An older one can be sent from its own screen.

= Why is the invoice date today and not the order date? =

Cuéntica refuses a date earlier than the last invoice issued in the same series. You can choose the order date on the Invoices tab if your orders are always sent the day they are paid.

= An invoice was not sent. What now? =

The Activity tab and a note on the order give the reason. Fix it and press Retry.

= I also use a Verifactu plugin. Is that a problem? =

Choose one system to register your invoices, so that the same sale is not registered by two of them.

== External services ==

This plugin connects to the Cuéntica API (api.cuentica.com), a service of Ecosistemas Digitales de Negocio, SL, which is what it exists for. It sends nothing until you connect an account.

* What is sent: your token with each call. For each order: customer name, company, tax number, e-mail, phone and address; the order lines, prices, taxes, date, currency and payment method.
* When: when you connect or refresh the lists, and when an order reaches a status you chose.

With Pro also: the payment date and company account when you turn on payments; the customer's e-mail address when you ask Cuéntica to e-mail the invoice.

The Pro build also connects to catcode.com.ua for the license and for updates, sending the key and the site address. [Terms](https://catcode.com.ua/terms/), [privacy policy](https://catcode.com.ua/privacy/).

Cuéntica [legal notice](https://cuentica.com/aviso-legal/).

== Screenshots ==

1. Connecting the Cuéntica account.
2. Account, numbering series and statuses.
3. Activity with the calls made today.

== Changelog ==

= 1.0.0 =
* First release.
