Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion mysite/templates/calculator/SIP_calculator.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% block MDesc %}
Calculate SIP and Lumpsum returns with interactive sliders. Estimate your wealth creation through systematic investment plans in mutual funds.
{% endblock %}
{% block MKW %}SIP calculator,calculator of sip,sip calculator india,systematic investment plan calculator,lumpsum calculator,mutual fund calculator,sip returns calculator{% endblock %}
{% block MKW %}SIP calculator,Step Up SIP Calculator,sip calculator india,systematic investment plan calculator,lumpsum calculator,mutual fund calculator,sip returns calculator{% endblock %}
{% block Mr %}
{% now "d/m/Y" %}
{% endblock %}
Expand Down Expand Up @@ -204,6 +204,16 @@ <h1 class="my-2 text-center text-light">SIP Calculator</h1>
<input type="range" class="slider-input" id="timePeriod" min="1" max="50" step="1" value="10">
</div>
</div>

<div class="slider-container">
<label class="slider-label">Annual Step-up (%)</label>
<input type="text" class="value-display" id="sipStepupDisplay" value="0%">
<div class="slider-wrapper">
<div class="slider-track"></div>
<div class="slider-fill" id="sipStepupFill"></div>
<input type="range" class="slider-input" id="sipStepup" min="0" max="50" step="0.5" value="0">
</div>
</div>
</div>

<!-- Lumpsum Inputs -->
Expand Down
45 changes: 27 additions & 18 deletions staticfiles/js/calculator/SIP_calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,30 @@ function getMonthlyRate(annualReturn) {
}

// Calculate SIP
function calculateSIP(monthlyInvestment, annualReturn, years) {
function calculateSIP(monthlyInvestment, annualReturn, years, stepUpPercent = 0) {
const monthlyRate = getMonthlyRate(annualReturn);
const totalMonths = years * 12;

const totalInvested = monthlyInvestment * totalMonths;
let totalInvested = 0;
let totalValue = 0;

if (monthlyRate > 0) {
const factor = (Math.pow(1 + monthlyRate, totalMonths) - 1) / monthlyRate;
totalValue = monthlyInvestment * factor * (1 + monthlyRate);
} else {
totalValue = totalInvested;

let currentInvestment = monthlyInvestment;
const stepUpMultiplier = 1 + (stepUpPercent / 100);

for (let year = 1; year <= years; year++) {
// For each year, do 12 months of SIP
for (let month = 1; month <= 12; month++) {
totalInvested += currentInvestment;
const monthsRemaining = (years - year) * 12 + (12 - month + 1);
totalValue += currentInvestment * Math.pow(1 + monthlyRate, monthsRemaining);
}
currentInvestment *= stepUpMultiplier; // Increase SIP for next year
}

const estimatedReturns = totalValue - totalInvested;

return {
totalInvested: totalInvested,
estimatedReturns: estimatedReturns,
totalValue: totalValue
totalInvested,
estimatedReturns,
totalValue
};
}

Expand All @@ -80,8 +84,9 @@ function updateResults() {
const monthlyInvestment = parseFloat(document.getElementById('monthlyInvestment').value);
const annualReturn = parseFloat(document.getElementById('expectedReturn').value);
const years = parseInt(document.getElementById('timePeriod').value);

result = calculateSIP(monthlyInvestment, annualReturn, years);
const stepUpPercent = parseFloat(document.getElementById('sipStepup').value);

result = calculateSIP(monthlyInvestment, annualReturn, years, stepUpPercent);
} else {
const lumpsumAmount = parseFloat(document.getElementById('lumpsumAmount').value);
const annualReturn = parseFloat(document.getElementById('lumpsumReturn').value);
Expand Down Expand Up @@ -111,14 +116,17 @@ function updateDisplays() {
const monthlyInvestment = parseFloat(document.getElementById('monthlyInvestment').value);
const annualReturn = parseFloat(document.getElementById('expectedReturn').value);
const years = parseInt(document.getElementById('timePeriod').value);

const stepUpPercent = parseFloat(document.getElementById('sipStepup').value);

document.getElementById('sipStepupDisplay').value = formatPercentage(stepUpPercent);
document.getElementById('monthlyInvestmentDisplay').value = formatCurrency(monthlyInvestment);
document.getElementById('expectedReturnDisplay').value = formatPercentage(annualReturn);
document.getElementById('timePeriodDisplay').value = formatYears(years);

updateSliderFill('monthlyInvestment', 'monthlyInvestmentFill');
updateSliderFill('expectedReturn', 'expectedReturnFill');
updateSliderFill('timePeriod', 'timePeriodFill');
updateSliderFill('sipStepup', 'sipStepupFill');
} else {
const lumpsumAmount = parseFloat(document.getElementById('lumpsumAmount').value);
const annualReturn = parseFloat(document.getElementById('lumpsumReturn').value);
Expand Down Expand Up @@ -178,6 +186,7 @@ document.getElementById('lumpsumToggle').addEventListener('click', function() {
document.getElementById('monthlyInvestment').addEventListener('input', updateDisplays);
document.getElementById('expectedReturn').addEventListener('input', updateDisplays);
document.getElementById('timePeriod').addEventListener('input', updateDisplays);
document.getElementById('sipStepup').addEventListener('input', updateDisplays);

// Lumpsum sliders event listeners
document.getElementById('lumpsumAmount').addEventListener('input', updateDisplays);
Expand Down
Loading