Last active
July 22, 2025 19:57
-
-
Save brunurd/362117ada53f3fd297bf10d0a604c10b to your computer and use it in GitHub Desktop.
Function to calculate how much gross do you need to reach a net target.
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
/** | |
* calculateInvoice is a function to calculate how much gross do you need to reach a net target. | |
* | |
* @param netTarget The net you want to receive. | |
* @param taxPercent The tax percentage normally practiced for company segment and government. | |
* @returns Object which includes the: tax, net and gross results. | |
*/ | |
function calculateInvoice(netTarget, taxPercent) { | |
for (let gross = netTarget; gross < (netTarget*1000); gross++) { | |
const tax = (gross*taxPercent)/100; | |
const net = gross-tax; | |
if (net >= netTarget) { | |
return { netTarget, tax, net, gross }; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment