FIX_ADDITION_MINUS_SYMBOL
This commit is contained in:
parent
8cfe1fb0b8
commit
4cde80ddaa
@ -1534,18 +1534,51 @@
|
||||
setCoPremiums(input);
|
||||
|
||||
// ✅ Apply deletion symbols last (safely);
|
||||
if (isDeletion) {
|
||||
applyDeletionSymbolsToFields(input, true);
|
||||
}
|
||||
// if (isDeletion) {
|
||||
applyDeletionSymbolsToFields(input, isDeletion);
|
||||
// }
|
||||
|
||||
console.log('############################## END AMOUNT CALCULATION ############################################');
|
||||
}
|
||||
|
||||
// Apply Deletion (Negative) Values
|
||||
function applyDeletionSymbolsToFields(input, isDeletion) {
|
||||
console.log('========== APPLYING DELETION SYMBOLS ==========');
|
||||
// function applyDeletionSymbolsToFields(input, isDeletion) {
|
||||
// console.log('========== APPLYING DELETION SYMBOLS ==========');
|
||||
|
||||
if (!isDeletion) return;
|
||||
// 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 ==========');
|
||||
|
||||
const fieldIds = [
|
||||
'base_premium',
|
||||
@ -1563,19 +1596,26 @@
|
||||
|
||||
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;
|
||||
if (!val) return;
|
||||
|
||||
let num = parseFloat(val);
|
||||
if (!isNaN(num) && num > 0) $el.val(-num);
|
||||
let num = parseFloat(val.replace(/^-/, '')); // remove any existing minus first
|
||||
console.log('num', num);
|
||||
if (isNaN(num)) return;
|
||||
|
||||
if (isDeletion) {
|
||||
// Apply minus sign
|
||||
if (num > 0) $el.val(-num);
|
||||
} else {
|
||||
// Remove minus sign
|
||||
$el.val(num);
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user