From 4bfd58a0e5bc15be331692e673aac23d586c08c5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 20 Dec 2025 16:59:24 +0530 Subject: [PATCH] FIX_STATEMENT_UPLOAD --- app/Controllers/ClientController.php | 2 +- .../PolicyTransactionController.php | 44 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d90b46cd..039f6f99 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5998,7 +5998,7 @@ class ClientController extends AdminController // ---------- POLICY TRANSACTION CONTROLLER -------------------------------------------------------------------------------- $policyTransactionController = new PolicyTransactionController(); - // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '271']); + // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '281']); // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '62']); // dd('-----', $res); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index fdfb3d42..385a4bff 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -3798,6 +3798,7 @@ // get uploaded month transactions data $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']); + // dd($source_data); // check policy no,insurer and etc in DB for this month // if all good return true, otherwise return false with messssage @@ -3808,6 +3809,9 @@ $row_number = $excel_key; $is_row_empty = check_row_is_empty_or_null($excel_row); + $policy_source_found = 0; + $endorsement_source_found = 0; + $dublicate_found = 0; if (!$is_row_empty) { @@ -3821,33 +3825,47 @@ $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; - - // Policy number mismatch - if ($policy_no != $source_row['policy_no']) { - $error_messages[$row_number]['policy_no_mismatch'] = - "Policy number ({$policy_no}) not in NHance."; - } - - // Endorsement number mismatch - if (!empty($endorsement_no) && $endorsement_no != $source_endorsement_no) { - $error_messages[$row_number]['endorsement_no_mismatch'] = - "Endorsement number ({$endorsement_no}) not not in NHance."; + if (($policy_no == $source_row['policy_no']) ){ + $policy_source_found = 1; + } + + if( $endorsement_no == $source_endorsement_no) { + $endorsement_source_found = 1; } // Duplicate check if (isset($matched_entry[$policy_no . '|' . $endorsement_no])) { - $error_messages[$row_number]['duplicate'] = - "Duplicate entry found. This policy and endorsement ({$policy_no} '|' {$endorsement_no}) combination has already been matched."; + $dublicate_found = 1; continue 2; } if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { $line_items = $line_items + 1; $matched_entry[] = $policy_no . '|' . $endorsement_no; + unset($source_data[$source_key]); continue 2; } } + + // Policy number mismatch + if ($policy_source_found == 0) { + $error_messages[$row_number]['policy_no_mismatch'] = + "Policy number ({$policy_no}) not in NHance."; + } + + // Endorsement number mismatch + if (!empty($endorsement_no) && $endorsement_source_found == 0) { + $error_messages[$row_number]['endorsement_no_mismatch'] = + "Endorsement number ({$endorsement_no}) not in NHance."; + } + + // Duplicate check + if ($dublicate_found == 1) { + $error_messages[$row_number]['duplicate'] = + "Duplicate entry found. This policy and endorsement ({$policy_no} '|' {$endorsement_no}) combination has already been matched."; + } } + } // print_rr($error_messages);die;