# Phase 58 — Professional Lending, Protection & Resilience Workspaces

## Purpose
Phase 58 completes the requested professional workspace upgrades on top of the Phase 57 security build. It also adds a controlled Loan Product Management workspace and fixes the branch-column error affecting Deposit Interest & Maturities.

## 1. Loan Product Management
New route: `/loan-products`

Navigation: Core Operations → Lending → Loan Products.

Authorized lending staff can now:
- create a loan product;
- maintain reference annual rate, interest method, standard term and grace period;
- maintain processing, insurance and penalty defaults;
- activate/deactivate products;
- review total facilities, live facilities, approved pricing-policy coverage and approved insurance-program coverage;
- edit existing product masters without losing historical loans.

Controls:
- duplicate product names are rejected;
- invalid percentage/term ranges are rejected;
- combined processing + insurance defaults must remain below 100%;
- a product with a currently approved pricing policy cannot be deactivated until that pricing policy is retired/ended;
- changes are audit logged.

The product master does **not** bypass Phase 52 pricing governance. For new staff-originated loans, the approved effective-dated pricing policy and accepted customer disclosure remain the controlled pricing source.

## 2. Deposit Interest & Maturities Hotfix
Fixed the invalid query against `branches.is_active`.

The current branch schema uses `branches.status`, so active branch selection now uses:

`WHERE status='active'`

The same stale branch filter was also corrected in:
- Accounts Payable;
- Accounts Receivable.

A project-wide scan found no remaining PHP branch queries using `branches.is_active`.

## 3. Loan Pricing & Customer Disclosure
The `/loan-pricing` workspace now has:
- a stronger professional command-centre hero;
- direct access to Loan Products, Loan Portfolio and Prepare Disclosure;
- richer workspace navigation cards;
- a four-stage pricing governance assurance strip;
- refined metric and overview presentation.

Existing Phase 52 policy, disclosure, fee, waiver and review workflows are preserved.

## 4. Insurance & Credit-Life Management
The `/insurance` workspace now has:
- a professional credit-protection command centre;
- direct access to Loan Products, Policy Register and Programme Management;
- richer navigation cards;
- a four-stage insurance lifecycle assurance strip;
- refined portfolio and reconciliation presentation.

Existing Phase 54 programme, policy, premium, claim and reconciliation controls are preserved.

## 5. Go-Live Readiness
The `/go-live-readiness` workspace was redesigned into a production assurance control centre with:
- readiness score presentation;
- production-gate status;
- blocker, warning, sign-off and audit-evidence metrics;
- permission-aware shortcuts;
- clearer automated control checks;
- professional functional sign-off cards;
- improved readiness history evidence.

Existing Phase 57 audit and sign-off logic remains unchanged.

## 6. Security, Guarantors & Collateral
The `/security-assets` workspace now provides a professional credit-security control centre with:
- security metrics;
- a four-step control process;
- professional guarantor and collateral registration cards;
- a dedicated maker-checker collateral review queue;
- guarantor exposure register;
- collateral valuation/coverage/insurance register;
- evidence upload controls;
- insurance-expiry exception panel.

## 7. Backup, Disaster Recovery & Continuity
The `/backup-recovery` workspace navigation is now presented as five professional cards:
- Resilience Centre — coverage, restore readiness and exceptions;
- Backup Policies — frequency, scope, retention and off-site rules;
- Backup Runs — jobs, checksums and independent verification;
- Recovery Tests — restore evidence, RTO and RPO assurance;
- Continuity Incidents — response, containment and service recovery.

All existing backup/recovery workflows remain intact.

## 8. My Security
`/account/security` now includes:
- improved hero actions;
- a four-layer protection strip covering password lifecycle, 2FA, session defence and audit evidence;
- existing professional password and authenticator controls;
- a corrected Security Audit destination (`/admin?tab=activity`) shown only when the signed-in role has audit permission.

The Phase 57 TOTP implementation and security controls are preserved.

## Database Upgrade
No new database migration is required for Phase 58. The Loan Products workspace uses the existing `loan_products` table and the existing Phase 52/54 governance tables.

## Deployment
1. Back up the current application and database.
2. Replace the application files with the Phase 58 package.
3. No SQL migration is required if the database is already on Phase 57.
4. Open `/savings/interest` and confirm Deposit Interest & Maturities loads normally.
5. Open `/loan-products` and review the existing loan-product catalogue.
6. Review `/loan-pricing`, `/insurance`, `/security-assets`, `/backup-recovery`, `/go-live-readiness` and `/account/security`.
