diff --git a/app/Controllers/AgentController.php b/app/Controllers/AgentController.php index 3f667ec..afef807 100644 --- a/app/Controllers/AgentController.php +++ b/app/Controllers/AgentController.php @@ -613,8 +613,13 @@ class AgentController extends ResourceController try{ $data = $this->request->getPost(); - //duplicate check - $duplicateData = $this->AgentIncentiveFileModel->where('agent_id',$data['agent_id'])->where('incentive_month',$data['incentive_month'])->where('file_type','incentive')->first(); + //duplicate check (ignore soft-deleted rows) + $duplicateData = $this->AgentIncentiveFileModel + ->where('agent_id', $data['agent_id']) + ->where('incentive_month', $data['incentive_month']) + ->where('file_type', 'incentive') + ->where('is_active', 1) + ->first(); if(!empty($duplicateData)){ return $this->respond(['status' => 'failed', 'code' => 200, 'data' => 'Duplicate Entry.'], 200); }