FIX_STMT_UPLOAD_INT_ISSUE
This commit is contained in:
parent
0682a4ed70
commit
1dc56c325b
@ -5702,8 +5702,8 @@ class ClientController extends AdminController
|
|||||||
// ---------- POLICY TRANSACTION CONTROLLER --------------------------------------------------------------------------------
|
// ---------- POLICY TRANSACTION CONTROLLER --------------------------------------------------------------------------------
|
||||||
|
|
||||||
$policyTransactionController = new PolicyTransactionController();
|
$policyTransactionController = new PolicyTransactionController();
|
||||||
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '60']);
|
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '62']);
|
||||||
// $res = $policyTransactionController->updateInsurerStatement(['file_id' => '22']);
|
// $res = $policyTransactionController->updateInsurerStatement(['file_id' => '62']);
|
||||||
// dd('-----', $res);
|
// dd('-----', $res);
|
||||||
|
|
||||||
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -2510,89 +2510,105 @@
|
|||||||
// check policy no,insurer and etc in DB for this month
|
// check policy no,insurer and etc in DB for this month
|
||||||
// if all good return true, otherwise return false with messssage
|
// if all good return true, otherwise return false with messssage
|
||||||
$data_to_update = [];
|
$data_to_update = [];
|
||||||
foreach ($excel_data as $excel_key => $excel_row) {
|
try{
|
||||||
$is_row_empty = check_row_is_empty_or_null($excel_row);
|
foreach ($excel_data as $excel_key => $excel_row) {
|
||||||
if (!$is_row_empty) {
|
$is_row_empty = check_row_is_empty_or_null($excel_row);
|
||||||
|
if (!$is_row_empty) {
|
||||||
|
|
||||||
$is_source_found = 0;
|
$is_source_found = 0;
|
||||||
// $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
// $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||||
// $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
// $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||||
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
|
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
|
||||||
$policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); //
|
$policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); //
|
||||||
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||||
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
||||||
|
|
||||||
foreach ($source_data as $source_key => $source_row) {
|
foreach ($source_data as $source_key => $source_row) {
|
||||||
// Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
|
// Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d'));
|
||||||
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
|
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
|
||||||
// if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) {
|
// if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) {
|
||||||
if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) {
|
if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) {
|
||||||
$is_source_found = 1;
|
$is_source_found = 1;
|
||||||
|
|
||||||
//calculate percentage first
|
//calculate percentage first
|
||||||
$total_amt = 0;
|
$total_amt = 0;
|
||||||
|
|
||||||
// $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file
|
// $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file
|
||||||
$actual_bp_per = 0; //set default value 0 for maintaining existing code flow
|
$actual_bp_per = 0; //set default value 0 for maintaining existing code flow
|
||||||
$actual_bp_brokerage = trim($excel_row[5]);
|
$actual_bp_brokerage = (int) trim($excel_row[5]);
|
||||||
$actual_bp_amt = trim($excel_row[3]);
|
$actual_bp_amt = (int) trim($excel_row[3]);
|
||||||
|
|
||||||
if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
|
if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
|
||||||
$total_amt += $actual_bp_brokerage;
|
$total_amt += $actual_bp_brokerage;
|
||||||
//percentage reverse calculation
|
//percentage reverse calculation
|
||||||
if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) {
|
if (($actual_bp_per == 0 || $actual_bp_per == 0) && !empty($actual_bp_amt)) {
|
||||||
$actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2);
|
$actual_bp_per = (int) round(($actual_bp_brokerage / $actual_bp_amt) * 100, 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
|
||||||
|
$total_amt += $actual_bp_brokerage;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100);
|
|
||||||
$total_amt += $actual_bp_brokerage;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file
|
// $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file
|
||||||
$actual_tp_per = 0;//set default value 0 for maintaining existing code flow
|
$actual_tp_per = 0;//set default value 0 for maintaining existing code flow
|
||||||
$actual_tp_brokerage = trim($excel_row[6]);
|
$actual_tp_brokerage = (int) trim($excel_row[6]);
|
||||||
$actual_tp_amt = trim($excel_row[4]);
|
$actual_tp_amt = (int) trim($excel_row[4]);
|
||||||
|
|
||||||
if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
|
if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
|
||||||
$total_amt += $actual_tp_brokerage;
|
$total_amt += $actual_tp_brokerage;
|
||||||
//percentage reverse calculation
|
//percentage reverse calculation
|
||||||
if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) {
|
if (($actual_tp_per == 0 || $actual_tp_per == "") && !empty($actual_tp_amt)) {
|
||||||
$actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100;
|
$actual_tp_per = (int) round(($actual_tp_brokerage / $actual_tp_amt) * 100, 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
|
||||||
|
$total_amt += $actual_tp_brokerage;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100);
|
|
||||||
$total_amt += $actual_tp_brokerage;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $actual_tep_per = trim($excel_row[11]);
|
// $actual_tep_per = trim($excel_row[11]);
|
||||||
// $actual_tep_brokerage = trim($excel_row[14]);
|
// $actual_tep_brokerage = trim($excel_row[14]);
|
||||||
// $actual_tep_amt = trim($excel_row[8]);
|
// $actual_tep_amt = trim($excel_row[8]);
|
||||||
|
|
||||||
$actual_tep_per = 0;
|
$actual_tep_per = 0;
|
||||||
$actual_tep_brokerage = 0;
|
$actual_tep_brokerage = 0;
|
||||||
$actual_tep_amt = 0;
|
$actual_tep_amt = 0;
|
||||||
|
|
||||||
if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
|
if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
|
||||||
$total_amt += $actual_tep_brokerage;
|
$total_amt += $actual_tep_brokerage;
|
||||||
//percentage reverse calculation
|
//percentage reverse calculation
|
||||||
if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) {
|
if (($actual_tep_per == 0 || $actual_tep_per == "") && !empty($actual_tep_amt)) {
|
||||||
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
|
$actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
|
||||||
|
$total_amt += $actual_tep_brokerage;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100);
|
//find variance
|
||||||
$total_amt += $actual_tep_brokerage;
|
$variance_amt = $source_row['exp_amt'] - $total_amt;
|
||||||
|
|
||||||
|
$data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[7]), 'statement_id' => $file_id];
|
||||||
|
|
||||||
|
unset($source_data[$source_key]);
|
||||||
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//find variance
|
|
||||||
$variance_amt = $source_row['exp_amt'] - $total_amt;
|
|
||||||
|
|
||||||
$data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[7]), 'statement_id' => $file_id];
|
|
||||||
|
|
||||||
unset($source_data[$source_key]);
|
|
||||||
continue 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}catch (\Throwable $th) {
|
||||||
|
|
||||||
|
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateInsurerStatement: Exception: " . $th->getMessage() . " --- Line: " . $th->getLine() . " --- Trace: " . $th->getTraceAsString());
|
||||||
|
$errorData = [
|
||||||
|
'message' => $th->getMessage(),
|
||||||
|
'file' => $th->getFile(),
|
||||||
|
'line' => $th->getLine(),
|
||||||
|
'code' => $th->getCode(),
|
||||||
|
'trace' => $th->getTraceAsString(),
|
||||||
|
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||||
|
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||||
|
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||||
|
];
|
||||||
|
return ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData];
|
||||||
}
|
}
|
||||||
// dd($data_to_update);
|
// dd($data_to_update);
|
||||||
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
|
$this->coShareStmtDetailsModel->insertBatch($data_to_update, 'id');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user