Quick Installation
- Purchase the module and download
haikhavan_accounting_gdpr_suite-ioncube-8.2-1.0.0-install.zipfrom your VPSrv Client Area Downloads. - Upload and extract the ZIP into your WHMCS root directory so files land in
modules/addons/haikhavan_accounting_gdpr_suite/. - Verify PHP 8.2–8.4 with ionCube PHP Loader 14+ / 15.5+ is enabled on your server.
- Go to System Settings → Addon Modules in WHMCS Admin, click Activate next to Haikhavan Accounting & GDPR Compliance Suite, and assign administrator role access.
Module Slug: haikhavan_accounting_gdpr_suite
Version: 1.0.0
Namespace: Haikhavan\AccountingGdpr\
Target Runtime: WHMCS 9.1.2 · PHP 8.3 · MySQL 8.4
1. Architecture & File Inventory
modules/addons/haikhavan_accounting_gdpr_suite/
├── whmcs.json # WHMCS schema 1.0 manifest
├── haikhavan_accounting_gdpr_suite.php # Addon entry point (_config, _activate, _deactivate, _upgrade, _output, _clientarea)
├── hooks.php # 8 WHMCS hooks (InvoicePaid, InvoiceRefunded, ClientAdd, ClientEdit, Navbar, Cookie Banner, AdminHomeWidgets, DailyCronJob)
├── lib/
│ ├── Database.php # 8-table Capsule schema installer, AES-256-CBC+HMAC crypto, CSV formula sanitizer, audit logger
│ ├── AccountingEngine.php # QBO/Xero/QBD sync, GL Code resolver, Reconciliation Diff checker, HMAC webhooks, CSV Journal & .IIF builders
│ ├── GdprService.php # Granular Consent Ledger, DSAR JSON/ZIP builder, Right-to-be-Forgotten safe anonymizer, Retention Sweep & Demo Seeder
│ ├── AdminController.php # CSRF-guarded Admin SPA, CRUD ops, Reconciliation resolver & CSV/IIF download endpoints
│ └── ClientController.php # CSRF-guarded Client Privacy Center, DSAR JSON/ZIP export endpoints & cookie consent API
├── templates/
│ ├── admin/dashboard.php # 5-tab Admin Accounting, Reconciliation, Webhooks, GDPR & Data Retention UI
│ └── client/privacy_center.tpl # Smarty Client Privacy & GDPR Center template
└── assets/
├── css/haikhavan_accounting_gdpr.css # Scoped zero-CDN stylesheet (.hkag-*)
└── js/haikhavan_accounting_gdpr.js # Zero-CDN High-DPI Canvas Synced Revenue Bar Chart & Compliance Radial Gauge
2. Database Schema (mod_hk_ag_*)
| Table | Purpose | Key Columns & Indexes |
|---|---|---|
mod_hk_ag_connectors |
QBO, Xero, QBD & Journal connectors | id PK, provider INDEX, name, company_realm_id, endpoint_url, credentials_encrypted (v1: AES-256-CBC+HMAC), auto_sync_invoices, auto_sync_refunds, auto_sync_clients, enabled INDEX, status, last_sync_at |
mod_hk_ag_gl_mappings |
Chart-of-Accounts GL Code mappings | id PK, entity_type INDEX (product|gateway|tax|refund|default), entity_key INDEX, entity_label, gl_code, gl_account_name, account_type, tax_code, enabled |
mod_hk_ag_sync_ledger |
Accounting sync & webhook ledger | id BIGINT PK, connector_id INDEX, provider INDEX, entity_type INDEX, whmcs_id INDEX, external_id INDEX, whmcs_amount, synced_amount, currency_code, status INDEX (synced|pending|failed|mismatch), attempts, payload_json, error_message, synced_at INDEX |
mod_hk_ag_profile_sync_rules |
Account Synchronization webhook hub | id PK, name, target_url, events_csv, secret_encrypted, max_retries, enabled, success_count, fail_count, last_dispatched_at |
mod_hk_ag_consents |
Immutable versioned GDPR consent log | id BIGINT PK, client_id INDEX, consent_key INDEX, policy_version, granted, source, ip_address, user_agent, recorded_at INDEX |
mod_hk_ag_gdpr_requests |
DSAR & Right-to-be-Forgotten queue | id PK, client_id INDEX, request_type INDEX (dsar_export|erasure), status INDEX, reason, preserve_financials, summary_json, processed_by_admin, processed_at |
mod_hk_ag_retention_rules |
Automated Data Retention policies | id PK, name, data_category INDEX, retention_days, action (anonymize|purge|archive), statutory_hold, enabled, last_run_at, records_affected |
mod_hk_ag_audit_log |
Immutable compliance & accounting log | id BIGINT PK, admin_id, client_id, action INDEX, status, summary, details_json, ip_address, created_at |
3. Accounting Export Formats & Reconciliation
3.1 Double-Entry GL Journal CSV (AccountingEngine::buildDoubleEntryJournalCsv)
Produces balanced two-line double-entry journal rows per transaction (Debit payment clearing GL account, Credit revenue GL account; reversed on refunds into GL 4900). All free-text columns pass through Database::csvSafe() neutralizing leading =, +, -, @, \t, \r characters against spreadsheet formula injection.
3.2 QuickBooks Desktop .IIF (AccountingEngine::buildQuickBooksDesktopIif)
Outputs CRLF-terminated tab-delimited Intuit Interchange Format blocks (!TRNS, !SPL, !ENDTRNS) with TRNSTYPE (INVOICE / CREDIT MEMO), MM/DD/YYYY dates, mapped GL account names, and balanced positive/negative AMOUNT splits.
3.3 Reconciliation Discrepancy Radar (AccountingEngine::runReconciliationCheck)
Detects: (1) amount_mismatch where $|\text{whmcs_amount} - \text{synced_amount}| \ge 0.01$ or status='mismatch', (2) sync_failed entries awaiting retry, and (3) unsynced_invoice rows present in tblinvoices without a ledger entry.
4. GDPR Privacy & Security Architecture
- Encryption at Rest: Connector OAuth credentials and webhook HMAC signing secrets are encrypted using
AES-256-CBC+HMAC-SHA256Encrypt-then-MAC (v1:) keyed via WHMCS$cc_encryption_hash. - Signed Account Sync Webhooks: Outgoing payloads carry
X-WHMCS-Sync-EventandX-WHMCS-Sync-Signature: sha256=<hmac>. - DSAR Data Portability (
GdprService::buildDsarPackage/buildDsarZipBytes): Strips sensitive auth/card columns (password,securityqans,cardnum,bankacct), bundles client profile, services, domains, invoices, tickets, and consent history into JSON or a multi-fileZipArchive, and records a completed DSAR audit entry. - Safe Right-to-be-Forgotten Anonymizer (
GdprService::processErasureRequest): Supportsdry_run=1preview and full execution, replacing 10 PII columns ontblclientswith redacted tokens (Anonymized Client #<id>,erased-<id>@anonymized.invalid) while leavingtblinvoicesuntouched to comply with 7-year statutory tax retention laws. - CSRF & Ownership: All Admin (
hkag_admin_csrf) and Client (hkag_client_csrf) write endpoints enforcehash_equals()verification (HTTP403on failure). Client DSAR downloads and consent updates strictly scope to$_SESSION['uid'].
5. WHMCS Hooks & AJAX Operations
- Hooks (
hooks.php):InvoicePaid,InvoiceRefunded,ClientAdd,ClientEdit,ClientAreaPrimaryNavbar,ClientAreaFooterOutput(cookie consent banner),AdminHomeWidgets,DailyCronJob. - Admin AJAX Ops:
seed_demo,save_connector,delete_connector,save_gl_mapping,delete_gl_mapping,sync_invoice_now,resolve_mismatch,save_profile_rule,delete_profile_rule,test_profile_webhook,process_erasure,save_retention_rule,delete_retention_rule,run_retention_sweep. - Client AJAX Ops:
save_consents,cookie_consent,request_erasure.