Código fuente para impar._impuestos.ganancias.ganancias_20131229

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# "THE WISKEY-WARE LICENSE":
# <jbc.develop@gmail.com> and <nluczywo@gmail.com> wrote this file.
# As long as you retain this notice you can do whatever you want with this stuff.
# If we meet some day, and you think this stuff is worth it, you can buy me a
# WISKEY in return Juan BC and Nadia AL


#===============================================================================
# DOCS
#===============================================================================

"""Funciones de calculo de impuesto a las ganacias

"""


#===============================================================================
# CONSTANTS
#===============================================================================

#: Categoria 1 (alquileres) de impuesto a las ganancias
CAT_ALQUILERES = 1

#: Categoria 2 (títulos) de impuesto a las ganancias
CAT_TITULOS = 2

#: Categoria 3 (empresa) de impuesto a las ganancias
CAT_EMPRESA = 3

#: Categoria 4 (empleado) de impuesto a las ganancias
CAT_EMPLEADO = 4

#: Tiempo minimo de permanencia en el pais para aplicar el impuesto
TIEMPO_MIN_PERMANENCIA_MESES = 6

#: Valor de la ganancia no imponible
GANANCIA_NO_IMPONIBLE = 15960.0

#: Valor de la ganancia no imponible para empleado
GANANCIA_NO_IMPONIBLE_CATEGORIA_4 = GANANCIA_NO_IMPONIBLE * 4.8

#: Alicuota exclusiva para categoria empresas
ALICUOTA_EMPRESA = lambda x: x * 0.35 if x > 0 else 0

#: Alicuota para cat 1, 2 y 4 (min, max, calculador)
ALICUOTAS = [
    [0, 60000,
        lambda x: x * 0.14],
    [60000, 90000,
        lambda x: (60000 * 0.14) + ((x - 60000) * 0.23)],
    [90000, 150000,
        lambda x: (60000 * 0.14) + (30000 * 0.23) + ((x - 90000) * 0.27)],
    [150000, None ,
        lambda x: (60000 * 0.14) + (30000 * 0.23) + (60000 * 0.27) + ((x - 150000) * 0.35) ],
]


#: Deduccion por conyugue
DEDUCCION_FIJA_CONYUGUE = 8400.0

#: Deduccion por hijo
DEDUCCION_FIJA_HIJO = 7200.0

#: Deduccion por familiar
DEDUCCION_FIJA_FAMILIAR = 7200.0

#: Deduccion máxima por sepelio
DEDUCCION_TOPE_SEPELIO = 969.25

#: Deduccion máxima por seguro de vida
DEDUCCION_TOPE_SEGUROS_DE_VIDA = 969.25

#: Deduccion máxima por seguro de retiro
DEDUCCION_TOPE_SEGUROS_DE_RETIRO = 969.25

#: Coeficiente de calculo de deduccion máxima por seguro médico
DEDUCCION_VARIABLE_SEGURO_MEDICO = 0.05

#: Coeficiente de calculo de deduccion máxima por honorario médico
DEDUCCION_VARIABLE_HONORARIO_MEDICO = 0.05

#: Máximo número de quebrantos soportados en la ley
MAX_QUEBRANTOS = 5


#===============================================================================
# FUNCTIONS
#===============================================================================

[documentos]def ganancias(monto, cat, deducciones_fijas=(), seguros_medico=0, honorarios_medico=0, sepelios=0, seguros_de_vida=0, seguros_de_retiro=0, intereses_hipotecarios_vivienda_propia=0, tiempo_permanencia_pais_meses=0): """Calcula el impuesto a las ganancias para una categora dada """ if cat not in (CAT_ALQUILERES, CAT_TITULOS, CAT_EMPRESA, CAT_EMPLEADO): raise ValueError(u"Categoría '{}' inexistente".format(cat)) monto = float(monto) impuesto_a_pagar = 0.0 if cat == CAT_EMPRESA: impuesto_a_pagar = ALICUOTA_EMPRESA(monto) else: if tiempo_permanencia_pais_meses >= TIEMPO_MIN_PERMANENCIA_MESES: monto -= GANANCIA_NO_IMPONIBLE if cat == CAT_EMPLEADO: monto -= GANANCIA_NO_IMPONIBLE_CATEGORIA_4 for deduc in deducciones_fijas: monto -= deduc monto -= min(monto * DEDUCCION_VARIABLE_SEGURO_MEDICO, seguros_medico) monto -= min(monto * DEDUCCION_VARIABLE_HONORARIO_MEDICO, honorarios_medico) monto -= min(sepelios, DEDUCCION_TOPE_SEPELIO) monto -= min(seguros_de_vida, DEDUCCION_TOPE_SEGUROS_DE_VIDA) monto -= min(seguros_de_retiro, DEDUCCION_TOPE_SEGUROS_DE_RETIRO) monto -= intereses_hipotecarios_vivienda_propia if monto > 0: for linf, lsup, calc in ALICUOTAS: lsup = lsup or monto if monto > linf and monto <= lsup: impuesto_a_pagar = calc(monto) break return impuesto_a_pagar
[documentos]def ganancias_empresa_con_quebrantos(quebrantos, *args, **kwargs): """Calcula el impuesto a las ganancias para empresas con impuestos con qubrantos """ if len(quebrantos) >= MAX_QUEBRANTOS: raise ValueError("Se soporta un maximo de 5 quebrantos") impuesto_a_pagar = impuesto_a_las_ganancias(*args, cat=CAT_EMPRESA, **kwargs) qresultados = [] for q in quebrantos: qresultado = 0.0 if impuesto_a_pagar > 0 and q > impuesto_a_pagar: qresultado = q - impuesto_a_pagar elif impuesto_a_pagar > 0 and q <= impuesto_a_pagar: qresultado = 0 elif impuesto_a_pagar <= 0: qresultado = q if impuesto_a_pagar > 0: impuesto_a_pagar = impuesto_a_pagar - q if impuesto_a_pagar < 0: impuesto_a_pagar = 0.0 return impuesto_a_pagar, qresultados #=============================================================================== # TEST #===============================================================================
def _test(): pass #=============================================================================== # MAIN #=============================================================================== if __name__ == "__main__": print(__doc__)
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.