Skip to content

Commit 9f04722

Browse files
MImmesbergerChristian Zimpelmann
andauthored
Unterhaltsvorschuss calculation on child level. (#739)
Closes #735 --------- Co-authored-by: Christian Zimpelmann <[email protected]>
1 parent 6c234b2 commit 9f04722

File tree

8 files changed

+80
-31
lines changed

8 files changed

+80
-31
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ releases are available on [Anaconda.org](https://anaconda.org/conda-forge/gettsi
66

77
## Unpublished
88

9+
- {gh}`739` Unterhaltsvorschuss calculation on child level ({ghuser}`MImmesberger`).
910
- {gh}`722` Join columns to make target columns available at source level
1011
({ghuser}`lars-reimann`).
1112
- {gh}`732` Change wealth input variable to individual-level (`vermögen_bedürft`)

docs/gettsim_objects/input_variables.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ Type: float
477477
## `m_alg1_übergang`
478478

479479
Total months of unemployment (only timeof Entgeltersatzleistungen, not ALGII),i.e.
480-
Arbeitslosengeld, Unterhaltsgeld,Übergangsgeld
480+
Arbeitslosengeld, Unterhaltsgeld, Übergangsgeld
481481

482482
Type: float
483483

@@ -599,13 +599,14 @@ Type: float
599599

600600
## `kind_unterh_anspr_m`
601601

602-
Monthly gross child alimony payments to be received as determined by the court
602+
Monthly gross child alimony payments to be received as determined by the court on child
603+
level
603604

604605
Type: float
605606

606607
## `kind_unterh_erhalt_m`
607608

608-
Monthly actual child alimony payments received
609+
Monthly actual child alimony payments received on child level
609610

610611
Type: float
611612

src/_gettsim/transfers/unterhaltsvors.py

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@
66
from _gettsim.shared import join_numpy, policy_info
77

88
aggregate_by_p_id_unterhaltsvors = {
9-
"_unterhaltsvors_anspruch_eltern_m": {
9+
"unterhaltsvors_zahlbetrag_eltern_m": {
1010
"p_id_to_aggregate_by": "p_id_kindergeld_empf",
11-
"source_col": "_unterhaltsvors_anspruch_pro_kind_m",
11+
"source_col": "unterhaltsvors_m",
1212
"aggr": "sum",
1313
},
1414
}
1515

1616

1717
@policy_info(params_key_for_rounding="unterhaltsvors")
1818
def unterhaltsvors_m(
19-
alleinerz: bool,
2019
kind_unterh_erhalt_m: float,
21-
_unterhaltsvors_anspruch_eltern_m: float,
20+
_unterhaltsvors_anspruch_kind_m: float,
21+
parent_alleinerz: bool,
2222
) -> float:
23-
"""Advance alimony payments (Unterhaltsvorschuss).
23+
"""Advance alimony payments (Unterhaltsvorschuss) on child level after deducting
24+
alimonies.
2425
2526
Single Parents get alimony payments for themselves and for their child from the ex
2627
partner. If the ex partner is not able to pay the child alimony, the government pays
@@ -38,26 +39,53 @@ def unterhaltsvors_m(
3839
3940
Parameters
4041
----------
41-
alleinerz
42-
See basic input variable :ref:`alleinerz <alleinerz>`.
4342
kind_unterh_erhalt_m
4443
See :func:`kind_unterh_erhalt_m`.
45-
_unterhaltsvors_anspruch_eltern_m
46-
See :func:`_unterhaltsvors_anspruch_eltern_m`.
44+
_unterhaltsvors_anspruch_kind_m
45+
See :func:`_unterhaltsvors_anspruch_kind_m`.
46+
parent_alleinerz
47+
See :func:`parent_alleinerz`.
4748
4849
Returns
4950
-------
5051
5152
"""
52-
53-
if alleinerz:
54-
out = max(_unterhaltsvors_anspruch_eltern_m - kind_unterh_erhalt_m, 0.0)
53+
if parent_alleinerz:
54+
out = max(_unterhaltsvors_anspruch_kind_m - kind_unterh_erhalt_m, 0.0)
5555
else:
5656
out = 0.0
5757

5858
return out
5959

6060

61+
@policy_info(skip_vectorization=True)
62+
def parent_alleinerz(
63+
p_id_kindergeld_empf: np.ndarray[int],
64+
p_id: np.ndarray[int],
65+
alleinerz: np.ndarray[bool],
66+
) -> np.ndarray[bool]:
67+
"""Check if parent that receives Unterhaltsvorschuss is a single parent.
68+
69+
Only single parents receive Unterhaltsvorschuss.
70+
71+
Parameters
72+
----------
73+
p_id_kindergeld_empf
74+
See basic input variable :ref:`p_id_kindergeld_empf`.
75+
p_id
76+
See basic input variable :ref:`p_id`.
77+
alleinerz
78+
See basic input variable :ref:`alleinerz`.
79+
80+
Returns
81+
-------
82+
83+
"""
84+
return join_numpy(
85+
p_id_kindergeld_empf, p_id, alleinerz, value_if_foreign_key_is_missing=False
86+
)
87+
88+
6189
@policy_info(start_date="2023-01-01", name_in_dag="_kindergeld_erstes_kind_m")
6290
def _kindergeld_erstes_kind_ohne_staffelung_m(
6391
kindergeld_params: dict,
@@ -102,14 +130,14 @@ def _kindergeld_erstes_kind_gestaffelt_m(
102130
return kindergeld_params["kindergeld"][1]
103131

104132

105-
def _unterhaltsvors_anspruch_pro_kind_m(
133+
def _unterhaltsvors_anspruch_kind_m(
106134
alter: int,
107135
_unterhaltsvorschuss_empf_eink_above_income_threshold: bool,
108136
_kindergeld_erstes_kind_m: float,
109137
unterhalt_params: dict,
110138
unterhaltsvors_params: dict,
111139
) -> float:
112-
"""Claim for advance on alimony payment (Unterhaltsvorschuss) per child.
140+
"""Claim for advance on alimony payment (Unterhaltsvorschuss) on child level.
113141
114142
Parameters
115143
----------
@@ -157,7 +185,8 @@ def _unterhaltsvorschuss_empf_eink_above_income_threshold(
157185
p_id: np.ndarray[int],
158186
_unterhaltsvorschuss_eink_above_income_threshold: np.ndarray[bool],
159187
) -> np.ndarray[bool]:
160-
"""Income of Unterhaltsvorschuss recipient above threshold.
188+
"""Income of Unterhaltsvorschuss recipient above threshold (this variable is
189+
defined on child level).
161190
162191
Parameters
163192
----------

src/_gettsim_tests/test_data/unterhaltsvors/2018-1/hh_id_5.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ inputs:
6060
- 0.0
6161
assumed: {}
6262
outputs:
63+
parent_alleinerz:
64+
- false
65+
- true
6366
unterhaltsvors_m:
64-
- 205
65-
- 0
67+
- 0.0
68+
- 205.0

src/_gettsim_tests/test_data/unterhaltsvors/2019-1/older_child_parent_with_income.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ inputs:
7878
- 0.0
7979
assumed: {}
8080
outputs:
81+
parent_alleinerz:
82+
- false
83+
- true
84+
- true
8185
unterhaltsvors_m:
82-
- 494
83-
- 0
84-
- 0
86+
- 0.0
87+
- 212.0
88+
- 282.0

src/_gettsim_tests/test_data/unterhaltsvors/2019-1/older_child_parent_without_income.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ inputs:
7878
- 0.0
7979
assumed: {}
8080
outputs:
81+
parent_alleinerz:
82+
- false
83+
- true
84+
- true
8185
unterhaltsvors_m:
82-
- 212
83-
- 0
84-
- 0
86+
- 0.0
87+
- 212.0
88+
- 0.0

src/_gettsim_tests/test_data/unterhaltsvors/2019-1/young_child_parent_without_income.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ inputs:
7878
- 0.0
7979
assumed: {}
8080
outputs:
81+
parent_alleinerz:
82+
- false
83+
- true
84+
- true
8185
unterhaltsvors_m:
82-
- 372
83-
- 0
84-
- 0
86+
- 0.0
87+
- 160.0
88+
- 212.0

src/_gettsim_tests/test_data/unterhaltsvors/2019-8/hh_id_1.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ inputs:
6060
- 0.0
6161
assumed: {}
6262
outputs:
63+
parent_alleinerz:
64+
- false
65+
- true
6366
unterhaltsvors_m:
64-
- 202
65-
- 0
67+
- 0.0
68+
- 202.0

0 commit comments

Comments
 (0)