FIX_GPA_TPA_ISSUE

This commit is contained in:
VENKATESHWARAN 2026-07-13 16:00:34 +05:30
parent 67684a55ec
commit 9895cb6181
2 changed files with 15 additions and 9 deletions

View File

@ -2994,20 +2994,20 @@ class ClientController extends AdminController
$base_policy = $sanitized_post_data['base_policy'] ?? null;
$insurerValue = (string) $sanitized_post_data['insurer'] ?? null;
$insurerValue = (string) ($sanitized_post_data['insurer'] ?? '');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
$sanitized_post_data['insurer_branch_id'] = $insurerBranchId;
$sanitized_post_data['insurer_id'] = $insurerId;
$tpaValue = (string) $sanitized_post_data['tpa'] ?? null;
$tpaValue = (string) ($sanitized_post_data['tpa'] ?? '');
if ($tpaValue === null || $tpaValue === '') {
if ($tpaValue === '') {
$tpaBranchId = null;
$tpaId = null;
} else {
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
list($tpaBranchId, $tpaId) = array_pad(explode('-', $tpaValue, 2), 2, null);
}
@ -3197,15 +3197,15 @@ class ClientController extends AdminController
$base_policy = $sanitized_post_data['base_policy'] ?? null;
$insurerValue = (string) $sanitized_post_data['insurer'];
$insurerValue = (string) ($sanitized_post_data['insurer'] ?? '');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
$sanitized_post_data['insurer_branch_id'] = $insurerBranchId ?? null;
$sanitized_post_data['insurer_id'] = $insurerId ?? null;
$tpaValue = (string) $sanitized_post_data['tpa'] ?? null;
if (!empty($tpaValue) || $tpaValue !== '') {
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
$tpaValue = (string) ($sanitized_post_data['tpa'] ?? '');
if ($tpaValue !== '') {
list($tpaBranchId, $tpaId) = array_pad(explode('-', $tpaValue, 2), 2, null);
} else {
$tpaBranchId = null;
$tpaId = null;

View File

@ -751,6 +751,8 @@ input:checked + .slider_blue::before {
$('.loader-mask').fadeIn();
var formData = new FormData($('#policy_form')[0]);
// TPA is optional for GPA and some other policy types; ensure the key is always posted
formData.set('tpa', $('#tpa').val() || '');
['policy_start_date', 'policy_end_date', 'open_date', 'close_date'].forEach(function(fieldName) {
var val = formData.get(fieldName);
if (val) {
@ -2056,7 +2058,11 @@ input:checked + .slider_blue::before {
if(res.status == true){
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
var baseTpaValue = '';
if (res.data.tpa_branch_id && res.data.tpa_id) {
baseTpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
}
$('#tpa').val(baseTpaValue).change();
$('#policy_no').val(res.data.policy_no).change();
// $('#open_date').val(rearrangeDateFormat(res.data.open_date)).change();
// $('#close_date').val(rearrangeDateFormat(res.data.close_date)).change();