From 88d7f817238f59e3b417dcd3d70a3580d6520dd8 Mon Sep 17 00:00:00 2001 From: Rob Date: Tue, 21 Apr 2026 15:29:56 +0200 Subject: [PATCH] Implement foerderquote calculation logic --- .github/copilot-tasks.md | 8 ++++---- src/taetigkeitsnachweis/matcher.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/copilot-tasks.md b/.github/copilot-tasks.md index fa502a1..9b467f4 100644 --- a/.github/copilot-tasks.md +++ b/.github/copilot-tasks.md @@ -42,9 +42,9 @@ Projekt vollstaendig umsetzen: aus PS_PW.xlsx und Stellenbeschreibungen.xlsx mon - [x] Mehrfache Eintraege je Name korrekt behalten ## Phase 4 - Matching und Fachlogik -- [ ] T7: Foerderquote berechnen - - [ ] Formel: funded_weekly_hours / contract_weekly_hours * 100 - - [ ] Rundungs-/Vergleichsregeln definieren +- [x] T7: Foerderquote berechnen + - [x] Formel: funded_weekly_hours / contract_weekly_hours * 100 + - [x] Rundungs-/Vergleichsregeln definieren - [ ] T8: Matching-Engine bauen - [ ] Primaerschluessel Name anwenden - [ ] Kandidaten via Stellenanteil/Foerderquote aufloesen @@ -111,4 +111,4 @@ Projekt vollstaendig umsetzen: aus PS_PW.xlsx und Stellenbeschreibungen.xlsx mon 8. T15 -> T16 -> T17 ## Aktueller Startpunkt -- [ ] Naechste aktive Aufgabe: T7 (Foerderquote berechnen) +- [ ] Naechste aktive Aufgabe: T8 (Matching-Engine bauen) diff --git a/src/taetigkeitsnachweis/matcher.py b/src/taetigkeitsnachweis/matcher.py index ba0dd7d..1af431c 100644 --- a/src/taetigkeitsnachweis/matcher.py +++ b/src/taetigkeitsnachweis/matcher.py @@ -1 +1,16 @@ """Record matching logic across allocation and master data.""" + +from __future__ import annotations + +from .errors import ValidationError +from .models import AllocationRecord + + +def calculate_foerderquote_percent(allocation: AllocationRecord, precision: int = 2) -> float: + if allocation.contract_hours_weekly <= 0: + raise ValidationError( + "contract_hours_weekly must be greater than 0 for foerderquote calculation." + ) + + raw_share = (allocation.funded_hours_weekly / allocation.contract_hours_weekly) * 100.0 + return round(raw_share, precision)