=== SmartBill & Oblio Invoices for WooCommerce ===
Contributors: catcodestudio
Tags: smartbill, oblio, factura, invoice, 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 (facturi) from WooCommerce orders in SmartBill or Oblio: buyer CUI at the checkout, the invoice and its PDF from the order screen.

== Description ==

Connects a WooCommerce shop of a Romanian company to SmartBill Cloud or to Oblio. You press one button on an order and the invoice appears in your series, with the right buyer and the right VAT rates.

* **One plugin, two services:** choose SmartBill or Oblio. Invoices made before a switch keep their service, so their PDF and storno still work.
* **Invoice from the order screen:** the buyer, the rows (products, shipping, fees) and the VAT rate of every row come from the order. The rows must add up to what the buyer paid; if they do not, the plugin tells you instead of sending a wrong document.
* **Company name, 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 and a CNP typed by mistake is caught.
* **Series and VAT rates read from your account** by "Check the connection".
* **The PDF** of the invoice downloads from the order screen; a list shows what was issued.
* **Never twice:** a failed call is retried by itself, and when the answer of the service was lost the plugin first looks whether the invoice was made (Oblio: the same idempotency key and the invoice list; SmartBill: the series counter). When it cannot be sure, it stops and asks you to look, with the series and number to check.
* **One sale, one invoice** next to our e-Factura ANAF for WooCommerce plugin: orders invoiced in SmartBill or Oblio are not sent to ANAF a second time by it, and orders it already invoiced are not invoiced here. An order with a Keez invoice (Keez Invoices for WooCommerce) is not invoiced here either.
* Secrets are stored encrypted. HPOS (custom order tables) supported.
// @pro-begin
* English and Romanian.
// @pro-end

// @pro-begin
= Pro =

* Invoices made by themselves when an order reaches the statuses you choose, and a bulk action on the orders list.
* The invoice e-mailed to the buyer by SmartBill or Oblio.
* Orders paid online invoiced as collected.
* Storno invoices for refunds, by themselves or with one click: the service reverses the whole invoice, a partial refund becomes an invoice with negative rows. Cancelling an invoice.
* Oblio: the invoice sent to e-Factura (SPV) right after it is issued, with its state on the order.
* The invoice link in My account and in the order e-mails.

The Pro build is sold on catcode.com.ua with a 7-day trial. The licence runs for one year on two sites (the shop and its test copy) 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 > SmartBill & Oblio and choose the service.
3. SmartBill: in SmartBill Cloud, Integrari > API, copy the e-mail, the token and the CIF. Oblio: in Setari > Date Cont, the login e-mail and the API secret, and the CIF of the company.
4. Save, press "Check the connection" and choose the invoice series.
5. Open an order and press "Issue the invoice".

== Frequently Asked Questions ==

= Does it send the invoice to e-Factura? =

SmartBill sends invoices to SPV from its own account settings. Oblio can do it from its account too, and the Pro version can ask Oblio to send each new invoice right away.

= What happens when the service is unreachable? =

The invoice waits and is tried again by itself (up to eight times, with growing pauses). A request whose answer was lost is never simply repeated: the plugin looks for the invoice first.

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

Yes. The buyer fields are added with the additional checkout fields API of WooCommerce. The classic checkout gets billing fields.

== External services ==

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

* **SmartBill** (SmartBill Cloud, Intelligent IT): requests go to `https://ws.smartbill.ro/SBORO/api` with your e-mail and API token. What is sent: the CIF of your company, for every invoice the buyer data (name, address, CUI, trade register number, e-mail, phone), the order rows with prices and VAT, the series; the PDF is downloaded on request. Terms: https://www.smartbill.ro/termeni-si-conditii Privacy: https://www.smartbill.ro/politica-de-confidentialitate
* **Oblio** (Oblio Software): requests go to `https://www.oblio.eu/api` (a token from `/api/authorize/token` with your e-mail and API secret). What is sent: the same data as above. Terms and privacy: https://www.oblio.eu/terms
* **When:** when you check the connection, issue, cancel or reverse an invoice, download its PDF, or send it to SPV.
// @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: SmartBill and Oblio, invoice and PDF from the order screen, company name, CUI and trade register number at the checkout, series and VAT rates from the account, safe retries and lost-answer lookup, one invoice per sale next to e-Factura ANAF and Keez.
// @pro-begin
* Pro: automatic invoices and bulk action, e-mail, collected invoices, storno invoices, cancelling, e-Factura through Oblio, invoice link for the customer, updates from catcode.com.ua.
// @pro-end
