Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate investiment already discounting the tax
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
You can’t perform that action at this time.