Created
July 18, 2018 18:14
-
-
Save uqmessias/7d2da1ff3403ae7b43bb5eb8b5d6f850 to your computer and use it in GitHub Desktop.
Calculate investiment already discounting the tax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const calculateInvestiment = (initial, months, annualInterestPercentage/*6.4 for instance*/, taxPercentage/*0 to 100*/) => { | |
const monthInterestMultiplier = Math.pow((annualInterestPercentage / 100) + 1, 1 / 12) - 1; | |
const totalInterestMultiplier = Math.pow(monthInterestMultiplier + 1, months) - 1; | |
const total = initial * (totalInterestMultiplier + 1); | |
const profit = total - initial; | |
const tax = profit * taxPercentage / 100; | |
const liquidProfit = profit - tax; | |
return { | |
initial, | |
total, | |
totalInterestPercentage: totalInterestMultiplier * 100, | |
tax, | |
taxPercentage, | |
profit, | |
liquidProfit, | |
monthInterestPercentage: monthInterestMultiplier * 100, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment