FIX_BDS_REPORT_ISSUE_CHANGE_0_RESTRICT_POLICY_IN_BDS

This commit is contained in:
VENKATESHWARAN 2025-10-28 18:01:50 +05:30
parent 7e6ecd570d
commit 7c7f3ce07a
2 changed files with 51 additions and 2 deletions

View File

@ -1005,6 +1005,7 @@
setTimeout(function(){
$('#policy_start_date').val(res.data.policy_start_date);
$('#policy_end_date').val(res.data.policy_end_date);
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
}, 1500)
$('#policy_no').val(res.data.policy_no);
@ -1347,15 +1348,39 @@
// $('#co_ter_premium_' + input).val(cotep.toFixed(2));
// }
function checkAndDistributeTax(input)
{
function checkAndDistributeTax(input){
const event = window.event;
console.log("Event id:", event.target.id);
let policy_type_id = $('#client_policy_id').find('option:selected').attr('data-ptid');
policy_type_id = parseInt(policy_type_id);
console.log('policy_type_id', policy_type_id);
let cgst = parseFloat($('#cgst_' + input).val());
let sgst = parseFloat($('#sgst_' + input).val());
let igst = parseFloat($('#igst_' + input).val());
// ✅ Allow 0 only for policy types 2, 5, 7
const allowZero = [1,2,3,4,5,6,7,38,39,40].includes(policy_type_id);
console.log("allowZero", allowZero);
// 🔒 Validation: Disallow 0 or negative values for other policy types
if (!allowZero) {
if ((cgst <= 0 && (event.target.id).startsWith('cgst')) ||
(sgst <= 0 && (event.target.id).startsWith('sgst')) ||
(igst <= 0 && (event.target.id).startsWith('igst'))) {
toastr.warning('Tax value must be greater than 0 for this policy type.');
$('#'+ event.target.id).val('');
$('#igst_' + input).val('');
$('#cgst_' + input).val('');
$('#sgst_' + input).val('');
return;
}
}
if (((event.target.id).startsWith('cgst'))) {
if (!isFinite(cgst) || isNaN(cgst) || cgst === undefined) {

View File

@ -2322,13 +2322,37 @@
// }
function checkAndDistributeTax(input){
const event = window.event;
console.log("Event id:", event.target.id);
let policy_type_id = parseInt($('#policy_type_id').val());
console.log('policy_type_id', policy_type_id);
let cgst = parseFloat($('#cgst_' + input).val());
let sgst = parseFloat($('#sgst_' + input).val());
let igst = parseFloat($('#igst_' + input).val());
// ✅ Allow 0 only for policy types 2, 5, 7
const allowZero = [1,2,3,4,5,6,7,38,39,40].includes(policy_type_id);
console.log("allowZero", allowZero);
// 🔒 Validation: Disallow 0 or negative values for other policy types
if (!allowZero) {
if ((cgst <= 0 && (event.target.id).startsWith('cgst')) ||
(sgst <= 0 && (event.target.id).startsWith('sgst')) ||
(igst <= 0 && (event.target.id).startsWith('igst'))) {
toastr.warning('Tax value must be greater than 0 for this policy type.');
$('#'+ event.target.id).val('');
$('#igst_' + input).val('');
$('#cgst_' + input).val('');
$('#sgst_' + input).val('');
return;
}
}
if (((event.target.id).startsWith('cgst'))) {
if (!isFinite(cgst) || isNaN(cgst) || cgst === undefined) {