{ "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", " | Desde | \n", "Hasta | \n", "Monto | \n", "Tasa | \n", "Impuesto | \n", "
---|---|---|---|---|---|
0 | \n", "0 | \n", "786384 | \n", "786384 | \n", "0.000 | \n", "0 | \n", "
1 | \n", "786384 | \n", "1747440 | \n", "961056 | \n", "0.040 | \n", "38442 | \n", "
2 | \n", "1747440 | \n", "2912400 | \n", "1164960 | \n", "0.080 | \n", "93196 | \n", "
3 | \n", "2912400 | \n", "4077360 | \n", "1164960 | \n", "0.135 | \n", "157269 | \n", "
4 | \n", "4077360 | \n", "5242320 | \n", "1164960 | \n", "0.230 | \n", "267940 | \n", "
5 | \n", "5242320 | \n", "6989760 | \n", "1747440 | \n", "0.304 | \n", "531221 | \n", "
6 | \n", "6989760 | \n", "18056880 | \n", "3010240 | \n", "0.350 | \n", "1053584 | \n", "