Endoresment create changes : GWM
This commit is contained in:
parent
512d78263e
commit
c2fadd0e69
@ -109,7 +109,7 @@ class EndorsementController extends ResourceController
|
||||
->where('partner_policy.policy_number', $reqData['policy_number'])
|
||||
->first();
|
||||
|
||||
if (empty($policy)) {
|
||||
if (empty($policy) && $reqData['policy_from'] == 'Internal') {
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => 'Policy not found'], 200);
|
||||
}
|
||||
|
||||
@ -128,7 +128,8 @@ class EndorsementController extends ResourceController
|
||||
|
||||
// Prepare endorsement data
|
||||
$endorsementData = [
|
||||
'policy_number' => $policy['policy_number'],
|
||||
'policy_from' => $reqData['policy_from'],
|
||||
'policy_number' => $policy['policy_number'] ?? $reqData['policy_number'],
|
||||
'client_policy_id' => $policy['client_policy_id'] ?? null,
|
||||
'insurer_id' => $policy['insurer_id'] ?? null,
|
||||
'insurer_branch_id' => $policy['insurer_branch_id'] ?? null,
|
||||
@ -144,27 +145,15 @@ class EndorsementController extends ResourceController
|
||||
'is_active' => 1
|
||||
];
|
||||
|
||||
// ✅ Insert endorsement
|
||||
|
||||
if (!$this->EndorsementModel->insert($endorsementData)) {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 422,
|
||||
'data' => $this->EndorsementModel->errors()
|
||||
], 422);
|
||||
return $this->respond([ 'status' => 'failed', 'code' => 422, 'data' => $this->EndorsementModel->errors()], 422);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'data' => ['endorsement_id' => $this->EndorsementModel->getInsertID()]
|
||||
], 200);
|
||||
return $this->respond([ 'status' => 'success', 'code' => 200, 'data' => ['endorsement_id' => $this->EndorsementModel->getInsertID()] ], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'data' => $e->getMessage()
|
||||
], 500);
|
||||
return $this->respond([ 'status' => 'failed', 'code' => 500, 'data' => $e->getMessage() ], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ class EndorsementTypeModel extends Model
|
||||
protected $returnType = 'array';
|
||||
|
||||
protected $allowedFields = [
|
||||
'policy_from',
|
||||
'endorsement_type',
|
||||
'is_active',
|
||||
'created_by',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user