# SmartPay360 Full App — Customer 360 Integration

Build date: 2026-08-17

This is the full SmartPay360 Bochat-style application, not a module-only patch.

## Integrated Customer 360
- Native integration with ar_customers, ar_invoices, ar_receipts, ar_allocations and ar_credit_notes.
- Corrected modules/ar/customers/edit.php (the prior file contained duplicated list/bulk-edit logic).
- Responsive Customer 360 directory with receivables KPIs and mobile cards.
- Popup Add/Edit customer forms from the directory.
- Kenyan phone normalization and duplicate customer protection.
- Customer code, type, alternative phone, KRA PIN, VAT flag, county, addresses, account manager, tags and account status.
- Credit limit and credit-day controls.
- Customer profile with open receivables, overdue value, ageing, credit exposure, open invoices, receipts and activity.
- Unified customer statement engine with opening balance, invoices, receipts, credit notes and closing balance.
- CSV export and print-friendly statement.
- Customer activity plus global audit-event integration.
- Server-side customers.view / customers.manage permission enforcement.
- Non-destructive extension tables: ar_customer_profiles and ar_customer_activity.

## Database
Fresh-install schemas include the two Customer 360 tables.
For an existing database run:

    database/upgrade_customer360_2026_08_17.sql

The pages also attempt CREATE TABLE IF NOT EXISTS, but running the migration explicitly during deployment is recommended.

## Validation
- PHP files linted: 557
- PHP syntax failures: 0
- Fresh schema CREATE TABLE statements: 175
- Service worker JavaScript: passed
- Bochat UI JavaScript: passed
- manifest.json: passed
- Customer invoice/receipt action targets: present

## Deployment note
No live MySQL/MariaDB server is available inside the build workspace, so a real database import and browser transaction test could not be executed here. Import the schema/migration on a staging database before production go-live and verify login, customer create/edit, invoice, receipt, statement and role access using your actual data.
