Skip to content

Commit

Permalink
Huurtoeslag (#31)
Browse files Browse the repository at this point in the history
Add huurtoeslag

🤖 Generated with Claude Code
Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
anneschuth and pre-commit-ci[bot] authored Feb 24, 2025
1 parent 08dbc7c commit b4f4ac6
Show file tree
Hide file tree
Showing 67 changed files with 3,152 additions and 1,821 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ repos:
rev: v1.36.4
hooks:
- id: djlint-reformat-jinja
types_or: [ "html" ]

- repo: local
hooks:
- id: validate-schema
Expand Down
21 changes: 21 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Machine Law Codebase Guidelines

## Commands
- Run all tests: `uv run behave features --no-capture -v --define log_level=DEBUG`
- Run specific feature: `uv run behave features/zorgtoeslag.feature`
- Lint code: `ruff check` and `ruff format`
- Run pre-commit hooks: `pre-commit run --all-files`
- Validate schemas: `./script/validate`
- Run web interface: `uv run web/main.py` (available at http://0.0.0.0:8000)
- Run simulations: `uv run simulate.py`

## Code Style
- Python 3.12+
- Indentation: 4 spaces (Python), 2 spaces (YAML)
- Line length: 120 characters
- Naming: snake_case (variables/functions), PascalCase (classes), UPPER_CASE (constants)
- Imports: stdlib → third-party → local, sorted alphabetically within groups
- Type annotations: required for all function parameters and return values
- Error handling: specific exceptions, contextual logging, fallback values
- YAML: structured hierarchies with explicit types for law definitions
- Architecture: modular, service-oriented with event-driven components
20 changes: 10 additions & 10 deletions analysis/graph/src/app.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!doctype html>
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
50 changes: 50 additions & 0 deletions features/huurtoeslag.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Feature: Berekening Huurtoeslag
Als burger
Wil ik weten of ik recht heb op huurtoeslag
Zodat ik de juiste toeslag kan ontvangen

Background:
Given de datum is "2025-02-01"

Scenario: Persoon onder 18 heeft geen recht op huurtoeslag
Given een persoon met BSN "111111111"
And de volgende RvIG personen gegevens:
| bsn | geboortedatum | verblijfsadres | land_verblijf |
| 111111111 | 2008-01-01 | Voorstraat 1, Utrecht | NEDERLAND |
And de volgende RvIG relaties gegevens:
| bsn | partnerschap_type | partner_bsn |
| 111111111 | GEEN | null |
And met een kale huur 500 en servicekosten 40 waarvan 40 meetellen
When de wet_op_de_huurtoeslag wordt uitgevoerd door TOESLAGEN
Then is niet voldaan aan de voorwaarden

Scenario: Alleenstaande met laag inkomen en hogere huur
Given een persoon met BSN "222222222"
And de volgende RvIG personen gegevens:
| bsn | geboortedatum | verblijfsadres | land_verblijf |
| 222222222 | 1990-01-01 | Voorstraat 1, Utrecht | NEDERLAND |
And de volgende RvIG relaties gegevens:
| bsn | partnerschap_type | partner_bsn |
| 222222222 | GEEN | null |
And de volgende BELASTINGDIENST box1 gegevens:
| bsn | loon_uit_dienstbetrekking |
| 222222222 | 1400000 |
And met een kale huur 720 en servicekosten 50 waarvan 48 meetellen
When de wet_op_de_huurtoeslag wordt uitgevoerd door TOESLAGEN
Then heeft de persoon recht op huurtoeslag
And is de huurtoeslag "89.60" euro

Scenario: Te hoog inkomen voor huurtoeslag
Given een persoon met BSN "333333333"
And de volgende RvIG personen gegevens:
| bsn | geboortedatum | verblijfsadres | land_verblijf |
| 333333333 | 1980-01-01 | Voorstraat 1, Utrecht | NEDERLAND |
And de volgende RvIG relaties gegevens:
| bsn | partnerschap_type | partner_bsn |
| 333333333 | GEEN | null |
And de volgende BELASTINGDIENST box1 gegevens:
| bsn | loon_uit_dienstbetrekking |
| 333333333 | 4500000 |
And met een kale huur 650 en servicekosten 50 waarvan 48 meetellen
When de wet_op_de_huurtoeslag wordt uitgevoerd door TOESLAGEN
Then is niet voldaan aan de voorwaarden
29 changes: 28 additions & 1 deletion features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def step_impl(context, service, table):
data = []
for row in context.table:
processed_row = {
k: v if k in {"bsn", "partner_bsn", "jaar"} else parse_value(v)
k: v if k in {"bsn", "partner_bsn", "jaar", "kind_bsn"} else parse_value(v)
for k, v in row.items()
}
data.append(processed_row)
Expand Down Expand Up @@ -372,3 +372,30 @@ def step_impl(context):
bsn=context.parameters["BSN"]
)
context.claim_id = claim_id


@then("heeft de persoon recht op huurtoeslag")
def step_impl(context):
"""
:type context: behave.runner.Context
"""
assertions.assertTrue(
context.result.requirements_met,
"Persoon heeft toch geen recht op huurtoeslag",
)


@given("met een kale huur {rent} en servicekosten {service_costs} waarvan {eligible_service_costs} meetellen")
def step_impl(context, rent, service_costs, eligible_service_costs):
"""
:type context: behave.runner.Context
"""
context.parameters["RENT_AMOUNT"] = int(rent) * 100
context.parameters["SERVICE_COSTS"] = int(service_costs) * 100
context.parameters["ELIGIBLE_SERVICE_COSTS"] = int(eligible_service_costs) * 100


@then('is de huurtoeslag "{amount}" euro')
def step_impl(context, amount):
actual_amount = context.result.output["subsidy_amount"]
compare_euro_amount(actual_amount, amount)
2 changes: 1 addition & 1 deletion law/algemene_ouderdomswet/SVB-2024-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: 13dc8a31-91eb-4598-998c-012c9129b9ea
name: AOW-uitkering
law: algemene_ouderdomswet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: 47fa262a-b8f7-43bf-a5dd-5f9b2d2c1228
name: Bepalen AOW-leeftijd 2025
law: algemene_ouderdomswet/leeftijdsbepaling
Expand Down
2 changes: 1 addition & 1 deletion law/awb/beroep/JenV-2024-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: c4fda809-15f2-454a-9e9b-f645b905ca12
name: Algemene wet bestuursrecht - Beroepmogelijkheid en Termijnen
law: awb/beroep
Expand Down
2 changes: 1 addition & 1 deletion law/awb/bezwaar/JenV-2024-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: b6679cca-4555-44b4-9b8f-caa6886b74a0
name: Algemene wet bestuursrecht - Bezwaarmogelijkheid en Termijnen
law: awb/bezwaar
Expand Down
2 changes: 1 addition & 1 deletion law/handelsregisterwet/KVK-2024-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: 8b59ef92-03f8-4294-bce9-4eaac01ba0ed
name: Bepalen ondernemerschap
law: handelsregisterwet
Expand Down
2 changes: 1 addition & 1 deletion law/kieswet/KIESRAAD-2024-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: 96d926a0-b45f-4cf3-92af-01b167221a00
name: Kiesrecht Tweede Kamer
law: kieswet
Expand Down
2 changes: 1 addition & 1 deletion law/participatiewet/bijstand/SZW-2023-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: c00f6a8b-b387-45d0-ab15-6f5aa34b7287
name: Bepalen recht op bijstand landelijk
law: participatiewet/bijstand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: b1d3a15b-45a2-44a3-b26a-d636785032c0
name: Bijstand Gemeente Amsterdam
law: participatiewet/bijstand
Expand Down
2 changes: 1 addition & 1 deletion law/penitentiaire_beginselenwet/DJI-2022-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: 292c11ff-8318-4b7a-bb11-3ea545b04c8e
name: Bepalen detentiestatus
law: penitentiaire_beginselenwet
Expand Down
2 changes: 1 addition & 1 deletion law/vreemdelingenwet/IND-2024-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: af0fed0d-ee11-48f3-b629-07becda4b7e9
name: Bepalen verblijfsstatus
law: vreemdelingenwet
Expand Down
51 changes: 50 additions & 1 deletion law/wet_brp/RvIG-2020-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: fcf09c18-1584-4565-9223-e8a86fbddc09
name: Bepalen persoonsgegevens BRP
law: wet_brp
Expand Down Expand Up @@ -283,6 +283,20 @@ properties:
type: "point_in_time"
reference: "$calculation_date"

- name: "household_members"
description: "Lijst met gegevens van medebewoners"
type: "array"
temporal:
type: "point_in_time"
reference: "$calculation_date"

- name: "children"
description: "Lijst met gegevens van kinderen"
type: "array"
temporal:
type: "point_in_time"
reference: "$calculation_date"

definitions:
DUTCH_NATIONALITIES:
- "NEDERLANDS"
Expand Down Expand Up @@ -403,3 +417,38 @@ actions:

- output: "woonplaats"
value: "$ADDRESS.woonplaats"

- output: "household_members"
operation: IF
conditions:
- test:
subject: "$HOUSEHOLD"
operation: NOT_NULL
then: "$HOUSEHOLD"
- else:
value: null # Leeg resultaat
reference: "Wet BRP Art. 2.4"

- output: "children"
operation: IF
conditions:
- test:
subject: "$HOUSEHOLD"
operation: NOT_NULL
then:
operation: FOREACH # Gebruik FOREACH voor filtering
subject: "$HOUSEHOLD"
combine: "ADD" # Combineer resultaten in een array
value:
operation: IF
conditions:
- test:
operation: LESS_THAN
values:
- "$age"
- 18
then: "$item" # Voeg dit item toe als kind
- else: null # Anders niets toevoegen
- else:
value: null # Leeg resultaat
reference: "Wet BRP Art. 1.6"
2 changes: 1 addition & 1 deletion law/wet_forensische_zorg/DJI-2022-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: c2124946-50d3-4aa8-b510-bccd04fc2cf9
name: Bepalen forensische zorg status
law: wet_forensische_zorg
Expand Down
2 changes: 1 addition & 1 deletion law/wet_inkomstenbelasting/BELASTINGDIENST-2001-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: cdd0ec9f-4975-4969-9d8a-808f2d6abfc9
name: Bepalen inkomens- en vermogensgegevens
law: wet_inkomstenbelasting
Expand Down
2 changes: 1 addition & 1 deletion law/wet_inkomstenbelasting/UWV-2020-01-01.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.1/schema.json
$id: https://raw.githubusercontent.com/MinBZK/poc-machine-law/refs/heads/main/schema/v0.1.2/schema.json
uuid: 06c43099-444f-415d-a98a-cb686954ed24
name: Bepalen toetsingsinkomen
law: wet_inkomstenbelasting
Expand Down
Loading

0 comments on commit b4f4ac6

Please sign in to comment.