FIX_POLICY_TRANSACTION_REMOVE : RV
This commit is contained in:
parent
c12fa35557
commit
25754f089f
@ -1436,21 +1436,54 @@ class ClientController extends AdminController
|
||||
->where('employees.emp_status', 'active')
|
||||
->where('employees.is_active', 1)
|
||||
->countAllResults();
|
||||
|
||||
if ($emp_details == 0) {
|
||||
|
||||
$update = $this->clientPolicyModel->where('id', $id)->set($data)->update();
|
||||
|
||||
if ($update) {
|
||||
|
||||
$policy_transaction_update = $this->deactivatePolicyTransactionsPolicy($id);
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy'], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'The policy has active employees'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function deactivatePolicyTransactionsPolicy($clientPolicyId)
|
||||
{
|
||||
// Deactivate policy_transaction records
|
||||
$this->policyTransactionModel
|
||||
->where('client_policy_id', $clientPolicyId)
|
||||
->set(['is_active' => 0])
|
||||
->update();
|
||||
|
||||
// Get related policy_transaction IDs
|
||||
$transactionIds = $this->policyTransactionModel
|
||||
->select('id')
|
||||
->where('client_policy_id', $clientPolicyId)
|
||||
->findAll();
|
||||
|
||||
$ids = array_column($transactionIds, 'id');
|
||||
|
||||
// Deactivate related pt_co_share records
|
||||
if (!empty($ids)) {
|
||||
$this->PTCOShareDetailsModel
|
||||
->whereIn('pt_id', $ids)
|
||||
->set(['is_active' => 0])
|
||||
->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function createClientPolicyPremium()
|
||||
{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user