=== NAV Online Számla for WooCommerce ===
Contributors: catcode
Tags: nav, online szamla, szamla, hungary, invoice
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
WC requires at least: 8.0
WC tested up to: 11.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Hungarian invoices from WooCommerce orders, reported directly to NAV Online Számla API 3.0 with your own technical user — no SaaS fee.

== Description ==

NAV Online Számla for WooCommerce issues an invoice for every order and reports its data to the Hungarian tax authority (NAV, Online Számla rendszer) through the official REST API 3.0 — the same way invoicing programs do it, with the technical user of your company. There is no invoicing service in between and no monthly fee.

**Free version**

* Invoice for every order of a Hungarian buyer — private person (reported as PRIVATE_PERSON, without name and address, as NAV requires) or company with a tax number (DOMESTIC) — created when the order reaches the status you choose.
* Direct reporting: `tokenExchange` → `manageInvoice` → `queryTransactionStatus`, requests signed with SHA3-512 as the NAV specification describes, the data reporting token decoded with your exchange key.
* Every invoice is checked against the official NAV XML schemas (shipped with the plugin) and the most common NAV blocking rules (VAT rates, customer data, tax numbers) before a number is used and before anything is sent.
* Processing status in the order: DONE with the NAV warnings (WARN) kept, ABORTED with the error list; "Rebuild and send" with the same number after you fix the order.
* A retry queue that never loses an invoice: network problems, NAV maintenance and a lost answer (timeout) are handled — a lost answer is looked up with `queryTransactionList` after 5 minutes, as NAV recommends, so an invoice is never reported twice.
* VAT from the WooCommerce taxes of each order (27%, 18%, 5%, 0%), several rates on one invoice, exempt lines (TAM) or out of scope (ATK), personal VAT exemption (alanyi adómentes, AAM), cash accounting.
* Tax number field at checkout (classic and block checkout) with the check digit test, and a "Company name" field when WooCommerce hides its own.
* Printable invoice (Hungarian / English labels) for the customer in My Account and by e-mail, shown only after NAV has processed it.
* Your own number series with a year or month counter; test and production keep separate registers.
* Tax authority data export (Decree 23/2014 NGM § 11/A): the documents of a date or number range as a ZIP.

**Pro (7-day free trial, then a licence)**

* Modifying invoices (MODIFY) from WooCommerce refunds — by item or by amount — and cancelling invoices (STORNO) when an invoiced order is cancelled. They are reported after NAV has processed the original, with the right modification index and line references.
* Foreign buyers: EU companies with a VAT number (intra-Community supply, KBAET or EUFAD37), buyers outside the EU (export, EAM or HO), orders in EUR or other currencies with the HUF exchange rate.
* Live check of Hungarian tax numbers at NAV (`queryTaxpayer`) at checkout and in the order.
* Bulk "Report to NAV" for past orders, CSV export of the register, e-mail alerts (refused documents, NAV warnings, delivery problems).

**What you need**

* Registration of your company in the Online Számla system and a technical user created by the primary user, with its signature key (XML aláírókulcs) and exchange key (XML cserekulcs). The test system (onlineszamla-test.nav.gov.hu) needs a separate registration and technical user.
* PHP 7.4+ with the standard hash (SHA3-512), OpenSSL and DOM extensions.

**Please note**

The plugin reports the data of the invoices it issues. Whether your invoicing process as a whole meets the Hungarian rules (the content of the invoice under the VAT Act, electronic invoices, the notification of the invoicing program to NAV, the tax authority export format of Decree 23/2014 NGM) is the responsibility of the seller — check it with your accountant.

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. WooCommerce → NAV Online Számla → Settings: fill in the seller data (tax number, name, address, bank account) and the numbering.
3. In "Technical user (NAV)" enter the login name, the password and both keys, save, then click "Check the connection".
4. Keep the TEST environment for the first orders, check the results in the Invoices tab, then switch to PRODUCTION (with the technical user of the live system).

== Frequently Asked Questions ==

= Is there a test environment? =
Yes: the NAV test system (api-test.onlineszamla.nav.gov.hu). It needs its own registration and technical user. For a first look without any NAV account the plugin can simulate NAV: define `CCNAV_NAV_MOCK` as `ok` in wp-config.php (test environment only).

= When is an invoice reported? =
Right after it is issued — when the order reaches the status you choose, or with "Issue and report" on the order. If NAV cannot be reached, the plugin keeps retrying on its own.

= NAV refused an invoice. What now? =
The error list from NAV is shown in the register and in the order notes. Correct the order and click "Rebuild and send": the invoice is rebuilt with the same number — the customer only receives an invoice after NAV has processed it.

= Where are the keys stored? =
The password is kept only as its SHA-512 hash (that is all NAV needs). The signature key and the exchange key are stored encrypted with the secret keys of your site, or can be defined in wp-config.php (`CCNAV_LOGIN`, `CCNAV_PASSWORD`, `CCNAV_SIGN_KEY`, `CCNAV_EXCHANGE_KEY`).

= Other currencies? =
The free version issues invoices in HUF. Pro adds other currencies with the HUF exchange rate from the settings or from the `ccnav_exchange_rate` filter.

== Privacy ==

The plugin sends invoice data (seller, buyer tax number, name and address of companies, lines, amounts) to NAV — the purpose of the Online Számla reporting. For private persons no name or address is sent. Licence checks contact catcode.com.ua with the licence key and the site address only.

== Credits ==

The XML schemas in includes/schemas are published by the Hungarian National Tax and Customs Administration (NAV) under the MIT licence (github.com/nav-gov-hu/Online-Invoice, github.com/nav-gov-hu/Common).

== Changelog ==

= 1.0.0 =
* First release.
