MERGE_UAT_NONEB_POLICY_TYPE_VALIDATION
This commit is contained in:
commit
894c6b0b7b
@ -506,7 +506,7 @@ class LeadsController extends BaseController
|
||||
'errors' => ['required' => 'Claim Year is required for all entries.', 'regex_match' => 'Year must be in format YYYY-YYYY.'],
|
||||
];
|
||||
$rules['first_policy_type_.*'] = [
|
||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
|
||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9 _-]+$/]',
|
||||
'errors' => ['required' => 'Policy Type is required in Claim History.',
|
||||
'regex_match' => 'Policy Type only letters, numbers, space, hyphens and underscores are allowed',
|
||||
],
|
||||
@ -517,7 +517,7 @@ class LeadsController extends BaseController
|
||||
'regex_match' => 'Date of Loss must be inValid format.'],
|
||||
];
|
||||
$rules['first_cause_of_loss.*'] = [
|
||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
|
||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9 _-]+$/]',
|
||||
'errors' => [
|
||||
'required' => 'Cause of Loss is required.',
|
||||
'regex_match' => 'Cause of Loss only letters, numbers, space, hyphens and underscores are allowed',
|
||||
@ -6802,67 +6802,79 @@ class LeadsController extends BaseController
|
||||
|
||||
public function handleMemberDataGPATotalSumInsurerFromExcel($params)
|
||||
{
|
||||
$lead_id = $params['lead_id'];
|
||||
$lead_data = $this->leadsModel->find((int) $lead_id);
|
||||
// dd($lead_data);
|
||||
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||
// dd($file_name_with_path);
|
||||
try {
|
||||
$lead_id = $params['lead_id'];
|
||||
$lead_data = $this->leadsModel->find((int) $lead_id);
|
||||
|
||||
if (! $lead_data) {
|
||||
return ['status' => 'failed', 'message' => 'Opportunity data not found'];
|
||||
}
|
||||
|
||||
if ($lead_data['file_name']) {
|
||||
|
||||
//check physical file
|
||||
if (! file_exists($file_name_with_path)) {
|
||||
|
||||
$message = "Lead Physcial file not found";
|
||||
$this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path));
|
||||
return ['status' => 'failed', 'message' => 'no physical file'];
|
||||
if (! $lead_data) {
|
||||
return ['status' => 'failed', 'message' => 'Opportunity data not found'];
|
||||
}
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||
|
||||
//get members data
|
||||
$members_sheet = $spreadsheet->getSheet(0);
|
||||
$highestRowAndColumn = $members_sheet->getHighestRowAndColumn();
|
||||
// dd($highestRowAndColumn);
|
||||
if ($lead_data['file_name']) {
|
||||
|
||||
$uncleaned_members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||
// dd($uncleaned_members);
|
||||
//check physical file
|
||||
if (! file_exists($file_name_with_path)) {
|
||||
|
||||
$members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members);
|
||||
// dd($members);
|
||||
|
||||
// Check column headings
|
||||
$members_heading = $members[0];
|
||||
$available_col = [];
|
||||
|
||||
$lower_headers = array_map('strtolower', $members_heading);
|
||||
foreach ($lower_headers as $index => $header) {
|
||||
if (preg_match('/^(sa\s*-\s*option|proposed\s+sum\s+insured)\s+\d+$/i', $header)) {
|
||||
$column_name = $members_heading[$index];
|
||||
$sum = 0;
|
||||
|
||||
for ($i = 1; $i < count($members); $i++) {
|
||||
$cell_raw = $members[$i][$index] ?? '';
|
||||
$cell_clean = preg_replace('/[^0-9.\-]/', '', $cell_raw); // remove non-numeric chars
|
||||
|
||||
if ($cell_clean !== '' && is_numeric($cell_clean)) {
|
||||
$sum += (float) $cell_clean;
|
||||
}
|
||||
}
|
||||
|
||||
$available_col[] = $sum;
|
||||
$message = "Lead Physcial file not found";
|
||||
$this->myLogger->logme('error', ($message . ' for file ' . $file_name_with_path));
|
||||
return ['status' => 'failed', 'message' => 'no physical file'];
|
||||
}
|
||||
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path);
|
||||
|
||||
//get members data
|
||||
$members_sheet = $spreadsheet->getSheet(0);
|
||||
$highestRowAndColumn = $members_sheet->getHighestRowAndColumn();
|
||||
|
||||
// Read raw values and skip formula evaluation to avoid Calculation exceptions from malformed formulas.
|
||||
$uncleaned_members = $members_sheet->rangeToArray(
|
||||
'A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row'],
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
$members = ExcelSanitizeHelper::sanitizeArrayData($uncleaned_members);
|
||||
|
||||
// Check column headings
|
||||
$members_heading = $members[0];
|
||||
$available_col = [];
|
||||
|
||||
$lower_headers = array_map('strtolower', $members_heading);
|
||||
foreach ($lower_headers as $index => $header) {
|
||||
if (preg_match('/^(sa\s*-\s*option|proposed\s+sum\s+insured)\s+\d+$/i', $header)) {
|
||||
$sum = 0;
|
||||
|
||||
for ($i = 1; $i < count($members); $i++) {
|
||||
$cell_raw = $members[$i][$index] ?? '';
|
||||
$cell_clean = preg_replace('/[^0-9.\-]/', '', $cell_raw); // remove non-numeric chars
|
||||
|
||||
if ($cell_clean !== '' && is_numeric($cell_clean)) {
|
||||
$sum += (float) $cell_clean;
|
||||
}
|
||||
}
|
||||
|
||||
$available_col[] = $sum;
|
||||
}
|
||||
}
|
||||
|
||||
return $available_col;
|
||||
}
|
||||
|
||||
// dd($available_col);
|
||||
return $available_col;
|
||||
}
|
||||
return [];
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Exception in handleMemberDataGPATotalSumInsurerFromExcel: {message}', [
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
log_message('error', 'Trace: {trace}', [
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
|
||||
return [];
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function generateDemographyDataTable($param = [])
|
||||
|
||||
@ -845,6 +845,7 @@ class MediAssistApiController extends BaseController
|
||||
tm.id,
|
||||
tm.tpa_no as memberId,
|
||||
tm.tpa_claim_push_reference_no as claimRefNo,
|
||||
tm.doa,
|
||||
cp.policy_no as policyNo,
|
||||
cp.policy_start_date as startDate,
|
||||
cp.policy_end_date as endDate,
|
||||
|
||||
@ -465,6 +465,7 @@ class VidalApiController extends BaseController
|
||||
tm.tpa_no as memberId,
|
||||
tm.tpa_claim_push_reference_no as claimRefNo,
|
||||
tm.tpa_claim_id as claimID,
|
||||
tm.doa,
|
||||
cp.policy_no as policyNo,
|
||||
cp.policy_start_date as startDate,
|
||||
cp.policy_end_date as endDate,
|
||||
|
||||
@ -74,6 +74,43 @@ Old function copied as `uploadRequiredDoc_v1` (preserved for reference).
|
||||
|
||||
---
|
||||
|
||||
|
||||
## 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`
|
||||
|
||||
## Task Plan — Policy Transaction Inception Form JS Validation
|
||||
|
||||
### Goal
|
||||
@ -145,3 +182,4 @@ Implement client-side form validation for `app/Views/policy_transaction_inceptio
|
||||
- Preserved existing AJAX submit and payload/date conversion behavior
|
||||
- Technical validation done:
|
||||
- JS syntax check passed (`node --check public/assets/js/pages/policy_transaction_inception_validation.js`)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user