MERGE_UAT_BDS_CO_SHARE_HANDLED
This commit is contained in:
commit
1e8be4e525
@ -414,9 +414,13 @@ class PolicyTransactionController extends BaseController
|
||||
// Prepare data for insertion and updating
|
||||
$coShareDetails = [];
|
||||
|
||||
// print_r($data);
|
||||
// print_r($data); die;
|
||||
// die;
|
||||
|
||||
if(isset($data['co_share_id']) && !empty($data['co_share_id'])){
|
||||
$this->removePtCoShareRecords($data['co_share_id']);
|
||||
}
|
||||
|
||||
if(isset($data['follow_insurer_id'])){
|
||||
|
||||
foreach ($data['follow_insurer_id'] as $index => $insurer) {
|
||||
@ -501,7 +505,7 @@ class PolicyTransactionController extends BaseController
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// print_r($data);
|
||||
// die;
|
||||
}
|
||||
@ -951,6 +955,23 @@ class PolicyTransactionController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
//function for soft delete for pt_co_share_details records
|
||||
public function removePtCoShareRecords($primaryKeys)
|
||||
{
|
||||
// print_r($primaryKeys); die;
|
||||
if (empty($primaryKeys)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert array to a comma-separated string for query binding
|
||||
$placeholders = implode(',', array_fill(0, count($primaryKeys), '?'));
|
||||
|
||||
$sql = "UPDATE pt_co_share_details SET is_active = 0 WHERE id NOT IN ($placeholders)";
|
||||
|
||||
return db_connect()->query($sql, $primaryKeys);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Policy Transaction Endorsement
|
||||
|
||||
@ -153,6 +153,7 @@
|
||||
<input type="hidden" name="insurer_id" id="insurer_id">
|
||||
<input type="hidden" name="cd_ac_no" id="cd_ac_pk_for_leader">
|
||||
<input type="hidden" name="ct_type" id="ct_type">
|
||||
<input type="hidden" name="remove_pt_co_id" id="remove_pt_co_id" >
|
||||
|
||||
<!-- <input type="hidden" id="cd_ac_no_for_edit"> -->
|
||||
<input type="hidden" id="premium_details_unique_id">
|
||||
@ -1453,6 +1454,8 @@ $(document).ready(function() {
|
||||
//edit function
|
||||
function getPolicyTransactionDataForEdit(input) {
|
||||
|
||||
console.log('############################# Get Policy Transaction Data For Edit #############################');
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
@ -1751,7 +1754,11 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
}
|
||||
});
|
||||
|
||||
//To check the invoice statement if statament is upload aginst this policy than change readonly the table fileds
|
||||
checkInvoiceStatusToHideSubmitBtn(id)
|
||||
|
||||
console.log('############################# END Get Policy Transaction Data For Edit #############################');
|
||||
|
||||
}
|
||||
|
||||
//-------- CALCULATION PART -------------------------------------------------------------------------------------------------
|
||||
@ -1798,6 +1805,7 @@ function checkAndDistributeTax(input)
|
||||
|
||||
function amountCalculation(input) {
|
||||
|
||||
console.log('############################## AMOUNT CALCULATION ############################################')
|
||||
console.log('amountCalculation : ' + input);
|
||||
let selectedOption = $('#policy_type_id').find('option:selected');
|
||||
let bap = selectedOption.data('bap');
|
||||
@ -1853,17 +1861,13 @@ function amountCalculation(input) {
|
||||
let gst_amount = parseFloat($('#gst_amount_' + input).val()) || 0;
|
||||
|
||||
// console.log(standard_bp_per, standard_tp_per, standard_tep_per);
|
||||
// console.log(agreed_bp_per, agreed_tp_per, agreed_tep_per);
|
||||
|
||||
// let co_premium_amt = ((bp + tp + tep) * co_share_per) / 100;
|
||||
|
||||
// $('#co_premium_' + input).val(!isNaN(co_premium_amt) && isFinite(co_premium_amt) ? co_premium_amt.toFixed(2) : '0.00');
|
||||
|
||||
|
||||
// Calculate GST percentage
|
||||
let gst_per = igst;
|
||||
if (igst === 0) {
|
||||
gst_per = parseFloat(cgst) + parseFloat(sgst);
|
||||
// gst_per = (cgst) + (sgst);
|
||||
}
|
||||
|
||||
// console.log('gst_per', gst_per);
|
||||
@ -1872,9 +1876,20 @@ function amountCalculation(input) {
|
||||
// console.log('sgst', sgst);
|
||||
|
||||
// Calculate the total premium
|
||||
|
||||
let base_premium = cop;
|
||||
let third_part_premium = cotp;
|
||||
let terrisom_premium = cotep;
|
||||
|
||||
let tpTotal = cop + cotp + cotep;
|
||||
if($('#bro_payable_by').is(':checked')){
|
||||
|
||||
tpTotal = bp + tp + tep;
|
||||
|
||||
base_premium = bp;
|
||||
third_part_premium = tp;
|
||||
terrisom_premium = tep;
|
||||
|
||||
}
|
||||
|
||||
if (!$('#cop_yes').is(':checked')) {
|
||||
@ -1884,7 +1899,6 @@ function amountCalculation(input) {
|
||||
$('#co_share_per_' + input).val(100);
|
||||
}
|
||||
|
||||
|
||||
console.log('tpTotal', tpTotal);
|
||||
ncpaTotal = tpTotal + ncpa;
|
||||
let ncpa_gst_per_amt = (ncpaTotal * gst_per) / 100;
|
||||
@ -1907,11 +1921,12 @@ function amountCalculation(input) {
|
||||
}
|
||||
|
||||
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
|
||||
|
||||
console.log('Summed Amount:', finalTotal);
|
||||
// $('#total_amt_' + input).val(finalTotal.toFixed(2));
|
||||
|
||||
//Total Amount
|
||||
$('#total_amt_' + input).val(!isNaN(finalTotal) && isFinite(finalTotal) ? finalTotal.toFixed(2) : '0.00');
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
let sum_of_agreed_premium = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
||||
// console.log('sum_of_agreed_precentage : ', sum_of_agreed_premium);
|
||||
@ -1922,24 +1937,32 @@ function amountCalculation(input) {
|
||||
expectedAmount = agreed_amount;
|
||||
// console.log('Formula 1 AGREED AMOUNT');
|
||||
}else if(sum_of_agreed_premium > 0){
|
||||
//expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per));
|
||||
|
||||
let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
||||
expectedAmount = (tpTotal * sumOfTheAggreedPer);
|
||||
expectedAmount = expectedAmount / 100;
|
||||
|
||||
let sum_of_bp_amt = (base_premium * agreed_bp_per) /100
|
||||
let sum_of_tp_amt = (third_part_premium * agreed_tp_per) / 100
|
||||
let sum_of_tep_amt = (terrisom_premium * agreed_tep_per) / 100
|
||||
|
||||
expectedAmount = (sum_of_bp_amt + sum_of_tp_amt + sum_of_tep_amt) ?? 0;
|
||||
|
||||
// console.log('Formula 2 AGREED BP TP/TEP %');
|
||||
}else{
|
||||
// expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
|
||||
|
||||
let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per;
|
||||
expectedAmount = (tpTotal * sumOfTheStandardPer);
|
||||
console.log(expectedAmount)
|
||||
expectedAmount = expectedAmount / 100;
|
||||
|
||||
let sum_of_bp_amt = (base_premium * standard_bp_per) /100
|
||||
let sum_of_tp_amt = (third_part_premium * standard_tp_per) / 100
|
||||
let sum_of_tep_amt = (terrisom_premium * standard_tep_per) / 100
|
||||
|
||||
expectedAmount = (sum_of_bp_amt + sum_of_tp_amt + sum_of_tep_amt) ?? 0;
|
||||
|
||||
// console.log('Formula 3 STANDARD BP TP/TEP %');
|
||||
}
|
||||
|
||||
// console.log('expectedAmount', expectedAmount);
|
||||
console.log('expectedAmount', expectedAmount);
|
||||
|
||||
//Expected Amount
|
||||
// $('#exp_amt_' + input).val(expectedAmount.toFixed(2));
|
||||
$('#exp_amt_' + input).val(!isNaN(expectedAmount) && isFinite(expectedAmount) ? expectedAmount.toFixed(2) : '0.00');
|
||||
|
||||
|
||||
@ -1956,12 +1979,12 @@ function amountCalculation(input) {
|
||||
let variance = (actual_bp_brokerage_amount + actual_tp_brokerage_amount + actual_tep_brokerage_amount) - expectedAmount;
|
||||
// console.log('variance', variance);
|
||||
|
||||
|
||||
// $('#variance_' + input).val(variance.toFixed(2));
|
||||
$('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
||||
// console.log('variance', variance);
|
||||
// $('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
||||
|
||||
setCoPremiums(input);
|
||||
|
||||
console.log('############################## END AMOUNT CALCULATION ############################################')
|
||||
|
||||
}
|
||||
|
||||
function actualAmountCalculation(input, field = null){
|
||||
@ -2482,6 +2505,45 @@ function select_leader_disable_premium_amt(input, value) {
|
||||
}
|
||||
}
|
||||
|
||||
function select_leader_disable_premium_amt_in_edit() {
|
||||
|
||||
$('#insurerTable thead th').each(function(value) {
|
||||
|
||||
if (value === 0) {
|
||||
console.log("Premium Table columnIndexes is", value);
|
||||
} else {
|
||||
|
||||
if ($('#co_share_type_' + value).is(':checked')) {
|
||||
// Disable and add readonly-select class to all premiums except the one with the given value
|
||||
$('input[name="base_premium[]"]').addClass('readonly-select');
|
||||
$('#base_premium_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="tp_premium[]"]').addClass('readonly-select');
|
||||
$('#tp_premium_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="ter_premium[]"]').addClass('readonly-select');
|
||||
$('#ter_premium_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="stamp_duty[]"]').addClass('readonly-select');
|
||||
$('#stamp_duty_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="co_premium[]"]').addClass('readonly-select');
|
||||
$('#co_premium_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="co_tp_premium[]"]').addClass('readonly-select');
|
||||
$('#co_tp_premium_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="co_ter_premium[]"]').addClass('readonly-select');
|
||||
$('#co_ter_premium_' + value).removeClass('readonly-select');
|
||||
|
||||
$('input[name="cd_ac_no_for_child[]"]').addClass('readonly-select');
|
||||
$('#cd_ac_no_' + value).removeClass('readonly-select');
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function validateRange(input) {
|
||||
// if (input.value < 1) input.value = 1;
|
||||
if (input.value > 100) input.value = 100;
|
||||
@ -2589,7 +2651,6 @@ function appendOwner(data) {
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
let client_show_name = item.client_name;
|
||||
@ -2658,7 +2719,6 @@ function checkInvoiceStatusToHideSubmitBtn(id){
|
||||
$('#submitButton').show()
|
||||
}
|
||||
}else{
|
||||
|
||||
console.log(res.message, 'warning');
|
||||
}
|
||||
},
|
||||
@ -3354,7 +3414,7 @@ $('#client_type').change(function() {
|
||||
}
|
||||
|
||||
|
||||
var selectedOption = $(this).find('option:selected');
|
||||
var selectedOption = $('#policy_type_id').find('option:selected');
|
||||
|
||||
var ebp = selectedOption.data('ebp');
|
||||
var etp = selectedOption.data('etp');
|
||||
@ -3689,7 +3749,7 @@ $('#setInsurerCount').on('click', function() {
|
||||
});
|
||||
|
||||
function addInsurerColumn() {
|
||||
|
||||
|
||||
insurerCount = insurerCount + 1;
|
||||
|
||||
// Update header
|
||||
@ -4024,14 +4084,6 @@ function addInsurerColumn() {
|
||||
// console.log('std_tp', std_tp);
|
||||
// console.log('std_tep', std_tep);
|
||||
|
||||
// console.log('ebp', ebp);
|
||||
// console.log('etp', etp);
|
||||
// console.log('etep', etep);
|
||||
// console.log('iep', iep);
|
||||
// console.log('itp', itp);
|
||||
// console.log('itep', itep);
|
||||
|
||||
|
||||
$('[name="standard_bp[]"]').val(std_bp);
|
||||
$('[name="standard_tp[]"]').val(std_tp);
|
||||
$('[name="standard_ter[]"]').val(std_tep);
|
||||
@ -4060,24 +4112,47 @@ function addInsurerColumn() {
|
||||
}
|
||||
|
||||
function removeInsurerColumn(index, count_index) {
|
||||
|
||||
console.log('#################################### Remove Insurer Column ####################################');
|
||||
|
||||
// Remove the header
|
||||
$('#insurerTable thead tr th').eq(index).remove();
|
||||
|
||||
// Remove the corresponding data cells in each row
|
||||
let removedCoShareIds = [];
|
||||
|
||||
$('#insurerTable tbody tr').each(function() {
|
||||
$(this).find('td').eq(index).remove();
|
||||
let coShareId = $(this).find('td').eq(index).find('[name="co_share_id[]"]').val();
|
||||
|
||||
if (coShareId) {
|
||||
removedCoShareIds.push(coShareId);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('removedCoShareIds array', removedCoShareIds);
|
||||
|
||||
// Set the array as a comma-separated string in the hidden input
|
||||
$('#remove_pt_co_id').val(removedCoShareIds.join(','));
|
||||
console.log('remove_pt_co_id value', $('#remove_pt_co_id').val());
|
||||
|
||||
insurer_count_array = insurer_count_array.filter(item => item !== count_index);
|
||||
co_share_percentage_calculation(null, "remove");
|
||||
insurerCount--;
|
||||
|
||||
console.log('#################################### END Remove Insurer Column ####################################');
|
||||
|
||||
}
|
||||
|
||||
function populateTable(dataArray, cd_ac_pk) {
|
||||
|
||||
console.log('#################################### Populate Table ####################################');
|
||||
|
||||
|
||||
console.log('populateTable data', dataArray)
|
||||
|
||||
dataArray.forEach((data, index) => {
|
||||
|
||||
// Add a new insurer column for each entry in the data array
|
||||
addInsurerColumn(); // This will add a new column dynamically
|
||||
|
||||
@ -4324,11 +4399,18 @@ function populateTable(dataArray, cd_ac_pk) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(index != 0){
|
||||
if(data.co_share_type != 0 && data.co_share_type != 1){
|
||||
let co_share_index = index + 1;
|
||||
select_leader_disable_premium_amt_in_edit(co_share_index);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// $('input:disabled, select:disabled, textarea:disabled').addClass('readonly-color');
|
||||
|
||||
console.log('#################################### END Populate Table ####################################');
|
||||
|
||||
}
|
||||
|
||||
$(document).on('click', '.delete-insurer', function() {
|
||||
@ -4423,6 +4505,8 @@ function setFormDataFromLocalStorage(formSelector, storageKey) {
|
||||
|
||||
function checkCDAmountForBasePremium(input) {
|
||||
|
||||
console.log('#################################### Check CD Amount For Base Premium ####################################');
|
||||
|
||||
console.log(input)
|
||||
let client_type = $('#client_type').val();
|
||||
console.log('client type', client_type);
|
||||
@ -4477,10 +4561,15 @@ function checkCDAmountForBasePremium(input) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
console.log('#################################### END Check CD Amount For Base Premium ####################################');
|
||||
|
||||
}
|
||||
|
||||
function getCdAmount(cd_ac_pk, increment){
|
||||
|
||||
console.log('#################################### Get CD Amount ####################################');
|
||||
|
||||
// increment = increment + 1
|
||||
console.log('cd_ac_pk', cd_ac_pk);
|
||||
console.log('increment', increment);
|
||||
@ -4513,6 +4602,8 @@ function getCdAmount(cd_ac_pk, increment){
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
});
|
||||
|
||||
console.log('#################################### END Get CD Amount ####################################');
|
||||
|
||||
}
|
||||
|
||||
$('#bro_payable_by').on('change', function(){
|
||||
@ -4520,25 +4611,23 @@ $('#bro_payable_by').on('change', function(){
|
||||
var columnIndexes = [];
|
||||
$('#insurerTable thead th').each(function(index) {
|
||||
if(index == 0){
|
||||
console.log("columnIndexes is ", index);
|
||||
console.log("Premium Table columnIndexes is ", index);
|
||||
}else{
|
||||
amountCalculation(index);
|
||||
}
|
||||
columnIndexes.push(index);
|
||||
});
|
||||
console.log("columnIndexes", columnIndexes);
|
||||
|
||||
});
|
||||
|
||||
$(document).on('change', '#insurerTable input, #insurerTable select, #insurerTable textarea', function() {
|
||||
console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
|
||||
// console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
|
||||
getColumnIndexes()
|
||||
});
|
||||
|
||||
function getColumnIndexes(count = 0) {
|
||||
$('#insurerTable thead th').each(function(index) {
|
||||
if (index === 0) {
|
||||
console.log("columnIndexes is", index);
|
||||
console.log("Premium Table columnIndexes is", index);
|
||||
} else {
|
||||
amountCalculation(index);
|
||||
if(count == 1){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user