Net Present Value (NPV) Calculator

Enter the expected cash flow for each period.

NPV Calculation Results

Metric Value
Initial Investment
Discount Rate
Number of Periods
Total Cash Inflows (Present Value)
Net Present Value (NPV)
Decision

Initial Investment: ${outputInitialInvestment.textContent}

Discount Rate: ${outputDiscountRate.textContent}

Number of Periods: ${outputNumberOfPeriods.textContent}

Cash Flows

    ${cashFlowDetails}

Calculation Results

Metric Value
Initial Investment ${outputInitialInvestment.textContent}
Discount Rate ${outputDiscountRate.textContent}
Number of Periods ${outputNumberOfPeriods.textContent}
Total Cash Inflows (Present Value) ${outputTotalPresentValue.textContent}
Net Present Value (NPV) ${outputNPV.textContent}
Decision ${outputDecision.textContent}
`; element.innerHTML = pdfContent; html2pdf().from(element).set({ margin: [10, 10, 10, 10], filename: 'NPV_Calculator_Report.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true }, jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } }).save(); } // Event Listeners for Tabs tabButtons.forEach((button, index) => { button.addEventListener('click', function() { // Prevent direct tab switching to 'Results' without calculation if (index === 2 && currentActiveTab !== 1) { alert('Please calculate NPV first.'); return; } switchTab(index); }); }); // Navigation Button Listeners if (nextTab1Button) { nextTab1Button.addEventListener('click', function() { const numPeriodsVal = parseInt(numberOfPeriodsInput.value); if (isNaN(numPeriodsVal) || numPeriodsVal <= 0) { alert('Please enter a valid positive integer for Number of Periods before proceeding.'); numberOfPeriodsInput.focus(); return; } setupCashFlowInputs(); switchTab(1); }); } else { console.error("Next tab 1 button not found."); } if (prevTab2Button) { prevTab2Button.addEventListener('click', function() { switchTab(0); }); } else { console.error("Prev tab 2 button not found."); } if (nextTab2Button) { nextTab2Button.addEventListener('click', calculateNPV); } else { console.error("Next tab 2 button not found."); } if (prevTab3Button) { prevTab3Button.addEventListener('click', function() { switchTab(1); }); } else { console.error("Prev tab 3 button not found."); } if (addCashFlowButton) { addCashFlowButton.addEventListener('click', function() { const existingCashFlows = cashFlowInputsContainer.querySelectorAll('.cash-flow-item').length; const numPeriods = parseInt(numberOfPeriodsInput.value); if (isNaN(numPeriods) || numPeriods <= 0) { alert('Please enter a valid positive integer for Number of Periods on the "Project Details" tab first.'); switchTab(0); numberOfPeriodsInput.focus(); return; } // Allow adding more periods than initially specified if needed, but update the number of periods input if (existingCashFlows < numPeriods) { // Only add up to the initially defined number of periods setupCashFlowInputs(); // Regenerate based on current numPeriods } else { const newPeriodIndex = existingCashFlows + 1; const cashFlowItem = document.createElement('div'); cashFlowItem.className = 'cash-flow-item'; cashFlowItem.innerHTML = ` `; cashFlowInputsContainer.appendChild(cashFlowItem); // Update the number of periods input field to reflect the new total numberOfPeriodsInput.value = newPeriodIndex; } }); } else { console.error("Add Cash Flow button not found."); } if (downloadPdfButton) { downloadPdfButton.addEventListener('click', downloadPDF); } else { console.error("Download PDF button not found."); } });
Scroll to Top