diff --git a/config.json b/config.json index 2b93860..c367674 100644 --- a/config.json +++ b/config.json @@ -24,7 +24,10 @@ "Nov": "11", "Dez": "12" }, - "valid_status_codes": ["K", "KK", "E", "F", "P", "U"], + "valid_status_codes": ["K", "KK", "E", "F", "P", "U", "A", "V"], "plan_hours_value": "6", - "pauschale_value": "8,60" + "pdf_field_ort": "unterschrift.ort", + "pdf_field_erstellungsdatum": "unterschrift.datum", + "pdf_pauschale_prefix": "pauschale_5", + "pauschale_present_value": "1" } diff --git a/input/Anwesenheitsliste 2026.xlsx b/input/Anwesenheitsliste 2026.xlsx new file mode 100644 index 0000000..7edfd82 Binary files /dev/null and b/input/Anwesenheitsliste 2026.xlsx differ diff --git a/src/config_loader.py b/src/config_loader.py index 42c2de6..21fa281 100644 --- a/src/config_loader.py +++ b/src/config_loader.py @@ -20,7 +20,10 @@ _REQUIRED_KEYS = [ "month_mapping", "valid_status_codes", "plan_hours_value", - "pauschale_value", + "pdf_field_ort", + "pdf_field_erstellungsdatum", + "pdf_pauschale_prefix", + "pauschale_present_value", ] # Singleton cache so the file is only read once per process diff --git a/src/pdf_filler.py b/src/pdf_filler.py index 1633b59..c3430fd 100644 --- a/src/pdf_filler.py +++ b/src/pdf_filler.py @@ -44,14 +44,17 @@ def build_field_dict( creation_date = date.today() plan_value: str = config["plan_hours_value"] - pauschale_value: str = config["pauschale_value"] + pauschale_prefix: str = config["pdf_pauschale_prefix"] + pauschale_present_value: str = config["pauschale_present_value"] + ort_field: str = config["pdf_field_ort"] + datum_field: str = config["pdf_field_erstellungsdatum"] fields: Dict[str, str] = { "person.name": attendance.person.name, "monat_jahr": attendance.monat_jahr, "antragsnummer": config["antragsnummer"], - "ort": config["ort"], - "erstellungsdatum": creation_date.strftime("%d.%m.%Y"), + ort_field: config["ort"], + datum_field: creation_date.strftime("%d.%m.%Y"), } for idx, entry in enumerate(attendance.entries): @@ -61,11 +64,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.{idx}"] = pauschale_value + fields[f"{pauschale_prefix}.{idx}"] = pauschale_present_value else: fields[f"ist.{idx}"] = "" fields[f"plan.{idx}"] = "" - fields[f"pauschale.{idx}"] = "" + fields[f"{pauschale_prefix}.{idx}"] = "0" return fields diff --git a/template/sab.pdf b/template/sab.pdf new file mode 100644 index 0000000..4f38f79 Binary files /dev/null and b/template/sab.pdf differ diff --git a/tests/test_excel_reader.py b/tests/test_excel_reader.py index 427805e..6836ccb 100644 --- a/tests/test_excel_reader.py +++ b/tests/test_excel_reader.py @@ -35,9 +35,12 @@ def cfg(): "Apr": "04", "Mai": "05", "Jun": "06", "Jul": "07", "Aug": "08", "Sep": "09", "Okt": "10", "Nov": "11", "Dez": "12", }, - "valid_status_codes": ["K", "KK", "E", "F", "P", "U"], + "valid_status_codes": ["K", "KK", "E", "F", "P", "U", "A", "V"], "plan_hours_value": "6", - "pauschale_value": "8,60", + "pdf_field_ort": "unterschrift.ort", + "pdf_field_erstellungsdatum": "unterschrift.datum", + "pdf_pauschale_prefix": "pauschale_5", + "pauschale_present_value": "1", "antragsnummer": "12345", "ort": "Teststadt", "template_pdf": "template/sab.pdf", diff --git a/tests/test_pdf_filler.py b/tests/test_pdf_filler.py index f5b5ed6..8ee8fed 100644 --- a/tests/test_pdf_filler.py +++ b/tests/test_pdf_filler.py @@ -20,7 +20,10 @@ def cfg(): "template_pdf": "template/sab.pdf", "output_dir": "output", "plan_hours_value": "6", - "pauschale_value": "8,60", + "pdf_field_ort": "unterschrift.ort", + "pdf_field_erstellungsdatum": "unterschrift.datum", + "pdf_pauschale_prefix": "pauschale_5", + "pauschale_present_value": "1", "excel_year_pattern": "(20\\d{2})", "excel_name_header": "Name, Vorname", "excel_name_column": 1, @@ -70,11 +73,11 @@ class TestHeaderFields: def test_ort(self, cfg): fields = build_field_dict(_make_attendance(), cfg, date(2026, 2, 1)) - assert fields["ort"] == "Leipzig" + assert fields["unterschrift.ort"] == "Leipzig" def test_erstellungsdatum(self, cfg): fields = build_field_dict(_make_attendance(), cfg, date(2026, 3, 27)) - assert fields["erstellungsdatum"] == "27.03.2026" + assert fields["unterschrift.datum"] == "27.03.2026" # --------------------------------------------------------------------------- @@ -104,7 +107,7 @@ class TestPresentDay: def test_pauschale_set(self, cfg): fields = build_field_dict(_make_attendance(_present(3, 6.0)), cfg, date(2026, 2, 1)) - assert fields["pauschale.0"] == "8,60" + assert fields["pauschale_5.0"] == "1" # --------------------------------------------------------------------------- @@ -130,7 +133,7 @@ class TestAbsentDay: @pytest.mark.parametrize("status", ["K", "KK", "E", "F", "P", "U"]) def test_pauschale_empty(self, cfg, status): fields = build_field_dict(_make_attendance(_absent(4, status)), cfg, date(2026, 2, 1)) - assert fields["pauschale.0"] == "" + assert fields["pauschale_5.0"] == "0" # --------------------------------------------------------------------------- diff --git a/tests/test_validators.py b/tests/test_validators.py index 5505f73..44f7f74 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -28,9 +28,12 @@ def _write_config(tmp_path: Path, overrides: dict = None) -> Path: "excel_day_start_col": 9, "excel_day_end_col": 39, "month_mapping": {"Feb": "02", "Jan": "01"}, - "valid_status_codes": ["K", "KK", "E", "F", "P", "U"], + "valid_status_codes": ["K", "KK", "E", "F", "P", "U", "A", "V"], "plan_hours_value": "6", - "pauschale_value": "8,60", + "pdf_field_ort": "unterschrift.ort", + "pdf_field_erstellungsdatum": "unterschrift.datum", + "pdf_pauschale_prefix": "pauschale_5", + "pauschale_present_value": "1", } if overrides: cfg.update(overrides)