=== eRačun HR for WooCommerce ===
Contributors: catcodestudio
Tags: eracun, fiskalizacija, croatia, e-invoice, kpd
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

Croatian eRačun for B2B orders: UBL 2.1 under the HR specification, KPD 2025 on every line, bulk assignment by category, OIB at checkout.

== Description ==

Since 1 January 2026 a Croatian VAT payer issues domestic invoices to other businesses as structured eRačun, not as PDF. From 1 January 2027 this also covers sellers outside the VAT system, such as a paušalni obrt (Zakon o fiskalizaciji, NN 89/25, art. 38 and 80). Every line of an eRačun needs a six-digit KPD 2025 code (art. 42).

eRačun HR turns a WooCommerce order of a business customer into that document:

* **UBL 2.1 under the Croatian specification** ("Specifikacija osnovne uporabe eRačuna s proširenjima", v1.7): OIB as the electronic address (scheme 9934), operator mark and OIB, business process, issue time, HR VAT marks (HR:PDV25, HR:PDV13, HR:PDV5, HR:E, HR:Z, HR:AE, HR:O) and the HR extension where the specification asks for it.
* **KPD 2025 built in**: all 3,359 six-digit codes of the State Bureau of Statistics, searchable in Croatian and English, with or without diacritics. A code that is not on the list is refused when you type it and stopped again before an invoice is issued.
* **Bulk assignment by category**: one screen with all product categories. A product uses its own code, else the code of its category or nearest parent category.
* **OIB at checkout**, classic and block, checked for the control digit, and in the order screen.
* **Invoice numbers in the three legal parts** (17-WEB1-1), gap-free per premises and device, taken under a database lock (art. 9).
* **Pre-check in plain words** before a number is taken: missing KPD, wrong OIB, a VAT rate other than 25, 13 or 5 %, no IBAN, no legal reason for an exempt line.
* **Lines without VAT**: exempt (E), zero rated (Z), reverse charge (AE), and a seller outside the VAT system (O), with your legal text. VAT on collected amounts (HR-BT-15).
* **Totals the way validators check them**: VAT per category; the cent WooCommerce's per-line rounding can differ by goes into the rounding amount, so the amount due is what the customer was charged.
* **Issued documents never change**: the XML is stored with the order. Until it is sent you can rebuild it under the same number.

The XML is made on your server. In the free version you download it and upload it to your information intermediary yourself.

= Pro: sending through moj-eRačun =

* Send invoices and credit notes through the moj-eRačun API v2, demo or live, by hand or automatically on an order status.
* Document, fiscalization and buyer statuses in the order, refreshed every hour. The order gets a note when a document fails, when fiscalization fails or when the buyer rejects the invoice.
* A send whose answer got lost cannot go out twice: the next attempt looks for the number in the outbox first.
* Check whether the buyer is registered for eRačun. If the buyer has no address in the AMS, report the supply through eIzvještavanje (art. 40 and 51).
* Report the collection of an invoice, by hand or when WooCommerce records the payment. The law asks for it by the 20th of the following month (art. 53).
* Credit notes for refunds: type 381, process P9, the invoice they correct, without KPD on the lines.
* Bulk tools: write a category's code onto all its products, find products without a code.
* 7-day trial. No card, and it never starts by itself.

You need your own agreement with moj-eRačun: username, password and software id come from them, and so do their fees.

= What the plugin does not do =

* It does not choose KPD codes for you. The choice is yours; your accountant or the State Bureau of Statistics (kpd@dzs.hr) can help.
* It does not issue eRačun to buyers abroad or to consumers: the obligation covers domestic transactions between businesses (art. 33, 38). For consumers see CatCode Fiskalizacija HR.
* It does not receive incoming invoices: that happens at your intermediary.
* It issues in EUR only, and no advance invoices yet.
* It is not legal or tax advice. Agree on the VAT categories, legal reasons and your internal act with your accountant.

= With CatCode Fiskalizacija HR =

A transaction paid by card or cash with a fiscal receipt cannot also be an eRačun (art. 39). With both plugins active, an order with an eRačun gets no fiscal receipt, and an order that already has a receipt gets no eRačun. A setting decides what happens to an order with a buyer OIB before anything is issued. Use a different device number in each plugin: every series runs on its own.

= External services =

The free build connects to nothing.
The Pro build talks to two services, only for what you start:

* **moj-eRačun** (demo.moj-eracun.hr, www.moj-eracun.hr): your access data, invoices and collection reports, when you send or when you switch on automatic sending. Service: https://www.moj-eracun.hr
* **catcode.com.ua**: licence key and site address, to activate the licence and check for updates.

The KPD 2025 list comes from the open data of the State Bureau of Statistics (data.gov.hr, dataset kpd-2025, open licence) and is bundled with the plugin.

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Open WooCommerce → eRačun HR and fill in the seller, operator, premises, device and IBAN.
3. On the KPD codes tab set a code for each product category.
4. On a business order with an OIB, open the eRačun box and click "Issue eRačun".

== Frequently Asked Questions ==

= Which orders get an eRačun? =

Orders with a Croatian billing address and a valid buyer OIB. Other orders are left alone.

= Must shipping have a KPD? =

Every invoice line needs one. By default shipping is a charge at document level, which has no KPD; if you enter a KPD of shipping in the settings, shipping becomes its own line with that code.

= Do credit notes need a KPD? =

No. The specification (HR-BR-25) excepts credit notes and advance invoices, and the Tax Administration says the code is not shown on a credit note line.

= Was the XML checked? =

The sample documents behind the plugin's tests pass the demo validator of moj-eRačun, which runs the UBL validation and the Tax Administration validator. Your own data still needs checking: send your first invoices to the demo environment.

= Who signs the invoice? =

The plugin does not sign. moj-eRačun signs and timestamps what it receives.

== Changelog ==

= 1.0.0 =
* First release: UBL 2.1 under the Croatian specification v1.7, KPD 2025 by product and category, OIB at checkout, numbering, pre-check.
* Pro: sending through moj-eRačun, statuses, eIzvještavanje, collection reports, credit notes, bulk KPD tools, automatic updates.
