Skip to content

Commit

Permalink
Códigos em Notebook do Jupyter e Script em Python
Browse files Browse the repository at this point in the history
  • Loading branch information
rigueti-bruno authored Apr 29, 2024
1 parent e36f53a commit fc322ed
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 0 deletions.
175 changes: 175 additions & 0 deletions calculo-salario-liquido-brasil/calculo-contracheque.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Cálculo de Contra-Cheque Padrão:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# Criação da Classe para gerar os Objetos Salario Liquido:\n",
"class Salario: \n",
" def __init__(self,remuneracao,he,insa):\n",
" self.remuneracao = remuneracao\n",
" self.he = he\n",
" self.insa = insa\n",
" \n",
" def descinss(self):\n",
" if self.remuneracao <= 1412:\n",
" return self.remuneracao * 0.075\n",
" elif self.remuneracao <= 2666.68:\n",
" return (self.remuneracao * 0.09) - 21.18\n",
" elif self.remuneracao <= 4000.03:\n",
" return (self.remuneracao * 0.12) - 101.18\n",
" elif self.remuneracao > 7786.02:\n",
" return (self.remuneracao * 0.14) - 181.18\n",
" \n",
" def descir(self):\n",
" if self.remuneracao <= 2259.20:\n",
" return 0\n",
" elif self.remuneracao <= 2826.65:\n",
" return (self.remuneracao * 0.075) - 169.44\n",
" elif self.remuneracao <= 3751.05:\n",
" return (self.remuneracao * 0.15) - 381.44\n",
" elif self.remuneracao <= 4664.68:\n",
" return (self.remuneracao * 0.225) - 662.77\n",
" elif self.remuneracao > 4664.68:\n",
" return (self.remuneracao * 0.275) - 896\n",
"\n",
" def hextra(self):\n",
" return ((self.remuneracao / 220) * 1.5) * self.he\n",
" \n",
" def insalub(self):\n",
" if self.insa == True:\n",
" return self.remuneracao * 0.15\n",
" else:\n",
" return 0\n",
"\n",
" def liquido(self):\n",
" return self.remuneracao + self.hextra() + self.insalub() - self.descinss() - self.descir()\n",
" \n",
" def contracheque(self):\n",
" print(f\"Salario Bruto: R${self.remuneracao:.2f}\")\n",
" print(f\"(+) Horas Extras: R${self.hextra():.2f}\")\n",
" print(f\"(+) Insalubridade: R${self.insalub():.2f}\")\n",
" print(f\"(-) INSS: R${self.descinss():.2f}\")\n",
" print(f\"(-) IRPF: R${self.descir():.2f}\") \n",
" \n",
" print(f\"(=) Salario Liquido: R${self.liquido():.2f}\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"x = Salario(1412,0,False)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1412\n",
"0\n",
"False\n"
]
}
],
"source": [
"print(x.remuneracao)\n",
"print(x.he)\n",
"print(x.insa)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Salario Bruto: R$1412.00\n",
"(-) INSS: R$105.90\n",
"(-) IRPF: R$0.00\n",
"(+) Horas Extras: R$0.00\n",
"(+) Insalubridade: R$0.00\n",
"(=) Salario Liquido: R$1306.10\n"
]
}
],
"source": [
"print(f\"Salario Bruto: R${x.remuneracao:.2f}\")\n",
"print(f\"(-) INSS: R${x.descinss():.2f}\")\n",
"print(f\"(-) IRPF: R${x.descir():.2f}\")\n",
"print(f\"(+) Horas Extras: R${x.hextra():.2f}\")\n",
"print(f\"(+) Insalubridade: R${x.insalub():.2f}\")\n",
"print(f\"(=) Salario Liquido: R${x.liquido():.2f}\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Salario Bruto: R$1412.00\n",
"(+) Horas Extras: R$0.00\n",
"(+) Insalubridade: R$0.00\n",
"(-) INSS: R$105.90\n",
"(-) IRPF: R$0.00\n",
"(=) Salario Liquido: R$1306.10\n"
]
}
],
"source": [
"x.contracheque()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Criação da Interface:"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
59 changes: 59 additions & 0 deletions calculo-salario-liquido-brasil/contra-cheque.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Criação da Classe para gerar os Objetos Salario Liquido:
class Salario:
def __init__(self,remuneracao,he,insa):
self.remuneracao = remuneracao
self.he = he
self.insa = insa

def hextra(self):
return ((self.remuneracao / 220) * 1.5) * self.he

def insalub(self):
if self.insa == True:
return self.remuneracao * 0.15
else:
return 0

def descinss(self):
self.saltot = self.remuneracao + self.hextra() + self.insalub()
if self.saltot <= 1412:
return self.saltot * 0.075
elif self.saltot <= 2666.68:
return (self.saltot * 0.09) - 21.18
elif self.saltot <= 4000.03:
return (self.saltot * 0.12) - 101.18
elif self.saltot > 7786.02:
return (self.saltot * 0.14) - 181.18

def descir(self):
self.saltot = self.remuneracao + self.hextra() + self.insalub()
if self.saltot <= 2259.20:
return 0
elif self.saltot <= 2826.65:
return (self.saltot * 0.075) - 169.44
elif self.saltot <= 3751.05:
return (self.saltot * 0.15) - 381.44
elif self.remuneracao <= 4664.68:
return (self.saltot * 0.225) - 662.77
elif self.saltot > 4664.68:
return (self.saltot * 0.275) - 896

def liquido(self):
return self.remuneracao + self.hextra() + self.insalub() - self.descinss() - self.descir()

def contracheque(self):
return f"Salario Bruto: R${self.remuneracao:.2f}\n(+) Horas Extras: R${self.hextra():.2f}\n(+) Insalubridade: R${self.insalub():.2f}\n(-) INSS: R${self.descinss():.2f}\n(-) IRPF: R${self.descir():.2f}\n\n(=) Salario Liquido: R${self.liquido():.2f}"

salario = float(input("Insira o valor do Salario: "))
hextra = int(input("Insira a quantidade de Horas Extras: "))
ins = input("Tem Insalubridade? Insira Sim ou Nao: ")
insalubridade = False
if ins == "Sim" or ins == "sim":
insalubridade = True

nome = input("Insira o Nome do Colaborador: ")

contcheque = Salario(salario,hextra,insalubridade)

with open(f"Contra-Cheque {nome}.txt","w") as f:
f.write(contcheque.contracheque())

0 comments on commit fc322ed

Please sign in to comment.