From a1a177ecb95ad83f9192961db9060fb7d820a790 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 13 Nov 2025 11:09:56 +0530 Subject: [PATCH] FIX_ENDO_STATUS_(+)(-)_ISSUE --- .../policy_transaction_endorsement_form.php | 93 +++++++++++-------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/app/Views/policy_transaction_endorsement_form.php b/app/Views/policy_transaction_endorsement_form.php index 82e35f92..04f4b2de 100644 --- a/app/Views/policy_transaction_endorsement_form.php +++ b/app/Views/policy_transaction_endorsement_form.php @@ -1346,6 +1346,41 @@ // $('#co_premium_' + input).val(cop.toFixed(2)); // $('#co_tp_premium_' + input).val(cotp.toFixed(2)); // $('#co_ter_premium_' + input).val(cotep.toFixed(2)); + // } + + // Apply Deletion (Negative) Values + // function applyDeletionSymbolsToFields(input, isDeletion) { + // console.log('========== APPLYING DELETION SYMBOLS =========='); + + // if (!isDeletion) return; + + // const fieldIds = [ + // 'base_premium', + // 'tp_premium', + // 'ter_premium', + // 'co_premium', + // 'co_tp_premium', + // 'co_ter_premium', + // 'gst_amount', + // 'agreed_amount', + // 'non_comm_per_amt', + // 'total_amt', + // 'exp_amt' + // ]; + + // fieldIds.forEach(field => { + // const $el = $('#' + field + '_' + input); + // console.log('$el', '#' + field + '_' + input); + // console.log('$el', $el); + // let val = $el.val()?.trim(); + // console.log('$val', val); + // if (!val || val.startsWith('-')) return; + + // let num = parseFloat(val); + // if (!isNaN(num) && num > 0) $el.val(-num); + // }); + + // console.log('========== COMPLETED DELETION SYMBOL APPLICATION =========='); // } function checkAndDistributeTax(input){ @@ -1432,11 +1467,9 @@ let bap = selectedOption.data('bap') || ''; let allocg = selectedOption.data('allocg') || ''; let endorsement_type = $('#action_type').val(); - let isDeletion = endorsement_type === "deletion"; - // let isDeletion = false; // REF : VR,SVR and SVM remove "-" forenoon, they all said to revert it i don't know the reason 12/N/25 3:47pm . - - - console.log("bap:", bap, "allocg:", allocg, "isDeletion:", isDeletion); + let isDeletion = false; + // let isDeletion = endorsement_type === "deletion" || endorsement_type === "policy_cancellation"; + console.log({bap, allocg, isDeletion}); const event = window.event || {}; @@ -1460,7 +1493,20 @@ let cotp = (allocg !== 'EB') ? absNum('co_tp_premium') : 0; let cotep = (['Fire', 'Marine Cargo', 'Marine Hull'].includes(bap)) ? absNum('co_ter_premium') : 0; - console.log({ bp, tp, tep, cop, cotp, cotep, ncpa }); + console.log('premiums :', { bp, tp, tep, cop, cotp, cotep, ncpa }); + + let bp_raw_val = parseFloat($('#base_premium_' + input).val()); + console.log('bp_raw_val', bp_raw_val); + + // handel the positive(+), negative(-) symbole add the value + if(endorsement_type === "addition" || endorsement_type === "baby_addition" || endorsement_type === "addition_inception"){ + isDeletion = false + }else if(endorsement_type === "deletion" || endorsement_type === "policy_cancellation"){ + isDeletion = true + }else if(bp_raw_val < 0){ + isDeletion = true; + console.log('Value is negative:', bp_raw_val); + } let co_share_type_val = numVal('co_share_type'); console.log('co_share_type_val :', co_share_type_val); @@ -1542,40 +1588,6 @@ } // Apply Deletion (Negative) Values - // function applyDeletionSymbolsToFields(input, isDeletion) { - // console.log('========== APPLYING DELETION SYMBOLS =========='); - - // if (!isDeletion) return; - - // const fieldIds = [ - // 'base_premium', - // 'tp_premium', - // 'ter_premium', - // 'co_premium', - // 'co_tp_premium', - // 'co_ter_premium', - // 'gst_amount', - // 'agreed_amount', - // 'non_comm_per_amt', - // 'total_amt', - // 'exp_amt' - // ]; - - // fieldIds.forEach(field => { - // const $el = $('#' + field + '_' + input); - // console.log('$el', '#' + field + '_' + input); - // console.log('$el', $el); - // let val = $el.val()?.trim(); - // console.log('$val', val); - // if (!val || val.startsWith('-')) return; - - // let num = parseFloat(val); - // if (!isNaN(num) && num > 0) $el.val(-num); - // }); - - // console.log('========== COMPLETED DELETION SYMBOL APPLICATION =========='); - // } - function applyDeletionSymbolsToFields(input, isDeletion) { console.log('========== APPLYING DELETION SYMBOLS =========='); @@ -1615,7 +1627,6 @@ console.log('========== COMPLETED DELETION SYMBOL APPLICATION =========='); } - function setCoPremiums(input) { // Get base, TP, and TEP premiums for the given input row let bp = parseFloat($('#base_premium_' + input).val()) || 0;