diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 2c06d68b..5b7ebdd3 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1748,18 +1748,46 @@ function checkAndDistributeTax(input) let sgst = parseFloat($('#sgst_' + input).val()); let igst = parseFloat($('#igst_' + input).val()); - if(((event.target.id).startsWith('cgst') || (event.target.id).startsWith('sgst') )) - { - if(cgst !== 0) { $('#sgst_' + input).val(cgst); } - else if(sgst !== 0) { $('#cgst_' + input).val(sgst); } + // if(((event.target.id).startsWith('cgst') || (event.target.id).startsWith('sgst') )) + // { + // if(cgst !== 0) { $('#sgst_' + input).val(cgst); } + // else if(sgst !== 0) { $('#cgst_' + input).val(sgst); } + // $('#igst_' + input).val(0); + // } + // else if((event.target.id).startsWith('igst')) + // { + // $('#cgst_' + input).val(0); + // $('#sgst_' + input).val(0); + // } + + if (((event.target.id).startsWith('cgst') || (event.target.id).startsWith('sgst'))) { + + if (!isFinite(cgst) || isNaN(cgst) || cgst === undefined) { + cgst = 0; + } + if (!isFinite(sgst) || isNaN(sgst) || sgst === undefined) { + sgst = 0; + } + + if (cgst !== 0) { + $('#sgst_' + input).val(cgst); + } else if (sgst !== 0) { + $('#cgst_' + input).val(sgst); + } + $('#igst_' + input).val(0); - } - else if((event.target.id).startsWith('igst')) - { + } + else if ((event.target.id).startsWith('igst')) { $('#cgst_' + input).val(0); $('#sgst_' + input).val(0); } + + // Ensure IGST, CGST, and SGST are never NaN, undefined, or Infinity + $('#igst_' + input).val(isFinite($('#igst_' + input).val()) ? $('#igst_' + input).val() : 0); + $('#cgst_' + input).val(isFinite($('#cgst_' + input).val()) ? $('#cgst_' + input).val() : 0); + $('#sgst_' + input).val(isFinite($('#sgst_' + input).val()) ? $('#sgst_' + input).val() : 0); + } function amountCalculation(input) { @@ -2293,11 +2321,21 @@ $(document).on('change', '[name="base_premium[]"], [name="co_share_per[]"]', fun let basePremium = $('input[name="base_premium[]"]').toArray() .map(input => parseFloat($(input).val()) || 0) .find(value => value > 0) || 0; + + let tpPremium = $('input[name="tp_premium[]"]').toArray() + .map(input => parseFloat($(input).val()) || 0) + .find(value => value > 0) || 0; + + let terPremium = $('input[name="tp_premium[]"]').toArray() + .map(input => parseFloat($(input).val()) || 0) + .find(value => value > 0) || 0; console.log('Base Premium:', basePremium); + console.log('TP Premium:', tpPremium); // Loop through all co_share_per[] fields $('input[name="co_share_per[]"]').each(function(index) { + const coSharePer = parseFloat($(this).val()) || 0; // Get co_share_per value const coPremium = (basePremium * coSharePer) / 100; // Calculate co_premium @@ -3536,6 +3574,9 @@ var insurerCount = 0; $('#setInsurerCount').on('click', function() { addInsurerColumn(); // Ensure this function is defined properly + setTimeout(() => { + getColumnIndexes(); + }, 2000); }); @@ -3840,6 +3881,9 @@ function addInsurerColumn() { const index = $(this).closest('th').index(); let count_index = $(this).data('count'); removeInsurerColumn(index, count_index); + setTimeout(() => { + getColumnIndexes(); + }, 2000); }); // hidePermiumDetailsBasedOnTheTeam() diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 099cf7ad..0c7a4a75 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -32,32 +32,32 @@