CHANGE_IMPOERT_CD_AMT_BALANCE_CHECK
This commit is contained in:
parent
0b04fdfa62
commit
7a968e2099
@ -1457,6 +1457,47 @@ class EmpDataServiceController extends BaseController
|
|||||||
//get the employee data for excel file validation
|
//get the employee data for excel file validation
|
||||||
$employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1);
|
$employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1);
|
||||||
|
|
||||||
|
// ----------------- CD BALANCE CHECK ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$cash_balance = $this->clientDepositModel
|
||||||
|
->where('cd_ac_pk', $client_policy_data['cd_ac_pk'])
|
||||||
|
->where('is_active', 1)
|
||||||
|
->orderBy('id', 'DESC')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($cash_balance == null) {
|
||||||
|
$balance = $this->CDMasterModel
|
||||||
|
->where('client_id', $file['client_id'])
|
||||||
|
->where('insurer_id', $client_policy_data['insurer_id'])
|
||||||
|
->where('id', $client_policy_data['cd_ac_pk'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$cash_balance['balance'] = $balance['opening_bal'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the total amount from the objects
|
||||||
|
$totals = 0;
|
||||||
|
foreach ($employee_data as $item) {
|
||||||
|
$totals = $totals + $item['total'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$totals = round($totals, 2);
|
||||||
|
|
||||||
|
//check CD amt insufficient only insurer, not tpa
|
||||||
|
if($file['insurer_or_tpa'] == 'insurer')
|
||||||
|
{
|
||||||
|
if (!empty($cash_balance)) {
|
||||||
|
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||||
|
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
|
||||||
|
$this->batchFileModel->where('id', $file_id)->set(['status' => 'failed-7', 'error_data' => 'Insufficient deposit balance. Available CD Balance: ' . $cash_balance['balance'] . ', Excel Total Amount: ' . $totals])->update();
|
||||||
|
return ['status' => 'error', 'message' => 'Insufficient deposit balance. Available CD Balance: ' . $cash_balance['balance'] . ', Required Amount: ' . $totals];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- END CD BALANCE CHECK ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
if ($employee_data == null || empty($employee_data)) {
|
if ($employee_data == null || empty($employee_data)) {
|
||||||
|
|
||||||
if ($insurer_or_tpa == 'tpa') {
|
if ($insurer_or_tpa == 'tpa') {
|
||||||
@ -2569,6 +2610,7 @@ class EmpDataServiceController extends BaseController
|
|||||||
'event_type' => $file['event_type'],
|
'event_type' => $file['event_type'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$client_policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
|
||||||
|
|
||||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||||
|
|
||||||
@ -2691,6 +2733,47 @@ class EmpDataServiceController extends BaseController
|
|||||||
|
|
||||||
// dd($endorsement_data, $excel_data);
|
// dd($endorsement_data, $excel_data);
|
||||||
|
|
||||||
|
// ----------------- CD BALANCE CHECK ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$cash_balance = $this->clientDepositModel
|
||||||
|
->where('cd_ac_pk', $client_policy_data['cd_ac_pk'])
|
||||||
|
->where('is_active', 1)
|
||||||
|
->orderBy('id', 'DESC')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($cash_balance == null) {
|
||||||
|
$balance = $this->CDMasterModel
|
||||||
|
->where('client_id', $file['client_id'])
|
||||||
|
->where('insurer_id', $client_policy_data['insurer_id'])
|
||||||
|
->where('id', $client_policy_data['cd_ac_pk'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$cash_balance['balance'] = $balance['opening_bal'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the total amount from the objects
|
||||||
|
$totals = 0;
|
||||||
|
foreach ($endorsement_data as $item) {
|
||||||
|
$totals = $totals + $item['total'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$totals = round($totals, 2);
|
||||||
|
|
||||||
|
//check CD amt insufficient only insurer, not tpa
|
||||||
|
if($file['insurer_or_tpa'] == 'insurer')
|
||||||
|
{
|
||||||
|
if (!empty($cash_balance)) {
|
||||||
|
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||||
|
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
|
||||||
|
$this->batchFileModel->where('id', $file_id)->set(['status' => 'failed-7', 'error_data' => 'Insufficient deposit balance. Available CD Balance: ' . $cash_balance['balance'] . ', Excel Total Amount: ' . $totals])->update();
|
||||||
|
return ['status' => 'error', 'message' => 'Insufficient deposit balance. Available CD Balance: ' . $cash_balance['balance'] . ', Required Amount: ' . $totals];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- END CD BALANCE CHECK ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($endorsement_data == null || empty($endorsement_data)) {
|
if ($endorsement_data == null || empty($endorsement_data)) {
|
||||||
|
|
||||||
|
|||||||
@ -388,13 +388,11 @@ class EmployeeController extends AdminController
|
|||||||
batch_files.client_branch_id,
|
batch_files.client_branch_id,
|
||||||
|
|
||||||
CASE
|
CASE
|
||||||
WHEN batch_files.status = 'partially success' OR batch_files.status = 'in-progress-partially' THEN
|
WHEN batch_files.status IN ('partially success', 'in-progress-partially', 'failed-7')
|
||||||
batch_files.error_data
|
THEN batch_files.error_data
|
||||||
ELSE
|
ELSE NULL
|
||||||
NULL
|
|
||||||
END AS error_data,
|
END AS error_data,
|
||||||
|
|
||||||
|
|
||||||
clients.short_name as client_short_name,
|
clients.short_name as client_short_name,
|
||||||
client_branch.branch_name,
|
client_branch.branch_name,
|
||||||
client_policy.policy_no,
|
client_policy.policy_no,
|
||||||
|
|||||||
@ -82,14 +82,15 @@
|
|||||||
|
|
||||||
<?php } else if ($file['status'] == 'partially success') { ?>
|
<?php } else if ($file['status'] == 'partially success') { ?>
|
||||||
|
|
||||||
<?php echo $file['status']; ?>
|
<?php echo $file['status']; ?>
|
||||||
<?php if ($file['error_data'] != 0) { ?>
|
|
||||||
|
|
||||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
<?php if ($file['error_data'] != 0) { ?>
|
||||||
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
|
||||||
|
|
||||||
|
|
||||||
<?php } ?>
|
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||||
|
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||||
|
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<?php } else if ($file['status'] == 'in-progress-partially') { ?>
|
<?php } else if ($file['status'] == 'in-progress-partially') { ?>
|
||||||
|
|
||||||
@ -98,7 +99,6 @@
|
|||||||
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
<a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||||
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||||
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php } else if ($file['status'] == 'failed-1') { ?>
|
<?php } else if ($file['status'] == 'failed-1') { ?>
|
||||||
@ -135,6 +135,11 @@
|
|||||||
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||||
data-placement="top" title="There is no data to update"></a>
|
data-placement="top" title="There is no data to update"></a>
|
||||||
|
|
||||||
|
<?php } else if ($file['status'] == 'failed-7') { ?>
|
||||||
|
|
||||||
|
failed <a class="fe-alert-circle" style="color: #000;" data-toggle="tooltip"
|
||||||
|
data-placement="top" title="<?= $file['error_data'] ?>"></a>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
|
||||||
<?php echo $file['status']; ?>
|
<?php echo $file['status']; ?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user