Erster Versuch zweiter Schritt, configs ausgefüllt
This commit is contained in:
1 parent
2faa1689dd
commit
15d49acfc8
8 files changed
+35
-17
No files matched your search
+5
-2
@@ -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"
|
||||
}
|
||||
Binary file not shown.
@@ -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
|
||||
|
||||
+8
-5
@@ -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
|
||||
|
||||
|
||||
Binary file not shown.
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user