From 7c7f3ce07abb9e89173539f14e8cce549f608894 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 28 Oct 2025 18:01:50 +0530 Subject: [PATCH] FIX_BDS_REPORT_ISSUE_CHANGE_0_RESTRICT_POLICY_IN_BDS --- .../policy_transaction_endorsement_form.php | 29 +++++++++++++++++-- .../policy_transaction_inception_form.php | 24 +++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 4071282f..06f02de4 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -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) { diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index f196a35e..75a0376d 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -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) {