=== Invoicing Integration for sevDesk and WooCommerce ===
Contributors: devikit
Tags: woocommerce, sevdesk, invoice, germany, accounting
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.20
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Connect WooCommerce with sevDesk for native German invoices, contact sync, and USt-IdNr support.

== Description ==

**Invoicing Integration for sevDesk and WooCommerce** connects your WooCommerce store to [sevDesk](https://sevdesk.de/) via the official sevDesk REST API. Create real sevDesk invoices (Rechnung) from WooCommerce orders and keep contacts in sync.

https://youtu.be/r1svAEgPnBo

= Key Features (FREE) =

* **Individual sevDesk invoice per order** — create a native sevDesk invoice from the WooCommerce order edit screen.
* **Contact sync** — find or create sevDesk contacts (company or person) with billing address and USt-IdNr / VAT ID.
* **USt-IdNr checkout field** — German VAT ID field with detection of popular EU VAT plugins to avoid duplicate fields.
* **Tax mapping** — net / gross / vatfree, Kleinunternehmer (§19 UStG), third-country delivery; line rates 0 % / 7 % / 19 % for domestic DE.
* **Draft or finalized invoices** — choose whether documents stay as Entwurf or are finalized via sendBy.
* **PDF download** — download sevDesk invoice PDFs in admin and from customer My Account → View Order.
* **Deeplink to sevDesk** — open the invoice in the sevDesk web app.
* **Connection test** — verify your API token against GET /SevUser.
* **Detailed logging** — WooCommerce logger with token redaction.
* **HPOS compatible** — full support for WooCommerce High-Performance Order Storage.
* **WooCommerce Blocks** — USt-IdNr field works with classic and block checkout.

Head/foot text, payment account, e-invoice, EU OSS, reverse charge, automation, credit notes, email PDF delivery, mark as paid, and bulk actions appear as PRO teasers (grayed UI) in FREE and require the PRO plugin.

= PRO Features =

Upgrade to the Pro version for additional capabilities:

* **Document texts** — custom headText and footText with order variables
* **Payment account** — select sevDesk check account for bookAmount
* **E-invoice support** — XRechnung / ZUGFeRD where supported
* **EU OSS and reverse charge** — advanced cross-border tax scenarios
* **Automatic invoice creation** on selected order statuses (Action Scheduler with retries)
* **Credit notes (Gutschrift)** — manual and automatic on refunds; customer My Account PDF download
* **Send Invoice / Credit Note PDF** — email sevDesk PDFs to customers
* **Mark as paid** — bookAmount when the WooCommerce order is processing or completed
* **Bulk invoice / credit note generation** — process multiple orders with progress tracking
* **Bulk PDF download** — ZIP archive of sevDesk PDFs
* **License management and automatic updates**
* **Priority email support**

[**Get PRO Version**](https://devikit.de/produkt/sevdesk-woocommerce-pro/)

= Requirements =

* WordPress 5.8 or higher
* WooCommerce 5.0 or higher
* PHP 7.4 or higher
* Active sevDesk account with API access (Buchhaltung Pro tariff for API)

== Installation ==

1. Upload the `invoicing-integration-for-sevdesk-and-woocommerce` folder to `/wp-content/plugins/`, or install through the WordPress Plugins screen.
2. Activate the plugin through the Plugins screen.
3. Navigate to **WooCommerce → sevDesk** to configure the plugin.
4. Enter your sevDesk API token and click **Test Connection**.
5. Configure document mode (draft / finalized), tax options, and checkout USt-IdNr settings.
6. Start creating invoices from the order edit screen.

== Frequently Asked Questions ==

= Where do I find my sevDesk API token? =

Open [User Management](https://my.sevdesk.de/admin/userManagement), open a user, and copy the **API-Token** field. The token is sent in the `Authorization` header without a Bearer prefix.

= Does this plugin create invoices automatically? =

The free version supports manual invoice creation from the WooCommerce order screen. Automation, credit notes, email PDF delivery, mark as paid, and bulk actions are available in the [Pro version](https://devikit.de/produkt/sevdesk-woocommerce-pro/).

= Does the plugin support Kleinunternehmer (§19 UStG)? =

Yes. Enable Kleinunternehmer in plugin settings to map invoices to sevDesk tax rule 11 with the §19 UStG text.

= Can my customers download their invoice? =

Yes. Once a sevDesk invoice exists for the order, customers can download the PDF from **My Account → Orders → View order**.

= Is WooCommerce HPOS supported? =

Yes. The plugin declares compatibility with custom order tables (HPOS).

= Does this work with WooCommerce Blocks? =

Yes. The USt-IdNr field is compatible with classic checkout and WooCommerce Blocks checkout. The optional “I need a business invoice” checkbox mode works on classic checkout only; on Blocks the VAT ID field stays visible when not hidden.

== External services ==

This plugin relies on the sevDesk REST API, a third-party accounting and invoicing service, to create invoices and manage contacts.

= What is the sevDesk REST API? =

sevDesk is a German cloud accounting and invoicing platform. This plugin uses their official REST API to:

* Authenticate with a personal API token
* Create and update contacts (customers)
* Create invoices (draft or finalized via sendBy)
* Retrieve invoice data and download PDF documents
* Read SevUser (connection test)
* (PRO) Create credit notes, send e-invoice flags, bookAmount (mark as paid), and related document options

API base: `https://my.sevdesk.de/api/v1/`

= What data is sent and when? =

The plugin sends data to the sevDesk REST API (`https://my.sevdesk.de/api/v1/`) in these situations:

**When you click "Create Invoice" or when automatic invoice generation is triggered (PRO version):**

* Customer billing information: name, company, USt-IdNr / VAT ID, email, phone, billing address (street, city, postal code, country)
* Order information: line items (names, quantities, net/gross amounts, tax rates), shipping and fees, voucher date, optional headText/footText (PRO)

**When the plugin connects to sevDesk (settings page or as needed):**

* Your sevDesk API token (Authorization header, raw token)
* Requests to retrieve SevUser, contacts, invoices, check accounts, and PDF files

**No data is sent automatically without your action (FREE).** The free plugin communicates with sevDesk when:

* You manually create an invoice from the order screen
* You click **Test Connection** on the settings page
* You download an invoice PDF (admin or My Account)

With PRO automation enabled, invoices/credit notes may also be created when order status changes or refunds are issued, and invoices may be booked as paid when the order reaches processing/completed, according to your settings.

= Service provider information =

* **Service name:** sevDesk REST API
* **Service URL:** [https://sevdesk.de/](https://sevdesk.de/)
* **Application:** [https://my.sevdesk.de/](https://my.sevdesk.de/)
* **API documentation:** [https://api.sevdesk.de/](https://api.sevdesk.de/)
* **API help:** [https://hilfe.sevdesk.de/de/articles/9374668-sevdesk-api](https://hilfe.sevdesk.de/de/articles/9374668-sevdesk-api)
* **Plugin documentation:** [https://devikit.de/docs/sevdesk-woocommerce-pro/](https://devikit.de/docs/sevdesk-woocommerce-pro/)
* **API token management:** [https://my.sevdesk.de/admin/userManagement](https://my.sevdesk.de/admin/userManagement)
* **Privacy Policy:** [https://sevdesk.de/datenschutz/](https://sevdesk.de/datenschutz/)

By using this plugin, you acknowledge that customer and order data will be transmitted to sevDesk for invoice generation purposes. You are responsible for ensuring compliance with applicable data protection laws (including GDPR) and informing your customers about this data processing.

== Screenshots ==

1. Plugin settings
2. Plugin settings
3. Plugin settings
4. Plugin settings
5. Plugin settings
6. Plugin settings
7. Plugin settings
8. Plugin settings


== Changelog ==

= 1.0.20 =
* Fix: After coupon expiry, restore usage and generic PRO banners.

= 1.0.19 =
* Fix: Prefer bundled plugin translations over stale WP_LANG_DIR language packs.

= 1.0.18 =
* Fix: Rebuild language files so coupon upsell strings compile correctly.

= 1.0.17 =
* Add: Personalized first-year PRO coupon upsell for eligible FREE installs (30 days + 5 documents).
* Improve: Banner priority so coupon and usage notices do not stack with the generic PRO banner.

= 1.0.14 =
* Fix: Plugin URI points to Devikit PRO product page.
= 1.0.13 =
* Add: Devikit self-update checker (public manifest)

= 1.0.10 =
* Complete WordPress.org directory screenshots set (8 Plugin settings images).

= 1.0.9 =
* Add WordPress.org plugin directory screenshots (Plugin settings).

= 1.0.8 =
* Move WordPress.org listing assets (icons/screenshots) to `.wordpress-org` so they deploy to SVN `/assets` and are excluded from the plugin ZIP.

= 1.0.7 =
* Align total mismatch alert threshold to 1 cent (0.01)

= 1.0.6 =
* Prevent duplicate USt-IdNr display in the admin order billing section

= 1.0.5 =
* Avoid duplicate USt-IdNr on Blocks/Store API order addresses

= 1.0.4 =
* Show USt-IdNr on formatted billing addresses (emails, My Account, thank-you)

= 1.0.3 =
* Soften PRO banner copy (remove "German" from bookkeeping teaser)

= 1.0.2 =
* Use the sevDesk document number for invoice PDF download filenames

= 1.0.1 =
* Add demo video link to the plugin description

= 1.0.0 =
* Initial release
* Manual sevDesk invoice creation from WooCommerce order screen
* Contact sync (create/update) with USt-IdNr support
* Tax mapping for common German / EU scenarios, including Kleinunternehmer
* Draft or finalized document mode
* Invoice PDF download in admin and My Account
* PRO teasers for document texts, payment account, e-invoice, OSS, reverse charge, automation, credit notes, email PDF, mark as paid, and bulk actions
* Connection test, logging with secret redaction, HPOS support
* German (de_DE) translation

== Upgrade Notice ==

= 1.0.7 =
Uses a 1 cent (0.01) threshold for the order vs invoice total mismatch alert.

= 1.0.6 =
Removes duplicate USt-IdNr under the admin order billing address.

= 1.0.5 =
Prevents duplicate USt-IdNr on Blocks checkout order emails and My Account.

= 1.0.4 =
Shows USt-IdNr in order emails and My Account billing address.

= 1.0.3 =
Minor copy update in the PRO features banner.

= 1.0.2 =
PDF downloads now use the sevDesk document number as the filename.

= 1.0.1 =
Adds a demo video link on the WordPress.org plugin page.

= 1.0.0 =
Initial public release of the sevDesk WooCommerce integration.
