I need my current PHP-based web application (running locally on XAMPP with a MySQL backend) upgraded so that every sales and purchase document fully meets ZATCA Phase 2 e-invoicing rules in Saudi Arabia. The system must handle both B2B and B2C flows end-to-end, including credit and debit notes, without breaking the existing UI or database structure. What has to change • Forms: add all mandatory ZATCA data elements, automate the VAT and total calculations, and store the hash, digital signature, QR code string and any other Phase 2-specific fields that ZATCA requires. • Invoice logic: generate compliant XML payloads along with the on-screen / PDF format, and keep the workflow identical for B2B and B2C users. • Notes: enable automated creation of credit and debit notes for returns or corrections, again for both customer types, linked to the original invoice. • Reporting: build interactive reports for invoices and notes with on-screen filters plus one-click export to Excel and PDF. They must show status (draft, cleared, cancelled), totals, VAT amounts and reference numbers exactly as ZATCA expects. • Data integrity: keep everything stored in MySQL and ensure it works on the same local XAMPP stack. Deliverables 1. Updated PHP source files and SQL scripts. 2. A brief setup guide so I can redeploy on my local PC. 3. Test data demonstrating a successful B2B invoice, B2C invoice, credit note and debit note, each validated against ZATCA Phase 2 rules. I’ll provide the current codebase and DB schema once we agree on the approach; please indicate the libraries or third-party tools you plan to use, especially for XML generation, cryptographic signing and QR encoding.