From 2e873ccdef12bd1d0cfa16843fff6d798d3f66aa Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 8 Apr 2026 10:01:23 +0530 Subject: [PATCH] TEST_NONEB_API_DOCS_UPDATED --- dev_logs/2026-04-01.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dev_logs/2026-04-01.md b/dev_logs/2026-04-01.md index 1d7e53a6..35ab7f11 100644 --- a/dev_logs/2026-04-01.md +++ b/dev_logs/2026-04-01.md @@ -71,3 +71,41 @@ Old function copied as `uploadRequiredDoc_v1` (preserved for reference). ### API Docs - `nonebapidocs.md` - `dev_logs/non_eb_claim_api.md` + +--- + +## LeadsController — Bug Fix: `createClientWithLeadData` for Non-EB Leads + +### 6. Fix: `prepareClientPolicyData` crashes on Non-EB leads + +**Problem:** `proposel_data` is always `null` for Non-EB leads. The function unconditionally did: +```php +$proposel_data = json_decode($data['proposel_data'], true); +list($insurer_branch_id, $insurer_id) = explode('-', $proposel_data['insurer'], 2); +``` +This throws a PHP 8 TypeError (cannot access key on null) for any Non-EB lead, making `createClientWithLeadData` silently fail. + +**Fix:** Split insurer resolution by `lead_form_type`: +- **EB (`lead_form_type == 1`):** parse insurer from `proposel_data['insurer']` as `"{insurer_branch_id}-{insurer_id}"` — unchanged +- **Non-EB:** read `insurer_id` and `insurer_branch_id` directly from lead row columns + +### 7. Fix: `getPlacementJson` null-safety for Non-EB leads + +**Problem:** Same null `proposel_data` issue — `json_decode($data['proposel_data'], true)` returned null, and downstream `$proposel_data['proposel_name']` access would crash if a Non-EB lead had QCR data. + +**Fix:** `json_decode($data['proposel_data'] ?? '', true) ?? []` — `proposel_data` is now always an array, so all `??` key accesses are safe. + +### Smoke Test Results + +| Path | Step | Result | +|---|---|---| +| EB | `proposel_data` decode | ✅ decodes normally | +| EB | `explode('-', proposel_data['insurer'])` | ✅ `insurer_branch_id` + `insurer_id` parsed correctly | +| EB | `preparePolicyTermsFromRFQ` | ✅ unaffected | +| Non-EB | `proposel_data` null → `[]` | ✅ safe | +| Non-EB | insurer from lead row columns | ✅ `insurer_id` + `insurer_branch_id` read directly | +| Non-EB | `getPlacementJson` — no QCR data | ✅ returns null safely, policy terms skipped | +| Non-EB | `getPlacementJson` — QCR data exists | ⚠️ line 4356: `$proposel_data['proposel_name']` missing `??` — pending clarification on whether Non-EB leads can have QCR data | + +### Files Changed +- `app/Controllers/LeadsController.php`