=== Factura ARCA with TusFacturasAPP for WooCommerce ===
Contributors: catcodestudio
Tags: factura electronica, arca, afip, argentina, tusfacturas
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

Issue Argentine electronic invoices (Factura A, B and C, with CAE from ARCA, ex AFIP) for WooCommerce orders through your TusFacturasAPP account.

== Description ==

TusFacturasAPP is an Argentine electronic invoicing platform with a public API. This plugin connects your WooCommerce store to your own TusFacturasAPP account, so a paid order becomes an invoice authorized by ARCA (ex AFIP), with no Zapier in between.

API service for Argentine electronic invoicing provided by [TusFacturasAPP®](https://www.tusfacturas.app). TusFacturasAPP is a third-party product. This is an independent integration, not affiliated with or endorsed by it.

= What it does =

* **"I need an invoice with my data" at checkout**, classic and block: type and number of document, IVA condition and name. The CUIT check digit is verified, and a registered, Monotributo or exempt buyer must give a CUIT.
* **The right letter by itself**: a registered taxpayer issues A to registered and Monotributo buyers and B to the rest; Monotributo and exempt sellers issue C.
* **Sales with no buyer's data**, the documented way, within the amount ARCA allows. The plugin reads that amount from the API once a day and asks for a document above it.
* **IVA from the order**: 27, 21 and 10.5 % from the taxes WooCommerce charged. If your shop has WooCommerce taxes off, you choose the rate inside the prices: in the settings, by category or by product (also 0 %, exempt and not taxed). The invoice comes to what the buyer paid.
* **It works while ARCA is down**: documents go to the processing queue of TusFacturasAPP, which issues them when ARCA is back. Your checkout never waits for ARCA.
* **No duplicates**: an unanswered request is looked up by its reference before anything is sent again.
* **The result comes back by itself**, by webhook or, without one, by asking every 15 minutes: CAE, due date, number, observations of ARCA.
* **The PDF stays in your shop**: the links of the API expire, so the file is stored on your site.
* **What to do with an error** in the order box: send back to the queue, send back with today's date, or delete, correct and issue again.
* **A copy of your shop does not invoice**: if the site's address changes, nothing is issued until you save the settings there.

= What you need =

An account on TusFacturasAPP with an API plan and a point of sale linked to ARCA. On the free API DEV plan you can test: documents come back without a CAE and have no fiscal validity. The plugin says so on each of them.

= Not included =

* Factura E (export) and Factura de Crédito Electrónica MiPyME: the queue does not take them. Issue those in TusFacturasAPP.
* IIBB or RG 5329 perceptions: no calculation here. A perception agent can add them through the `catcode_tusfacturas_document` filter. Ask your accountant.

= Pro =

* Issue automatically at the order status you choose, for orders with the buyer's data or for all. Also as a bulk action on the orders list.
* Credit notes for WooCommerce refunds, by line or by amount, by hand or by themselves, citing the invoice.
* TusFacturasAPP e-mails the PDF to the buyer.
* The buyer downloads the PDF from the order page, also as a guest through the order link, and the order e-mails link to it.
* Record the payment in the customer's account on TusFacturasAPP, so your accounts there stay right.
* Check a CUIT at ARCA from the order: name, condition, state and the APOC base.
* Send all failed documents back to the queue in the order they were sent, as the documentation asks after a fall of ARCA.
* 7-day trial. No card, and it never starts by itself.

= External services =

This plugin connects to the API of TusFacturasAPP (`https://www.tusfacturas.app/app/api/v2/`), operated by VOUSYS, to issue the invoices you ask for and to follow their state. It sends your API credentials with every request, and, when a document is issued: the buyer's name or legal name, document number, IVA condition, e-mail, province and billing address, and the lines, prices and taxes of the order. Nothing is sent until you enter credentials and issue a document (by hand or, in Pro, by the rule you set). PDF files are then downloaded from the links the API returns.

Terms of service: https://www.tusfacturas.app/terminos-y-condiciones.html

The Pro build also contacts `https://catcode.com.ua` to check the licence key and to look for updates. It sends the key, the address of the site and the module's name. Terms: https://catcode.com.ua/terms/

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. Open WooCommerce → Factura ARCA and enter the API key, API token, user token and point of sale (in your account: Menú > Mi espacio de trabajo > Puntos de venta).
3. Choose your IVA condition and, if your shop charges no tax in WooCommerce, the rate inside your prices. Press "Test the connection".
4. Optional: paste the webhook address shown on the settings page in your point of sale, and copy its token back.
5. Try one order on the API DEV plan before you go live.

== Frequently Asked Questions ==

= Why not Zapier? =

The documentation of TusFacturasAPP shows how to build it with Webhooks by Zapier: you map the fields by hand and keep an eye on its logs, and neither side supports the result. This plugin decides the letter and the IVA, follows ARCA's answer and keeps the PDF.

= Does it replace my accountant? =

No. Which rate applies, whether to issue B to a foreign buyer and whether you are a perception agent are questions for your accountant.

= What happens if ARCA is down? =

The document waits in the queue of TusFacturasAPP, which retries up to 100 times. The order shows "in the queue" until there is an answer.

= Can an issued invoice be deleted? =

No, ARCA does not allow that. It is reversed with a credit note.

= My shop is not in pesos. =

Pesos, dollars and the currencies in the API's table work, with the rate of ARCA read from the API. Only documents in pesos can record the payment on TusFacturasAPP.

== Changelog ==

= 1.0.0 =
* First release.
