CHANGE_BDS_CALC_CHANGE : RV
This commit is contained in:
parent
d4277e6478
commit
44ab16e663
@ -1279,6 +1279,9 @@ $(document).ready(function(){
|
||||
|
||||
$(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', function() {
|
||||
|
||||
$('[name="base_premium[]"]').val("");
|
||||
$('[name="co_premium[]"]').val("");
|
||||
|
||||
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
|
||||
|
||||
if (isAnyChecked) {
|
||||
@ -1342,7 +1345,6 @@ function checkLeaderSelected(){
|
||||
$(document).on('click', '[name="co_share_type[]"]', function() {
|
||||
|
||||
let val = $(this).val();
|
||||
console.log(val);
|
||||
let uniqueid = $(this).data('id');
|
||||
let insurer = $('#follow_insurer_id_'+uniqueid).val()
|
||||
|
||||
@ -1353,7 +1355,6 @@ $(document).on('click', '[name="co_share_type[]"]', function() {
|
||||
// console.log('client_id', client_id);
|
||||
// console.log('insurer_id', insurer_id);
|
||||
|
||||
|
||||
if(insurer == ""){
|
||||
toastr.warning('Please select the insurer.', 'WARNING!');
|
||||
$(this).prop('checked', false);
|
||||
@ -1834,7 +1835,10 @@ function amountCalculation(input) {
|
||||
console.log('sgst', sgst);
|
||||
|
||||
// Calculate the total premium (Base + TP + Co-Premium)
|
||||
let tpTotal = bp + tp + tep;
|
||||
let tpTotal = cop;
|
||||
if($('#bro_payable_by').is(':checked')){
|
||||
tpTotal = bp + tp + tep;
|
||||
}
|
||||
|
||||
console.log('bp', bp);
|
||||
console.log('tp', tp);
|
||||
@ -2401,50 +2405,29 @@ function co_share_percentage_calculation(input, extra = null){
|
||||
// console.log('Final input values:', inputValues);
|
||||
// }
|
||||
|
||||
// $(document).on('change', '[name="base_premium[]"]', function(e) {
|
||||
$(document).on('change', '[name="base_premium[]"], [name="co_share_per[]"]', function() {
|
||||
|
||||
console.log('Triggered change event.');
|
||||
|
||||
// console.log('############################################################');
|
||||
// console.log(e)
|
||||
|
||||
// // Get the index of the changed input field
|
||||
// const index = $('input[name="base_premium[]"]').index(this);
|
||||
|
||||
// // Get the corresponding co_share_per value
|
||||
// const coSharePer = parseFloat($('input[name="co_share_per[]"]').eq(index).val()) || 0;
|
||||
|
||||
// // Get the base_premium value
|
||||
// const basePremium = parseFloat($(this).val()) || 0;
|
||||
|
||||
// // Calculate the co_premium value using the formula
|
||||
// const coPremium = (basePremium * coSharePer) / 100;
|
||||
|
||||
// // Set the calculated value to the corresponding co_premium field
|
||||
// $('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2)); // Limiting to two decimal places
|
||||
// });
|
||||
|
||||
$(document).on('change', '[name="base_premium[]"], [name="co_share_per[]"]', function(e) {
|
||||
|
||||
// Get the base premium value (assuming there's only one)
|
||||
const basePremium = parseFloat($('input[name="base_premium[]"]').val()) || 0; // Get base_premium value
|
||||
console.log('basePremium', basePremium);
|
||||
// Get the first non-empty base premium value
|
||||
let basePremium = $('input[name="base_premium[]"]').toArray()
|
||||
.map(input => parseFloat($(input).val()) || 0)
|
||||
.find(value => value > 0) || 0;
|
||||
|
||||
console.log('Base Premium:', basePremium);
|
||||
|
||||
// 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
|
||||
|
||||
// Calculate co_premium using the formula: base_premium * co_share_per / 100
|
||||
const coPremium = (basePremium * coSharePer) / 100;
|
||||
|
||||
// Set the calculated value in the corresponding co_premium input
|
||||
$('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2)); // Limiting to two decimal places
|
||||
console.log(`Index: ${index}, Co-Share Percentage: ${coSharePer}, Co-Premium: ${coPremium}`);
|
||||
|
||||
// Update corresponding co_premium field
|
||||
$('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function select_leader_disable_premium_amt(input, value) {
|
||||
|
||||
if ($(input).is(':checked')) {
|
||||
@ -2680,10 +2663,6 @@ function getCDAccountNumber(input)
|
||||
console.log('follow_insurer_id insurer_id', insurer_id);
|
||||
console.log('follow_insurer_id unique_id', unique_id);
|
||||
|
||||
|
||||
// console.log('client_id', client_id);
|
||||
// console.log('insurer_id', insurer_id);
|
||||
|
||||
if(client_id && insurer_id){
|
||||
if(client_type == 1){
|
||||
$.ajax({
|
||||
@ -2723,8 +2702,15 @@ function getCDAccountNumber(input)
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
console.error('Client type Not found')
|
||||
console.log('client_type', client_type);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
console.error('Client ID or Insurer ID Not found')
|
||||
console.log('client_id', client_id);
|
||||
console.log('insurer_id', insurer_id);
|
||||
}
|
||||
}
|
||||
|
||||
function appendCDAccountNumber(data, unique_id, new_cd_ac_no = null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user