=== CFDI with Facturama for WooCommerce ===
Contributors: catcodestudio
Tags: cfdi, facturama, mexico, factura electronica, sat
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 Mexican CFDI 4.0 invoices for WooCommerce orders through your Facturama account: RFC at checkout, SAT codes, PDF and XML in the order.

== Description ==

Facturama is a Mexican electronic invoicing platform with an official app for Shopify, and none for WooCommerce. This plugin connects your WooCommerce store to your own Facturama account, so a paid order becomes a stamped CFDI 4.0.

Facturama is a third-party product. This is an independent integration, not affiliated with or endorsed by Facturama.

= What it does =

* **"I need an invoice" at checkout**, classic and block: RFC, fiscal name, tax regime, CFDI use and fiscal postal code. The RFC format is checked, and the regime and use must fit a person (13 characters) or a company (12).
* **SAT product and unit codes** on the product, on the category or as a default, with a search in the SAT catalogue through your account.
* **A CFDI box in the order**: what stops the order from being invoiced, in plain words; the button; folio fiscal, status, PDF and XML.
* **Taxes from the order**: IVA 16, 8 or 0 %, IEPS when the tax rate is named so, and your choice for lines without tax (rate 0, exempt or no object of tax). Coupons go as the line's discount, shipping and fees as their own lines.
* **No duplicates**: folio and date are fixed before the first call. After a timeout the plugin looks the folio up in Facturama before it sends anything again, as the Facturama documentation asks.
* **Sales to the general public**: an order without an RFC goes to XAXX010101000 with use S01 and regime 616.
* **Other currencies**, with the FIX exchange rate you enter in the order.
* **Sandbox and production**, switched in the settings. Each document remembers where it was issued.

= Pro =

* Issue automatically at the order status you choose, for orders with fiscal data or for all. A lost answer is retried in the background.
* Self-invoicing (autofactura): the buyer requests the CFDI from the order page, also as a guest through the order link, and downloads the PDF and XML there.
* Facturama e-mails the PDF and XML to the buyer.
* Cancel with the SAT motive (01 with the replacement folio, 02, 03, 04). A cancellation waiting for the receiver is followed every hour.
* Credit notes (CFDI type E, related to the invoice) for WooCommerce refunds, by line or for an amount.
* The global invoice: all sales of a period without a CFDI of their own, one concept per sale as the SAT guide asks. Sales in it are marked and cannot be invoiced again.
* Check the buyer's RFC, name, postal code and regime against the SAT records.
* 7-day trial. No card, and it never starts by itself.

= What you need =

A Facturama account. For production: an active subscription, the API annuity and your CSD uploaded to Facturama. Stamps and fees are between you and Facturama. The sandbox at dev.facturama.mx is free.

= What the plugin does not do =

* It issues paid orders only, as payment in one exhibition (PUE). No PPD and no payment complement.
* No Carta Porte, foreign trade complement, withholdings (IVA or ISR retained) or payroll.
* No invoice with the foreign generic RFC XEXX010101000.
* A negative fee cannot be a CFDI line: use coupons for discounts.
* It does not choose SAT codes or tax treatment for you, and it is not tax advice. Agree on them with your accountant.

= External services =

This plugin connects to the **Facturama API** (api.facturama.mx, and apisandbox.facturama.mx in sandbox mode) with the user and password you enter. It sends the order's lines, amounts and taxes and the buyer's fiscal data (RFC, name, regime, CFDI use, postal code) when a CFDI is issued, and searches the SAT catalogues when you use the search box. It sends nothing until you enter your account. Service: https://facturama.mx/ . Terms: https://cdnfacturama.azureedge.net/content/docs/Facturama-terminos-y-condiciones-del-servicio.pdf . Privacy: https://cdnfacturama.azureedge.net/content/docs/Aviso-De-Privacidad.pdf .

The Pro build also talks to **catcode.com.ua**: licence key and site address, to activate the licence and check for updates. Terms: https://catcode.com.ua/terms/ .

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Open WooCommerce → CFDI Facturama, enter the Facturama user and password, and test the connection.
3. Enter the postal code of the place of issue, the SAT code of shipping and how to report lines without tax.
4. Choose the SAT payment form of each payment method.
5. Set SAT codes on your categories or products.
6. Open a paid order and press "Issue CFDI" in the CFDI box.

== Frequently Asked Questions ==

= Is an API key needed? =

No. Facturama authenticates with the user and password of your account. The plugin stores the password encrypted with the keys of your wp-config.php.

= Why must I choose the payment form myself? =

SAT asks for the actual form: credit card (04), debit card (28), transfer (03) and so on. A payment method's id does not say which one it was. Bank transfer, cheque and cash on delivery are preset.

= Why is there no default code for shipping? =

The code depends on what you sell and how you ship. The search box finds it in the SAT catalogue; agree on it with your accountant.

= The order total and the CFDI total differ by a cent =

SAT checks the tax line by line. If WooCommerce rounded the tax further than the tolerance from base x rate, the arithmetic wins. The order box shows the difference before you issue.

= Can I cancel a CFDI? =

In your Facturama account, always. From the order with Pro.

== Screenshots ==

1. The settings: account, invoice data, SAT codes and payment forms.
2. "I need an invoice" at checkout.
3. The CFDI box in the order.

== Changelog ==

= 1.0.0 =
* First release: CFDI 4.0 through Facturama, fiscal data at checkout, SAT codes by product and category, pre-check, PDF and XML.
* Pro: automatic issuing, self-invoicing, e-mail, cancellation, credit notes, global invoice, buyer check against the SAT, automatic updates.
