CHANGE_CHECK_DUPLICATE_
This commit is contained in:
parent
59d358541c
commit
628c25f16d
@ -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);
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user