=== Nubefact Invoicing for WooCommerce ===
Contributors: catcodestudio
Tags: nubefact, sunat, factura electronica, boleta, 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

Issue boletas, facturas and credit notes (SUNAT electronic invoices) for WooCommerce orders through your Nubefact account.

== Description ==

Peruvian shops must give every sale a SUNAT electronic receipt. [Nubefact](https://www.nubefact.com/) is a SUNAT-authorised operator with a REST API; this plugin connects WooCommerce to that API, so the receipt is created from the order instead of being typed into another system.

* **Boleta or factura at checkout:** the customer picks DNI, carnet de extranjería, passport (boleta) or RUC (factura) and enters the number. The RUC check digit is verified before the order is placed. Works in the classic checkout and in the block checkout.
* **One click on the order:** the Nubefact box on the order screen issues the document, shows the answer of SUNAT and links to the PDF, XML and CDR.
* **Amounts taken from the order lines** (after coupons, before and after tax): taxable, exonerated and unaffected (IGV) lines, shipping and fees as services, soles, US dollars, euros or pounds with the exchange rate you set. An order whose tax does not match the IGV rate is stopped with a clear message instead of being sent wrong.
* **Correlative numbering** per series, kept by the plugin under a lock, so two orders never get the same number. A reply that did not arrive is retried with the same number and the same unique code, and a document Nubefact already has is fetched instead of being issued twice.
* **The customer sees it:** a PDF link in the order page of the account and in the order e-mails.
* HPOS (custom order tables) supported.
// @pro-begin
* Spanish translation included.
// @pro-end

// @pro-begin
= Pro =

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

* **Automatic issue** when the order reaches the status you choose, with retries if Nubefact or SUNAT is not reachable.
* **Credit notes from WooCommerce refunds** — full, by item or by amount.
* **Voiding** (comunicación de baja) from the order screen.
* **Bulk action** on the orders list.
* **Nubefact e-mails the document** to the customer, and documents SUNAT has not accepted yet are re-checked in the background.

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

= What you need =

A Nubefact account with the API (Integración) option switched on — it gives you a route and a token. Start with the DEMO account. Series and the tax treatment of your products are set up with your accountant; the plugin does not give tax advice.

= External service =

The plugin sends data to the Nubefact API at the route you enter (nubefact.com or a pse.pe reseller address, https only). Sent when you issue, look up or void a document, or run the connection test: the token, the series and number, the customer's name, identity number, address and e-mail, the order lines and amounts, the payment method title and the order number. Nothing is sent before you enter the route and the token and a document is requested. Service: [nubefact.com](https://www.nubefact.com/). Make sure your privacy notice covers it.
// @pro-begin

The Pro version also contacts catcode.com.ua to activate and check the licence key (the key and the site address) and to look for updates.
// @pro-end

The plugin is independent and not affiliated with Nubefact or SUNAT.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. WooCommerce → Nubefact: enter the route and the token of your Nubefact account, the series, and the IGV rate; press "Test the connection".
3. Place a test order, open it and press "Issue the document".

== Frequently Asked Questions ==

= Does the plugin work without a Nubefact account? =

No. It sends the document to your Nubefact account, which creates the XML and the PDF and sends it to SUNAT.

= Who sets the series and the numbers? =

You, with the series registered in your Nubefact account. Numbers run one by one from 1; if you already issued documents, set the next number in the settings.

= What if the tax of an order is not 18 %? =

The order is not sent; the order note says which line does not match. Set the same rate in WooCommerce → Settings → Tax and in the plugin, or mark the products as exempt.

= Which currencies are supported? =

Soles, US dollars, euros and pounds. For the last three enter the exchange rate to soles in the settings.

= Where do I see why a document was refused? =

In the order notes and in the Nubefact box on the order: the text comes from Nubefact or SUNAT.

== Changelog ==

= 1.0.0 =
* First release: connection to the Nubefact API, boleta or factura choice at checkout (classic and block), issuing from the order screen, status lookup, correlative numbering, customer PDF link.
