diff --git a/src/pdf_filler.py b/src/pdf_filler.py index a71dcd2..a4499d8 100644 --- a/src/pdf_filler.py +++ b/src/pdf_filler.py @@ -45,6 +45,7 @@ def build_field_dict( creation_date = date.today() plan_value: str = config["plan_hours_value"] + plan_threshold: float = float(plan_value) pauschale_prefix: str = config["pdf_pauschale_prefix"] pauschale_present_value: str = config["pauschale_present_value"] ort_field: str = config["pdf_field_ort"] @@ -65,7 +66,11 @@ def build_field_dict( if entry.is_present: fields[f"ist.{idx}"] = entry.hours_german() fields[f"plan.{idx}"] = plan_value - fields[f"{pauschale_prefix}.{idx}"] = pauschale_present_value + # Pauschale only if actual hours >= planned threshold + if entry.hours is not None and entry.hours >= plan_threshold: + fields[f"{pauschale_prefix}.{idx}"] = pauschale_present_value + else: + fields[f"{pauschale_prefix}.{idx}"] = "0" else: fields[f"ist.{idx}"] = "" fields[f"plan.{idx}"] = "" diff --git a/tests/test_pdf_filler.py b/tests/test_pdf_filler.py index 5db1443..4dfef80 100644 --- a/tests/test_pdf_filler.py +++ b/tests/test_pdf_filler.py @@ -109,6 +109,14 @@ class TestPresentDay: fields = build_field_dict(_make_attendance(_present(3, 6.0)), cfg, date(2026, 2, 1)) assert fields["pauschale_5.0"] == "1" + def test_pauschale_above_threshold(self, cfg): + fields = build_field_dict(_make_attendance(_present(3, 7.5)), cfg, date(2026, 2, 1)) + assert fields["pauschale_5.0"] == "1" + + def test_pauschale_below_threshold(self, cfg): + fields = build_field_dict(_make_attendance(_present(3, 5.0)), cfg, date(2026, 2, 1)) + assert fields["pauschale_5.0"] == "0" + # --------------------------------------------------------------------------- # Absent days (K, KK, E, F, P, U)