SIP Top up Return

SIP Top Up Return

Please enter a number from 1 to 100.
Name(Required)
jQuery(document).ready(function ($) { // Define field IDs const monthlySIPField = '#input_14_1'; // Monthly SIP Amount const tenureField = '#input_14_3'; // Tenure in Months const rateOfReturnField = '#input_14_4'; // Expected Rate of Return const topUpFrequencyField = '#input_14_13'; // Top-Up Frequency const topUpAmountField = '#input_14_5'; // Top-Up Amount const resultField = '#input_14_12'; // Result Field for SIP Value function calculateSIP() { // Retrieve input values const monthlySIP = parseFloat($(monthlySIPField).val()) || 0; const tenure = parseInt($(tenureField).val()) || 0; const annualRateOfReturn = parseFloat($(rateOfReturnField).val()) || 0; const topUpFrequency = parseInt($(topUpFrequencyField).val()) || 0; const topUpAmount = parseFloat($(topUpAmountField).val()) || 0; // Validation: If inputs are invalid, clear result and return if (!monthlySIP || !tenure || !annualRateOfReturn || !topUpFrequency) { $(resultField).val(''); return; } // Calculate monthly rate of return const monthlyRateOfReturn = annualRateOfReturn / 1200; // Initialize total future value let totalFutureValue = 0; // Calculate contributions for each month for (let month = 1; month <= tenure; month++) { // Determine current SIP amount const currentSIP = monthlySIP + Math.floor((month - 1) / topUpFrequency) * topUpAmount; // Future Value of the current month's SIP const monthsRemaining = tenure - month + 1; const futureValue = currentSIP * Math.pow(1 + monthlyRateOfReturn, monthsRemaining); totalFutureValue += futureValue; } // Update the result field $(resultField).val(totalFutureValue.toFixed(2)); } // Attach event listeners to trigger calculation $( monthlySIPField + ',' + tenureField + ',' + rateOfReturnField + ',' + topUpFrequencyField + ',' + topUpAmountField ).on('input change', calculateSIP); // Perform initial calculation (in case of pre-filled fields) calculateSIP(); });