=== Harbor EU E-Invoicing for WooCommerce ===
Contributors: harborplugins
Tags: woocommerce, invoice, e-invoicing, peppol, ubl
Requires at least: 6.3
Tested up to: 7.0
Requires Plugins: woocommerce
Stable tag: 1.0.0
Requires PHP: 8.0
WC requires at least: 8.0
WC tested up to: 10.9
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Generate EU e-invoices from WooCommerce orders: UBL 2.1 XML in the Peppol BIS Billing 3.0 or EN 16931 profile, with VAT number and PO fields.

== Description ==

Harbor EU E-Invoicing for WooCommerce turns a WooCommerce order into a structured EN 16931 invoice: a UBL 2.1 XML document that carries the seller and buyer identifiers, the VAT breakdown per category and rate, allowances and charges, and the payment details. The XML is generated on your own server and stored with the order, ready to be downloaded or handed to whatever channel you use to deliver it.

**Read this before you install: which profile do you need?**

The plugin has two profiles, set under **WooCommerce > E-Invoicing**.

* **Peppol BIS Billing 3.0** (the default) is the profile used by the Peppol network. It requires an electronic address for *both* parties. In practice that means the buyer must supply a valid EU VAT number at checkout. An order without one cannot be issued as a Peppol invoice, and the plugin will say so instead of producing a document that a Peppol access point would reject.
* **EN 16931** is the profile to choose if you also sell to consumers, or to business buyers who have no VAT number. It is the European semantic standard without the Peppol-specific rules, and the buyer's electronic address is optional.

If you sell B2C, choose EN 16931. If you sell B2B into the Peppol network, choose Peppol and collect VAT numbers at checkout.

**What the free version does**

* Adds a VAT number field and a purchase order reference field to the checkout. Both are registered on the block checkout (WooCommerce 8.9 or later) and on the classic shortcode checkout, and both are optional.
* Adds a **Generate** button and a **Download** link to the order screen.
* Produces UBL 2.1 Invoice XML in the Peppol BIS Billing 3.0 or EN 16931 profile.
* Derives the VAT category from the tax WooCommerce actually charged: standard rate, zero rate, exempt, reverse charge for services, intra-community supply of goods, export outside the EU, and not subject to VAT for a seller without a VAT number.
* Issues invoice numbers in an unbroken sequence, resettable yearly or monthly, that never change once assigned.
* Stores every invoice in the database. Downloads are served through WordPress with a capability check and a nonce, so the file is never exposed by a URL.
* Works with High-Performance Order Storage.

**Requirements**

* WordPress 6.3 or later
* WooCommerce 8.0 or later (8.9 or later for the VAT field on the block checkout)
* PHP 8.0 or later
* A complete seller record: legal name, street, city, postcode, country, contact name, contact phone and contact email. These are mandatory under the German, Italian and Dutch national rules, and the plugin will not issue an invoice without them.

**Filters**

* `hein_is_service` - whether a line item is a service. By default a virtual or downloadable product is a service, which determines whether a cross-border EU supply is reported as an intra-community supply of goods or as a reverse charge on services. Use this filter for a service that is sold as an ordinary simple product.
* `hein_tax_category` - the resolved VAT category for a line, charge or allowance.
* `hein_invoice_data` - the complete invoice array before it is serialized.
* `hein_invoice_number` - the assigned invoice number.
* `hein_buyer_endpoint` - the buyer's electronic address, when it cannot be derived from a VAT number.
* `hein_manage_capability` - the capability required to generate and download an invoice. Defaults to `edit_shop_order`.
* `hein_item_tax_percent` - the VAT rate resolved for a line, when your tax setup is not one WooCommerce reports per line.
* `hein_unit_code` - the UN/ECE Rec 20 unit of measure for a line. Defaults to `C62` (piece).
* `hein_payment_means_code` - the UNTDID 4461 payment means code derived from the order's gateway.
* `hein_rounding_tolerance` - how far the document total may differ from the sum of its parts before generation fails. Defaults to 0.05.
* `hein_eu_countries` - the list of country codes treated as EU member states.
* `hein_generator_formats` - the list of available invoice formats.
* `hein_invoice_filename` - the filename used for a downloaded invoice.
* `hein_store_to_filesystem` - whether an invoice is also written to the uploads folder.

**Not in this plugin: features of the separate paid version**

This plugin does UBL 2.1 only, generated manually from the order screen. The following are **not** capabilities of the plugin you are reading about. They belong to a separate paid product sold at [harborplugins.com](https://harborplugins.com), and their code is not present in this plugin in any form, enabled or disabled: the XRechnung, ZUGFeRD / Factur-X and FatturaPA formats, automatic generation on order completion, bulk regeneration, Peppol network delivery through the Storecove access point, and VeriFACTU reporting (beta).

If you need any of those, this plugin is not the one to install. If you need UBL 2.1 you need nothing else: what is described under "What the free version does" is the whole plugin, not a trial of it.

**Privacy**

Invoices are generated and stored on your own server. No order or customer data is sent anywhere by this plugin. VAT numbers are checked offline against the format published for each member state; there is no call to any validation service. See the Privacy Policy section for what the licensing SDK involves.

== Installation ==

1. In your WordPress admin, go to **Plugins > Add New**, search for "Harbor EU E-Invoicing for WooCommerce", and click **Install Now**, then **Activate**. Or upload the plugin zip via **Plugins > Add New > Upload Plugin**.
2. Go to **WooCommerce > E-Invoicing** and fill in the seller section: legal name, VAT number, street, city, postcode, country code, contact name, contact phone and contact email.
3. Choose the profile. Peppol requires a buyer VAT number on every order; EN 16931 does not.
4. Add your IBAN under Payment if you accept direct bank transfer. Without it, a bank transfer order records the payment means as undefined rather than as a credit transfer.
5. Open any order and use the **Generate** button in the E-invoice box.

== Frequently Asked Questions ==

= Generating an invoice says "The Peppol profile requires a buyer electronic address". What now? =

The order has no valid buyer VAT number, and the Peppol profile requires one. Either add the customer's VAT number to the VAT number field on the order screen and generate again, or switch the profile to EN 16931 under **WooCommerce > E-Invoicing** if you invoice consumers.

= Which VAT category does an order get? =

The category follows the tax that was actually charged. A line that carries a positive VAT rate is always standard rated. A line with no VAT is reported as an intra-community supply when the buyer is in another EU member state with a valid VAT number and the item is a physical product, as a reverse charge when it is a virtual or downloadable item, as an export when the buyer is outside the EU, as not subject to VAT when you have no VAT number of your own, and otherwise as zero rated or exempt, as configured.

= My digital product is being reported as an intra-community supply of goods. =

A line counts as a service when the product is marked virtual or downloadable. If you sell a service as an ordinary simple product, use the `hein_is_service` filter to declare it.

= Where are the invoices stored? =

In a database table that belongs to the plugin. A copy in your uploads folder is optional and can be turned off. Downloads always come from the database through WordPress, and require the capability to edit the order.

= Can I change an invoice number after it is issued? =

No. Once a number is assigned to an order it does not change, and regenerating the XML reissues the same number: the document is a rendering of one invoice, not a new one.

= Does the plugin handle refunds and credit notes? =

An invoice documents the original supply and is not altered by a later refund. Credit notes are not generated at all. The order screen shows a warning when an order has been refunded.

= Does it validate VAT numbers against VIES? =

No. VAT numbers are checked offline against the published format for each member state. No request leaves your server.

== Changelog ==

= 1.0.0 =
* Initial release.

== Privacy Policy ==

All invoice data is derived from your own WooCommerce orders and stored in your own database. This plugin does not transmit order data, customer data or VAT numbers to any external service.

This plugin uses the Freemius SDK for licensing and updates. On activation you are shown a one-time opt-in screen; if you skip it, no diagnostic data is collected. If you opt in, Freemius collects non-personally-identifiable environment data (site URL, WordPress version, PHP version, plugin version) for update delivery and, where applicable, license validation. See the [Freemius privacy policy](https://freemius.com/privacy/).

== Upgrade Notice ==

= 1.0.0 =
Initial release.
