Created
August 2, 2021 18:32
-
-
Save alonsosilvaallende/5b0fe4885d746780547ed2d8d1bc04a0 to your computer and use it in GitHub Desktop.
Taxes.ipynb
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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Taxes.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyMApkh0MkYRa+PYpkPFST1p", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/alonsosilvaallende/5b0fe4885d746780547ed2d8d1bc04a0/taxes.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "kzaszBuvGkzU" | |
}, | |
"source": [ | |
"import numpy as np" | |
], | |
"execution_count": 1, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "jVNRgqquG_Fz" | |
}, | |
"source": [ | |
"def impot(s):\n", | |
" T1 = 10084\n", | |
" T2 = 25710\n", | |
" T3 = 73516\n", | |
" T4 = 158122\n", | |
" total = 0\n", | |
" if s>T1 and s<=T2:\n", | |
" total = (s-T1)*0.11\n", | |
" elif s>T2 and s<=T3:\n", | |
" total = (T2-T1)*0.11 + (s-T2)*0.3\n", | |
" elif s>T3 and s<=T4:\n", | |
" total = (T2-T1)*0.11 + (T3-T2)*0.3 + (s-T3)*0.41\n", | |
" elif s>T4:\n", | |
" total = (T2-T1)*0.11 + (T3-T2)*0.3 + (T4-T3)*0.41 + (s-T4)*0.45\n", | |
" return total" | |
], | |
"execution_count": 2, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "06FD-88XIQnZ" | |
}, | |
"source": [ | |
"def impot_total(NetFiscal1, NetFiscal2, Nombre_de_parts):\n", | |
" # Abattement\n", | |
" nf1 = np.round(NetFiscal1*.9)\n", | |
" nf2 = np.round(NetFiscal2*.9)\n", | |
" if nf1 == 0 and nf2 == 0:\n", | |
" return 0\n", | |
" else:\n", | |
" a = 2*impot((nf1+nf2)/2)-1551*2*(Nombre_de_parts-2)\n", | |
" b = Nombre_de_parts * impot((nf1+nf2)/Nombre_de_parts)\n", | |
" return np.round(np.max([a,b]))" | |
], | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "NW3SHl2WIWhQ" | |
}, | |
"source": [ | |
"Nombre_de_parts = 2.5 #@param {type:\"slider\", min:1, max:4, step:0.5}\n", | |
"NetFiscal1 = 40000 #@param {type:\"number\"}\n", | |
"NetFiscal2 = 40000 #@param {type:\"number\"}\n", | |
"if NetFiscal1 is None or NetFiscal2 is None or NetFiscal1<0 or NetFiscal2<0:\n", | |
" print('Provide a positive number and try again.')\n" | |
], | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "avmUN3VbIZvc", | |
"outputId": "cf9d0310-f4fe-4c9a-8a8b-f8669ab5832f" | |
}, | |
"source": [ | |
"print(\"Taxes :\", impot_total(NetFiscal1, NetFiscal2, Nombre_de_parts))" | |
], | |
"execution_count": 5, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Taxes : 8061.0\n" | |
], | |
"name": "stdout" | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment