CHANGE_CHECK_DUPLICATE_

This commit is contained in:
VENKATESHWARAN 2026-01-05 17:37:14 +05:30
parent 59d358541c
commit 628c25f16d
2 changed files with 45 additions and 0 deletions

View File

@ -3571,6 +3571,20 @@ class EmployeeRestController extends AdminController
$get_docs_name = $this->request->getPost('claim_doc_names') ?? [];
$policy_transaction_id = $this->request->getPost('policy_transaction_id') ?? null;
$client_policy_data = $this->clientPolicyModel->where('id', $received_data['client_policy_id'] ?? null)->first();
$isduplicate = checkDuplicateClaim([
'doa' => change_date_format($received_data['doa'] ?? '') ?? null,
'emp_code' => $received_data['emp_code'] ?? null,
'claim_amount' => $received_data['claim_amount'] ?? null,
'policy_no' => $client_policy_data['policy_no'] ?? null
]);
if($isduplicate){
$response = ['status' => false, 'message' => 'Claim already exist'];
return $this->respond($response, 200);
}
if(!empty($policy_transaction_id)){
$response = $this->retailClaimInitiate($received_data);
return $this->respond($response, 200);

View File

@ -6,6 +6,7 @@ use App\Models\BatchFileModelFileModel;
use App\Controllers\GoogleDriveController;
use App\Models\BatchFileModel;
use App\Controllers\ApiServiceController;
use App\Models\TicketMasterModel;
// File: app/Helpers/Uuid_helper.php
@ -978,3 +979,33 @@ if (!function_exists('generate_ecard_download_link_based_on_tpa')) {
}
}
if (!function_exists('checkDuplicateClaim')) {
function checkDuplicateClaim(array $params): bool
{
$ticketMaster = new TicketMasterModel();
$query = $ticketMaster->where('is_active', 1);
if(!empty($params['doa']) && !empty($params['claim_amount'])){
return false;
}
$hasValidCondition = false;
foreach ($params as $key => $value) {
if ($value !== null && $value !== '') {
$query->where($key, $value);
$hasValidCondition = true;
}
}
if (!$hasValidCondition) {
return false;
}
$result = $query->countAllResults();
if($result > 0){ return true; }else{ return false; }
}
}