def wohngeld_basis_hh(hh_id: IntSeries, wohngeld_basis: FloatSeries) -> FloatSeries:
    """Calculate preliminary housing benefit per household.

    Social benefit for recipients with income above basic social assistance Computation
    is very complicated, accounts for household size, income, actual rent and differs on
    the municipality level ('Mietstufe' (1,...,6)).

    We usually don't have information on the last item. Therefore we assume 'Mietstufe'
    3, corresponding to an average level, but other Mietstufen can be specified in
    `household`.

    Benefit amount depends on parameters `wohngeld_miete` (rent) and
    `wohngeld_eink` (income) (§19 WoGG).

    Parameters
    ----------
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.
    wohngeld_basis
        See :func:`wohngeld_basis`.

    Returns
    -------

    """
    # ToDo: When thinking about calculating wohngeld on the correct level, we need
    # account for multiple tax units in one household. The following is the old code!
    # See #218.
    # out = (wohngeld_basis * tu_vorstand).groupby(hh_id).sum().round(2)
    out = wohngeld_basis.groupby(hh_id).max().round(2)
    return out
Exemple #2
0
def kinderzuschlag_m_hh(
    kinderzuschlag_vermögens_check_hh: FloatSeries,
    kinderzuschlag_vorrang_hh: BoolSeries,
    wohngeld_kinderzuschlag_vorrang_hh: BoolSeries,
    rentner_in_hh: BoolSeries,
) -> FloatSeries:
    """Aggregate child benefit on household level.

    Parameters
    ----------
    kinderzuschlag_vermögens_check_hh
        See :func:`kinderzuschlag_vermögens_check_hh`.
    kinderzuschlag_vorrang_hh
        See :func:`kinderzuschlag_vorrang_hh`.
    wohngeld_kinderzuschlag_vorrang_hh
        See :func:`wohngeld_kinderzuschlag_vorrang_hh`.
    rentner_in_hh
        See :func:`rentner_in_hh`.

    Returns
    -------

    """
    cond = (
        ~kinderzuschlag_vorrang_hh & ~wohngeld_kinderzuschlag_vorrang_hh
    ) | rentner_in_hh
    kinderzuschlag_vermögens_check_hh.loc[cond] = 0
    return kinderzuschlag_vermögens_check_hh
Exemple #3
0
def wohngeld_vermögens_check_hh(
    wohngeld_basis_hh: FloatSeries,
    vermögen_hh: FloatSeries,
    haushaltsgröße_hh: IntSeries,
) -> FloatSeries:
    """Set preliminary housing benefit to zero if it exceeds the wealth exemption.

    The payment depends on the wealth of the household and the number of household
    members.

    60.000 € pro Haushalt + 30.000 € für jedes Mitglied (Verwaltungsvorschrift)

    TODO: Need to write numbers to params.

    Parameters
    ----------
    wohngeld_basis_hh
        See :func:`wohngeld_basis_hh`.
    vermögen_hh
        See basic input variable :ref:`vermögen_hh <vermögen_hh>`.
    haushaltsgröße_hh
        See :func:`haushaltsgröße_hh`.

    Returns
    -------

    """
    condition = vermögen_hh <= (60_000 + (30_000 * (haushaltsgröße_hh - 1)))
    wohngeld_basis_hh.loc[~condition] = 0
    return wohngeld_basis_hh
def wohngeld_m_hh(
    wohngeld_vermögens_check_hh: FloatSeries,
    wohngeld_vorrang_hh: BoolSeries,
    wohngeld_kinderzuschlag_vorrang_hh: BoolSeries,
    rentner_in_hh: BoolSeries,
) -> FloatSeries:
    """Calculate final housing benefit per household.

    Parameters
    ----------
    wohngeld_vermögens_check_hh
        See :func:`wohngeld_vermögens_check_hh`.
    wohngeld_vorrang_hh
        See :func:`wohngeld_vorrang_hh`.
    wohngeld_kinderzuschlag_vorrang_hh
        See :func:`wohngeld_kinderzuschlag_vorrang_hh`.
    rentner_in_hh
        See :func:`rentner_in_hh`.

    Returns
    -------

    """
    cond = ~wohngeld_vorrang_hh & ~wohngeld_kinderzuschlag_vorrang_hh | rentner_in_hh
    wohngeld_vermögens_check_hh.loc[cond] = 0
    return wohngeld_vermögens_check_hh
Exemple #5
0
def wohngeld_vermögens_check_hh(
    wohngeld_basis_hh: FloatSeries,
    vermögen_hh: FloatSeries,
    haushaltsgröße_hh: IntSeries,
    wohngeld_params: dict,
) -> FloatSeries:
    """Set preliminary housing benefit to zero if it exceeds the wealth exemption.

    The payment depends on the wealth of the household and the number of household
    members.

    Parameters
    ----------
    wohngeld_basis_hh
        See :func:`wohngeld_basis_hh`.
    vermögen_hh
        See basic input variable :ref:`vermögen_hh <vermögen_hh>`.
    haushaltsgröße_hh
        See :func:`haushaltsgröße_hh`.
    wohngeld_params
        See params documentation :ref:`wohngeld_params <wohngeld_params>`.

    Returns
    -------

    """
    condition = vermögen_hh <= (wohngeld_params["vermögensfreibetrag_grund"] +
                                (wohngeld_params["vermögensfreibetrag_pers"] *
                                 (haushaltsgröße_hh - 1)))
    wohngeld_basis_hh.loc[~condition] = 0
    return wohngeld_basis_hh
Exemple #6
0
def kinderzuschlag_ab_juli_2019(
    hh_id: IntSeries,
    arbeitsl_geld_2_brutto_eink_hh: FloatSeries,
    kinderzuschlag_eink_min: FloatSeries,
    kinderzuschlag_kindereink_abzug: FloatSeries,
    kinderzuschlag_eink_anrechn: FloatSeries,
) -> FloatSeries:
    """Calculate preliminary child benefit since 07/2019.

    Parameters
    ----------
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.
    arbeitsl_geld_2_brutto_eink_hh
        See :func:`arbeitsl_geld_2_brutto_eink_hh`.
    kinderzuschlag_eink_min
        See :func:`kinderzuschlag_eink_min`.
    kinderzuschlag_kindereink_abzug
        See :func:`kinderzuschlag_kindereink_abzug`.
    kinderzuschlag_eink_anrechn
        See :func:`kinderzuschlag_eink_anrechn`.

    Returns
    -------

    """
    out = hh_id * 0
    condition = hh_id.replace(arbeitsl_geld_2_brutto_eink_hh) >= kinderzuschlag_eink_min
    out.loc[condition] = (
        kinderzuschlag_kindereink_abzug.groupby(hh_id).transform("sum")
        - kinderzuschlag_eink_anrechn
    ).clip(lower=0)

    return out.groupby(hh_id).transform("max")
Exemple #7
0
def kinderzuschlag_ab_2005_bis_juni_2019(
    hh_id: IntSeries,
    kinderzuschlag_eink_spanne: BoolSeries,
    kinderzuschlag_kindereink_abzug: FloatSeries,
    kinderzuschlag_eink_anrechn: FloatSeries,
) -> FloatSeries:
    """Calculate preliminary child benefit since 2005 until 06/2019.

    Parameters
    ----------
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.
    kinderzuschlag_eink_spanne
        See :func:`kinderzuschlag_eink_spanne`.
    kinderzuschlag_kindereink_abzug
        See :func:`kinderzuschlag_kindereink_abzug`.
    kinderzuschlag_eink_anrechn
        See :func:`kinderzuschlag_eink_anrechn`.

    Returns
    -------

    """
    out = kinderzuschlag_eink_spanne * 0
    out.loc[kinderzuschlag_eink_spanne] = (
        kinderzuschlag_kindereink_abzug.groupby(hh_id).transform("sum")
        - kinderzuschlag_eink_anrechn
    ).clip(lower=0)

    return out.groupby(hh_id).transform("max")
Exemple #8
0
def proxy_eink_vorj_elterngeld(
    rentenv_beitr_bemess_grenze: FloatSeries,
    bruttolohn_vorj_m: FloatSeries,
    elterngeld_params: dict,
    eink_st_params: dict,
    eink_st_abzuege_params: dict,
    soli_st_params: dict,
) -> FloatSeries:
    """Calculating the claim for benefits depending on previous wage.

    TODO: This function requires `.fillna(0)` at the end. Investigate!

    Parameters
    ----------
    rentenv_beitr_bemess_grenze
        See :func:`rentenv_beitr_bemess_grenze`.
    bruttolohn_vorj_m
        See basic input variable :ref:`bruttolohn_vorj_m <bruttolohn_vorj_m>`.
    elterngeld_params
        See params documentation :ref:`elterngeld_params <elterngeld_params>`.
    eink_st_params
        See params documentation :ref:`eink_st_params <eink_st_params>`.
    eink_st_abzuege_params
        See params documentation :ref:`eink_st_abzuege_params <eink_st_abzuege_params>`.
    soli_st_params
        See params documentation :ref:`soli_st_params <soli_st_params>`.

    Returns
    -------

    """
    # Relevant wage is capped at the contribution thresholds
    max_wage = bruttolohn_vorj_m.clip(upper=rentenv_beitr_bemess_grenze)

    # We need to deduct lump-sum amounts for contributions, taxes and soli
    prox_ssc = elterngeld_params["elterngeld_soz_vers_pausch"] * max_wage

    # Fictive taxes (Lohnsteuer) are approximated by applying the wage to the tax tariff
    prox_tax = st_tarif(
        (12 * max_wage -
         eink_st_abzuege_params["werbungskostenpauschale"]).clip(lower=0),
        eink_st_params,
    )

    prox_soli = piecewise_polynomial(
        prox_tax,
        thresholds=soli_st_params["soli_st"]["thresholds"],
        rates=soli_st_params["soli_st"]["rates"],
        intercepts_at_lower_thresholds=soli_st_params["soli_st"]
        ["intercepts_at_lower_thresholds"],
    )

    return (max_wage - prox_ssc - prox_tax / 12 - prox_soli / 12).clip(lower=0)
def brutto_eink_1(eink_selbst_m: FloatSeries) -> FloatSeries:
    """Aggregate income gross from self-employment to full year income.

    Parameters
    ----------
    eink_selbst_m
        See basic input variable :ref:`eink_selbst_m <eink_selbst_m>`.

    Returns
    -------

    """
    return 12 * eink_selbst_m.clip(lower=0)
def proxy_eink_vorj_arbeitsl_geld(
    rentenv_beitr_bemess_grenze: FloatSeries,
    bruttolohn_vorj_m: FloatSeries,
    arbeitsl_geld_params: dict,
    eink_st_params: dict,
    eink_st_abzuege_params: dict,
    soli_st_params: dict,
) -> FloatSeries:
    """Approximate last years income for unemployment benefit.

    Parameters
    ----------
    rentenv_beitr_bemess_grenze
        See :func:`rentenv_beitr_bemess_grenze`.
    bruttolohn_vorj_m
        See basic input variable :ref:`bruttolohn_vorj_m <bruttolohn_vorj_m>`.
    arbeitsl_geld_params
        See params documentation :ref:`arbeitsl_geld_params <arbeitsl_geld_params>`.
    eink_st_params
        See params documentation :ref:`eink_st_params <eink_st_params>`.
    eink_st_abzuege_params
        See params documentation :ref:`eink_st_abzuege_params <eink_st_abzuege_params>`.
    soli_st_params
        See params documentation :ref:`soli_st_params <soli_st_params>`.

    Returns
    -------

    """
    # Relevant wage is capped at the contribution thresholds
    max_wage = bruttolohn_vorj_m.clip(lower=None, upper=rentenv_beitr_bemess_grenze)

    # We need to deduct lump-sum amounts for contributions, taxes and soli
    prox_ssc = arbeitsl_geld_params["soz_vers_pausch_arbeitsl_geld"] * max_wage

    # Fictive taxes (Lohnsteuer) are approximated by applying the wage to the tax tariff
    prox_tax = st_tarif(
        12 * max_wage - eink_st_abzuege_params["werbungskostenpauschale"],
        eink_st_params,
    )
    prox_soli = piecewise_polynomial(
        prox_tax,
        thresholds=soli_st_params["soli_st"]["thresholds"],
        rates=soli_st_params["soli_st"]["rates"],
        intercepts_at_lower_thresholds=soli_st_params["soli_st"][
            "intercepts_at_lower_thresholds"
        ],
    )

    return (max_wage - prox_ssc - prox_tax / 12 - prox_soli / 12).clip(lower=0)
def sonstig_eink_m_tu(sonstig_eink_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate additional per tax unit.

    Parameters
    ----------
    sonstig_eink_m
        See basic input variable :ref:`sonstig_eink_m <sonstig_eink_m>`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return sonstig_eink_m.groupby(tu_id).sum()
Exemple #12
0
def unterhaltsvors_m_tu(unterhaltsvors_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate monthly child support advance payment on tax unit level.


    Parameters
    ----------
    unterhaltsvors_m
        See :func:`unterhaltsvors_m`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.
    Returns
    -------

    """
    return unterhaltsvors_m.groupby(tu_id).sum()
def brutto_eink_4_tu(brutto_eink_4: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate gross income of non selfemployed work on tax unit level.

    Parameters
    ----------
    brutto_eink_4
        See :func:`brutto_eink_4`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return brutto_eink_4.groupby(tu_id).sum()
Exemple #14
0
def ges_rente_m_tu(ges_rente_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate monthly pension payment on tax unit level.

    Parameters
    ----------
    ges_rente_m
        See basic input variable :ref:`ges_rente_m <ges_rente_m>`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return ges_rente_m.groupby(tu_id).sum()
Exemple #15
0
def unterhaltsvors_m_hh(unterhaltsvors_m: FloatSeries, hh_id: IntSeries) -> FloatSeries:
    """Aggregate monthly child support advance payment on household level.

    Parameters
    ----------
    unterhaltsvors_m
        See :func:`unterhaltsvors_m`.
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.

    Returns
    -------

    """
    return unterhaltsvors_m.groupby(hh_id).sum()
Exemple #16
0
def vermiet_eink_m_tu(vermiet_eink_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate monthly rental income on tax unit level.

    Parameters
    ----------
    vermiet_eink_m
        See basic input variable :ref:`vermiet_eink_m <vermiet_eink_m>`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return vermiet_eink_m.groupby(tu_id).sum()
Exemple #17
0
def kapital_eink_m_tu(kapital_eink_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate monthly capital income on tax unit level.

    Parameters
    ----------
    kapital_eink_m
        See basic input variable :ref:`kapital_eink_m <kapital_eink_m>`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return kapital_eink_m.groupby(tu_id).sum()
def brutto_eink_7_tu(brutto_eink_7: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate yearly gross pension income subject to taxation on tax unit level.

    Parameters
    ----------
    brutto_eink_7
        See :func:`brutto_eink_7`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return brutto_eink_7.groupby(tu_id).sum()
Exemple #19
0
def eink_selbst_m_tu(eink_selbst_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate monthly self employed income on tax unit level.

    Parameters
    ----------
    eink_selbst_m
        See basic input variable :ref:`eink_selbst_m <eink_selbst_m>`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return eink_selbst_m.groupby(tu_id).sum()
Exemple #20
0
def elterngeld_m_hh(elterngeld_m: FloatSeries,
                    hh_id: IntSeries) -> FloatSeries:
    """Aggregate parental leave benefit on household level.

    Parameters
    ----------
    elterngeld_m
        See :func:`elterngeld_m`.
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.
    Returns
    -------

    """
    return elterngeld_m.groupby(hh_id).sum()
def arbeitsl_geld_m_hh(arbeitsl_geld_m: FloatSeries, hh_id: IntSeries) -> FloatSeries:
    """Aggregate unemployment benefit on household level.

    Parameters
    ----------
    arbeitsl_geld_m
        See :func:`arbeitsl_geld_m`.
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.

    Returns
    -------

    """
    return arbeitsl_geld_m.groupby(hh_id).sum()
def brutto_eink_5_tu(brutto_eink_5: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate yearly gross capital income on tax unit level.

    Parameters
    ----------
    brutto_eink_5
        See :func:`brutto_eink_5`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return brutto_eink_5.groupby(tu_id).sum()
Exemple #23
0
def arbeitsl_geld_2_brutto_eink_hh(arbeitsl_geld_2_brutto_eink: FloatSeries,
                                   hh_id: IntSeries) -> FloatSeries:
    """Sum up the income before tax per household for calculation of basic subsistence.
    Parameters
    ----------
    arbeitsl_geld_2_brutto_eink
        See :func:`arbeitsl_geld_2_brutto_eink`.
    hh_id
        See basic input variable :ref:`hh_id <hh_id>`.

    Returns
    -------
    Float Series with the income of a person by unemployment insurance before tax.
    """
    return arbeitsl_geld_2_brutto_eink.groupby(hh_id).sum()
def arbeitsl_geld_m_tu(arbeitsl_geld_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate unemployment benefit on tax unit level.

    Parameters
    ----------
    arbeitsl_geld_m
        See :func:`arbeitsl_geld_m`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return arbeitsl_geld_m.groupby(tu_id).sum()
Exemple #25
0
def kinderbonus_m_tu(kinderbonus_m: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate Kinderbonus on the tax unit level.

    Parameters
    ----------
    kinderbonus_m
        See :func:`kinderbonus_m`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return kinderbonus_m.groupby(tu_id).sum()
def wohngeld_eink_abzüge_bis_2015(
    bruttolohn_m: FloatSeries,
    arbeitende_kinder: IntSeries,
    behinderungsgrad: IntSeries,
    alleinerziehend: BoolSeries,
    kind: BoolSeries,
    anzahl_kinder_unter_11_per_tu: IntSeries,
    wohngeld_params: dict,
):
    """Calculate housing benefit subractions until 2015.

    Parameters
    ----------
    bruttolohn_m
        See basic input variable :ref:`bruttolohn_m <bruttolohn_m>`.
    arbeitende_kinder
        See :func:`arbeitende_kinder`.
    behinderungsgrad
        See basic input variable :ref:`behinderungsgrad <behinderungsgrad>`.
    alleinerziehend
        See basic input variable :ref:`alleinerziehend <alleinerziehend>`.
    kind
        See basic input variable :ref:`kind <kind>`.
    anzahl_kinder_unter_11_per_tu
        See :func:`anzahl_kinder_unter_11_per_tu`.
    wohngeld_params
        See params documentation :ref:`wohngeld_params <wohngeld_params>`.

    Returns
    -------

    """
    abzüge = (
        (behinderungsgrad > 80) * wohngeld_params["freib_behinderung"]["ab80"]
        + ((1 <= behinderungsgrad) & (behinderungsgrad <= 80))
        * wohngeld_params["freib_behinderung"]["u80"]
        + (
            arbeitende_kinder
            * bruttolohn_m.clip(lower=None, upper=wohngeld_params["freib_kinder"][24])
        )
        + (
            (alleinerziehend & ~kind)
            * anzahl_kinder_unter_11_per_tu
            * wohngeld_params["freib_kinder"][12]
        )
    )

    return abzüge
def brutto_eink_1_tu(brutto_eink_1: FloatSeries, tu_id: IntSeries) -> FloatSeries:
    """Aggregate income gross from self-employment on tax unit level.


    Parameters
    ----------
    brutto_eink_1
        See :func:`brutto_eink_1`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return brutto_eink_1.groupby(tu_id).sum()
Exemple #28
0
def bruttolohn_m_tu(bruttolohn_m: FloatSeries,
                    tu_id: IntSeries) -> FloatSeries:
    """Sum monthly wages in tax unit.

    Parameters
    ----------
    bruttolohn_m
        See basic input variable :ref:`bruttolohn_m <bruttolohn_m>`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------
    FloatSeries with sum of monthly wages per tax unit.
    """
    return bruttolohn_m.groupby(tu_id).sum()
Exemple #29
0
def kindergeld_m_tu_basis(kindergeld_m_basis: FloatSeries,
                          tu_id: IntSeries) -> FloatSeries:
    """Aggregate the preliminary kindergeld on tax unit level.

    Parameters
    ----------
    kindergeld_m_basis
        See :func:`kindergeld_m_basis`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return kindergeld_m_basis.groupby(tu_id).sum()
Exemple #30
0
def elterngeld_m_tu(elterngeld_m: FloatSeries,
                    tu_id: IntSeries) -> FloatSeries:
    """Aggregate parental leave benefit on tax unit level.

    Parameters
    ----------
    elterngeld_m
        See :func:`elterngeld_m`.
    tu_id
        See basic input variable :ref:`tu_id <tu_id>`.

    Returns
    -------

    """
    return elterngeld_m.groupby(tu_id).sum()