=== PB UAE VAT Invoicing System for WooCommerce ===
Contributors: pluginsbuy
Donate link: https://pluginsbuy.com/donate/
Tags: woocommerce invoice, UAE VAT, FTA, receipt
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.7.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 8.0
WC tested up to: 9.9

UAE VAT invoices, receipts, credit notes, PDFs, QR codes and VAT reports for WooCommerce.

== Description ==

**PB UAE VAT Invoicing System for WooCommerce** is the document management solution for WooCommerce stores operating in the United Arab Emirates under the Federal Tax Authority (FTA) VAT regime.

PDF generation is fully bundled — no Composer, no server configuration, no additional installs required. Upload, activate, and you're issuing FTA-compliant PDFs immediately.

= Key Features =

**🇦🇪 Full FTA / UAE VAT Compliance**
* Validates 15-digit Tax Registration Number (TRN) — must start with 1 or 3
* Standard vs. Simplified Tax Invoice (AED 10,000 threshold)
* VAT amount always in AED as required by FTA
* Locally generated QR code image from TLV Base64 invoice data (no third-party QR API)
* PINT AE XML export for Phase 2 readiness (2027)
* Reverse charge mechanism support

**📄 Six Document Types**
Tax Invoice · Receipt · Credit Note · Proforma Invoice · Packing Slip · Delivery Note

**🖨 Zero-Setup PDF Generation**
* Dompdf library bundled — no Composer, no server changes needed
* Works immediately after plugin activation
* Professional A4 layouts with company logo, brand colours, QR code
* Arabic text support via character mapping

**⚙️ Workflow Automation**
* Auto-issue documents on configurable order status changes
* Attach PDFs to WooCommerce transactional emails
* Per-document-type email attachment control

**🔧 Admin Features**
* 5-step setup wizard on first install
* Visual template picker with live preview
* Per-document sequential numbering with custom prefix/suffix
* Documents log, VAT report, bulk PDF ZIP download
* HPOS (High Performance Order Storage) compatible

**👤 Customer Features**
* Invoice and receipt download buttons inside WooCommerce My Account > Orders
* Secure HMAC-signed download URLs

== Installation ==

1. Upload the `pb-invoicing-system` folder to `/wp-content/plugins/`
2. Activate through **Plugins > Installed Plugins**
3. WooCommerce must be installed and active
4. Follow the 5-step setup wizard that launches automatically
5. Start issuing FTA-compliant PDFs — no additional configuration needed!

== Screenshots ==
1. Setup Wizard - 1st Screen
2. Setup Wizard - 2nd Screen
3. Setup Wizard - 3rd Screen
4. Setup Wizard - 4th Screen
5. Setup Wizard - 45th Screen
6. Widget in each Order Page of WooCommerce
7. Details of generated documents in list of orders.
8. Documents generated filter and listing page.
9. Setup, select and preview few templates of the invoice.
10. VAT Reporting Page
11. One of the settings page to set documents sequencing numbers.
12. Download settings for user.

== Frequently Asked Questions ==

= Does this require Composer or any server changes? =
No. The Dompdf PDF library is bundled directly in the plugin. Install and activate — PDFs work immediately.

= Is this FTA compliant? =
The plugin implements the technical requirements of UAE FTA e-Invoicing Phase 1: TRN validation, AED VAT amounts, QR codes with TLV Base64 encoding, and PINT AE XML for Phase 2 readiness. It does not guarantee legal compliance — users are responsible for verifying their specific tax obligations with a qualified tax advisor.

= Does it support Arabic? =
Yes, common Arabic values (emirate names, etc.) are mapped to English for PDF output. The plugin is fully translation-ready (po/mo files).

= Can customers download their invoices? =
Yes. Customers can download available documents directly from their WooCommerce My Account > Orders screen.

== Privacy / External Services ==

This plugin does not track users, does not send analytics, and does not send invoice data to PluginsBuy or to any third-party QR service. PDF generation and QR image generation are handled entirely on your server.

= Bundled Libraries =

* **Dompdf** (LGPL 2.1) — HTML-to-PDF renderer. Used locally only. https://github.com/dompdf/dompdf

== Changelog ==

= 1.7.7 =
* Removed obsolete legacy PBIN-prefixed class files from the release package.
* Confirmed the active codebase uses the unique PBUAIV/pbuaiv prefixes throughout.
* Corrected and revalidated WordPress compatibility metadata.
* Performed release packaging and WordPress.org compliance cleanup.


= 1.7.6 =
* Added translator comments for translatable strings containing placeholders.
* Corrected the WordPress Tested up to value to the required major.minor format.
* Revalidated version metadata, PHP syntax, and WordPress.org compliance checks.

= 1.7.5 =
* Integrated automatic PDF delivery exclusively with WooCommerce transactional emails.
* Removed the separate completed-order email workflow and background email sender.
* Added on-demand document issuing before attachment when the current status matches automation settings.
* Normalized wizard and settings array options to prevent stale or malformed values.
* Kept manual document sending available only as an explicit admin action.

= 1.7.3 =
* Fixed an HPOS order-save recursion that exhausted PHP memory when an order was updated or completed.
* Fixed onboarding checkbox arrays so automation and email attachment choices save under the same option keys used by Settings.

= 1.7.2 =
* Unified onboarding wizard and Settings automation/email attachment rules.
* Added canonical shared defaults for document generation and customer email attachments.
* Clarified deferred completed-order PDF delivery used to prevent memory exhaustion.
= 1.7.1 =
* Fix: Defer completed-order PDF rendering to separate background actions to prevent PHP memory exhaustion.
* Fix: Generate at most one Dompdf document per request and send invoice/receipt together after generation.


= 1.7.0 =
* Fixed a memory exhaustion/critical error when completing WooCommerce orders.
* Prevented re-entry during automatic document issuance and email attachment generation.
* Reduced PDF generation memory retention during transactional emails.

= 1.6.9 =
* Audited document numbering option keys across defaults, settings UI, save handling and runtime sequence formatting.
* Added consistent numbering defaults and save support for all document types.
* Rechecked WordPress.org review items for prefixes, external QR calls, public attribution, plugin headers, raw script/style tags and PHP syntax.

= 1.6.4 =

= 1.6.3 =
* Replaced fake decorative QR pattern with locally generated scannable QR codes.
* QR codes now correctly encode FTA TLV Base64 data and are readable by QR scanners

= 1.6.2 =
* Renamed plugin display name for WordPress.org clarity
* Removed all public-facing PluginsBuy attribution from documents and emails
* Removed external QR code API usage and generated QR images locally
* Removed free-version licensing/update API endpoint constants
* Updated upload directory handling to use wp_upload_dir()
* Addressed WordPress.org enqueue/style/script review feedback for standalone templates

= 1.6.1 =
* PDF engine uses Dompdf for HTML template rendering
* Fixed VAT Reports page for HPOS (High Performance Order Storage) compatibility
* Fixed setup wizard re-running after plugin reinstall/reactivation
* Fixed all Plugin Check (WPCS) warnings: nonce verification, escaping, wp_date(), WP filesystem functions

= 1.0.0 =
* Initial release — all six document types, bundled PDF engine, FTA compliance engine, 5-step wizard, HPOS compatible

== Upgrade Notice ==

= 1.6.2 =
Recommended update: PDF layout improvements, VAT Reports HPOS fix, and full Plugin Check compliance.

= 1.0.0 =
Initial release.
