=== E-Invoicing Connector for Scrada Lite ===
Contributors: wpmajestic
Tags: woocommerce, e-invoicing, peppol, belgium, scrada
Requires Plugins: woocommerce
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically sends B2B sales invoices to Scrada for compliance with Belgian 2026 E-Invoicing (Peppol) regulations.

== Description ==

E-Invoicing Connector for Scrada integrates your WooCommerce store with the Scrada platform, automating the transmission of sales invoices to the Peppol network. This ensures full compliance with the new Belgian B2B e-invoicing mandate starting January 1, 2026.

This plugin works seamlessly with **WooCommerce EU VAT Compliance** (Simba Hosting) and other major VAT plugins to capture valid VAT numbers and send correct invoice data.

**Key Features:**

*   **Automated Transmission:** Automatically sends invoice data to Scrada when an order status changes to 'Completed'.
*   **Peppol Compliance:** Enables your store to participate in the Peppol network for secure B2B invoicing.
*   **Smart VAT Handling:** Automatically normalizes VAT rates to Belgian standards (0%, 6%, 12%, 21%) and fixes rounding issues.
*   **High-Performance Order Storage (HPOS) Compatible**
*   **Error Logging:** Directly logs successful transmissions and API errors to the WooCommerce Order Notes for easy troubleshooting.
*   **Sandbox Support:** Includes a Test Mode to safely verify integration with Scrada's test environment.

== Installation ==

1.  Upload the plugin files to the `/wp-content/plugins/e-invoicing-connector-for-scrada` directory, or install the plugin through the WordPress plugins screen directly.
2.  Activate the plugin through the 'Plugins' screen in WordPress.
3.  Go to 'Settings → Scrada Connector' to configure your API keys.

**Prerequisites:**
*   You must have a Scrada account.
*   You must have the **WooCommerce EU VAT Compliance** plugin (Simba Hosting) installed and active.

**CRITICAL SETTING:**
You MUST enable the "Show field for base country" setting in the EU VAT Compliance plugin.
1. Go to `WooCommerce → Settings → EU VAT Compliance`.
2. Find **"Show field for base country"**.
3. ensure it is **CHECKED**.
*Reason: If unchecked, Belgian customers (your base country) may not see the VAT field, preventing B2B detection.*

== Usage ==

1.  Enter your Scrada API Key, API Secret, and Company ID in the plugin settings.
2.  Enable "Test Mode" if you are using Scrada's sandbox credentials.
3.  When a B2B customer (with a valid VAT number) places an order, fulfill it as usual.
4.  Once the order status matches 'Completed', the invoice data is sent to Scrada.
5.  Check the "Order Notes" on the right side of the Order Edit screen to confirm success ("Invoice successfully sent to Scrada").

== Frequently Asked Questions ==

= Does this plugin generate PDF invoices? =

No. This plugin transmits the *data* to Scrada, which handles the Peppol e-invoice generation and transmission. You can still use your preferred PDF invoice plugin for sending receipts to customers via email if you wish.

= What happens if an order has no VAT number? =

The plugin ignores orders without a VAT number. It is designed specifically for B2B transactions where a VAT number is present. B2C orders are handled via your standard daily receipts process.

= Is it compatible with HPOS (High-Performance Order Storage)? =

Yes, this plugin is fully compatible with WooCommerce's High-Performance Order Storage (HPOS).

= How do I know if it worked? =

Go to the Order Edit screen in WooCommerce. Look at the "Order Notes" section. You will see a success message or specific error details from the Scrada API.

= Is this plugin compatible with other VAT plugins? =

It is designed to be compatible with most major VAT plugins (including Simba Hosting, Aelia, and official WooCommerce extensions) because it uses a "Universal VAT Finder" to check multiple common database keys actions. However, we cannot guarantee 100% compatibility with every plugin on the market, as some custom solutions may store data in non-standard locations that our connector cannot see.

== Disclaimer ==

This plugin is provided "as is" without warranty of any kind, express or implied. The authors are not responsible for any direct or indirect damages, including but not limited to financial loss, tax compliance penalties, or data discrepancies arising from the use of this plugin.

It is the sole responsibility of the store owner to verify that the invoice data transmitted to Scrada meets the legal requirements of their jurisdiction. We strongly recommend testing thoroughly in "Test Mode" before going live.

== Screenshots ==

1. General plugin settings and API configuration.
2. Order Notes showing a successful transmission to Scrada.
3. Order Notes showing an API error for debugging.

== Changelog ==

= 1.0 =
*   Initial release
*   Integration with Scrada API
*   Support for Simba Hosting EU VAT Compliance data
*   HPOS Compatibility
