FIX_EXCEL_RFQ_FORMAT

This commit is contained in:
Srinivas-Saravanan 2025-06-05 14:39:43 +05:30
parent 853647df78
commit 3889a4058d
2 changed files with 39 additions and 12 deletions

View File

@ -1212,6 +1212,7 @@ class LeadsController extends BaseController
//Construct excel file and save the file to the folder and return file path //Construct excel file and save the file to the folder and return file path
public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null) public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null)
{ {
helper('excel_util_helper');
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
$is_placement = false; $is_placement = false;
@ -1229,7 +1230,7 @@ class LeadsController extends BaseController
'No of Dependents' => $rfq_data['incept_dept_count'], 'No of Dependents' => $rfq_data['incept_dept_count'],
'Total Lives' => $rfq_data['incept_no_of_lives'], 'Total Lives' => $rfq_data['incept_no_of_lives'],
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided", 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
// 'Policy Run Days' => $rfq_data['policy_run_days'], // 'Policy Run Days' => $rfq_data['policy_run_days'],
]; ];
} else if (in_array( $rfq_data['policy_type_id'], [1, 6, 7])) { } else if (in_array( $rfq_data['policy_type_id'], [1, 6, 7])) {
@ -1237,7 +1238,7 @@ class LeadsController extends BaseController
'Insured' => $rfq_data['client_name'], 'Insured' => $rfq_data['client_name'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'], 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided", 'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
]; ];
} }
@ -1261,22 +1262,22 @@ class LeadsController extends BaseController
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'], 'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'], 'Total Lives at Renewal ' => $rfq_data['renewal_no_of_lives'],
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided", 'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Run Days' => $rfq_data['policy_run_days'], 'Policy Run Days' => $rfq_data['policy_run_days'],
'Inception Premium' => $rfq_data['premium_at_inception'], 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
'Premium as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['premium_date'], 'Premium as on ('.date('d-m-Y', strtotime($rfq_data['premium_date'])).')' => formatIndianCurrency($rfq_data['premium_amount']),
'Earned Premium' => $rfq_data['earned_premium'], 'Earned Premium' => $rfq_data['earned_premium'],
'Incurred Claims as on (Date - DD MM YYYY should be entered based on the claims dump report)' => $rfq_data['incurred_claims_date'], 'Incurred Claims as on ('.date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])).')' => formatIndianCurrency($rfq_data['incurred_claims']),
'Annualised Claims' => $rfq_data['annualised_claims'], 'Annualised Claims' => formatIndianCurrency($rfq_data['annualised_claims']),
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'], 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio']." %",
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'], 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio']." %",
]; ];
} else if (in_array( $rfq_data['policy_type_id'], [1, 6, 7])) { } else if (in_array( $rfq_data['policy_type_id'], [1, 6, 7])) {
$lead_data = [ $lead_data = [
'Insured' => $rfq_data['client_name'], 'Insured' => $rfq_data['client_name'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d/m/Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d/m/Y', strtotime($rfq_data['policy_end_date'])) : "To be decided", 'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "", 'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
'Existing Insurer' => $rfq_data['insurer_name'], 'Existing Insurer' => $rfq_data['insurer_name'],
'TPA ' => $rfq_data['tpa_name'], 'TPA ' => $rfq_data['tpa_name'],

View File

@ -2009,3 +2009,29 @@ if (!function_exists('generate_family_floater_key')) {
return $relation; return $relation;
} }
} }
if (!function_exists('formatIndianCurrency')) {
function formatIndianCurrency($amount)
{
$amount = (string) $amount;
$decimal = '';
// Split decimal part if exists
if (strpos($amount, '.') !== false) {
list($amount, $decimal) = explode('.', $amount);
$decimal = '.' . substr($decimal, 0, 2); // Limit to 2 decimal places
}
$lastThree = substr($amount, -3);
$rest = substr($amount, 0, -3);
if ($rest != '') {
$rest = preg_replace("/\B(?=(\d{2})+(?!\d))/", ",", $rest);
$formatted = $rest . ',' . $lastThree;
} else {
$formatted = $lastThree;
}
return $formatted . $decimal;
}
}