Skip to content

Instantly share code, notes, and snippets.

@uselessdev
Last active April 1, 2022 18:30
Show Gist options
  • Save uselessdev/75918982b9eb7c93ba90c023d2b63cf8 to your computer and use it in GitHub Desktop.
Save uselessdev/75918982b9eb7c93ba90c023d2b63cf8 to your computer and use it in GitHub Desktop.
const revenue = process.argv[2]
const prolabore = 28
const das = 6
const prolaboreAmount = ((prolabore / 100) * revenue)
const getINSSTaxAmount = () => {
if (prolaboreAmount <= 1100) {
return 7.5
}
if (prolaboreAmount >= 1100.01 && prolaboreAmount <= 2203.48) {
return 9
}
if (prolaboreAmount >= 2203.49 && prolaboreAmount <= 3305.22) {
return 11
}
if (prolaboreAmount >= 3305.23 && prolaboreAmount <= 6433.57) {
return 14
}
return 0
}
const inss = getINSSTaxAmount()
const inssTaxAmount = ((inss / 100) * prolaboreAmount)
const getIRRFTaxAmount = () => {
const base = prolaboreAmount - inssTaxAmount
if (base >= 1903.99 && base <= 2826.65) {
return {
tax: 7.5,
installment: 142.80
}
}
if (base >= 2826.66 && base <= 3751.05) {
return {
tax: 15,
installment: 354.80
}
}
if (base >= 3751.06 && base <= 4664.68) {
return {
tax: 22.5,
installment: 636.13
}
}
if (base >= 4664.68) {
return {
tax: 27.5,
installment: 869.36
}
}
return 0
}
const irrf = getIRRFTaxAmount().tax
const irrfInstallmentDeducted = getIRRFTaxAmount().installment
const dasTaxAmount = ((das / 100) * revenue)
const irrfTaxAmount = ((irrf / 100) * (prolaboreAmount - inssTaxAmount)) - irrfInstallmentDeducted
const prolaboreLiquidAmount = prolaboreAmount - inssTaxAmount - irrfTaxAmount
const anticipatedProfitsAmount = revenue - (prolaboreLiquidAmount + dasTaxAmount + irrfTaxAmount + inssTaxAmount)
const totalLiquidRevenueAmount = prolaboreLiquidAmount + anticipatedProfitsAmount
const format = (number) =>
new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(number)
console.log(`
Receita Bruta:
${format(revenue)}
DAS de ${das}%:
${format(dasTaxAmount)}
INSS de ${inss}%:
${format(inssTaxAmount)}
IRRF de ${irrf}%:
${format(irrfTaxAmount)}
Prolabore Bruto de ${prolabore}%:
${format(prolaboreAmount)}
Prolabore Liquido:
${format(prolaboreLiquidAmount)}
Lucros Antecipáveis:
${format(anticipatedProfitsAmount)}
Receita Liquida:
${format(totalLiquidRevenueAmount)}
Total de Impostos:
${format(revenue - totalLiquidRevenueAmount)}
`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment