{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from impuestos import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "786384 0\n", "1747440 0.04\n" ] } ], "source": [ "sueldo_bruto = 1_200_000\n", "\n", "impuesto = 0\n", "for tramo, rate in TRAMOS.items():\n", " print(tramo, rate)\n", " delta = sueldo_bruto - tramo\n", " if delta < 0:\n", " break\n", " impuesto += delta*rate" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[786384, 1747440, 2912400, 4077360, 5242320, 6989760, 18056880, 99999999]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(TRAMOS.keys())" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "def descomponer_en_tramos(sueldo_bruto, tramos=TRAMOS):\n", " descomp = []\n", " impuestos = []\n", " tramo_anterior = 0\n", " for tramo, descuento in tramos.items():\n", " delta = min(sueldo_bruto, tramo) - tramo_anterior\n", " if delta>0:\n", " descomp.append(delta)\n", " impuestos.append(int(delta*descuento))\n", " tramo_anterior = tramo\n", " return descomp, impuestos" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "([786384, 413616], [0, 16544])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sueldo_bruto = 1_200_000\n", "descomponer_en_tramos(sueldo_bruto, TRAMOS)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "def get_table(sueldo_bruto, tramos=TRAMOS):\n", " _tramos = [0]+list(tramos.keys())\n", " tasas = tramos.values()\n", " data = [[desde, hasta, monto, tasa, impuesto] for desde, hasta, tasa, monto, impuesto in zip(_tramos[:-1], _tramos[1:], tasas, *descomponer_en_tramos(sueldo_bruto))]\n", " df = pd.DataFrame(data=data, columns=[\"Desde\", \"Hasta\", \"Monto\", \"Tasa\", \"Impuesto\"])\n", " return df" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DesdeHastaMontoTasaImpuesto
007863847863840.0000
178638417474409610560.04038442
21747440291240011649600.08093196
32912400407736011649600.135157269
44077360524232011649600.230267940
55242320698976017474400.304531221
669897601805688030102400.3501053584
\n", "
" ], "text/plain": [ " Desde Hasta Monto Tasa Impuesto\n", "0 0 786384 786384 0.000 0\n", "1 786384 1747440 961056 0.040 38442\n", "2 1747440 2912400 1164960 0.080 93196\n", "3 2912400 4077360 1164960 0.135 157269\n", "4 4077360 5242320 1164960 0.230 267940\n", "5 5242320 6989760 1747440 0.304 531221\n", "6 6989760 18056880 3010240 0.350 1053584" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "get_table(10000000)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.2 ('st')", "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.10.2" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "885b610356171de8141a812cff200370cfd21ab3bf3d712138f61360bb82c1dd" } } }, "nbformat": 4, "nbformat_minor": 2 }