mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-07-01 11:14:52 +02:00
feat: repeat claim items in document tables
This commit is contained in:
+43
-3
@@ -32,6 +32,42 @@ def test_unknown_placeholder_is_reported() -> None:
|
||||
_replace_xml_placeholders(source, {})
|
||||
|
||||
|
||||
def test_claim_item_loop_clones_formatted_table_row() -> None:
|
||||
source = b"""<office:document
|
||||
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
||||
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
|
||||
<office:body><office:text><table:table>
|
||||
<table:table-row table:style-name="item-row">
|
||||
<table:table-cell><text:p>{{#claim.items}}{{item.description}}</text:p></table:table-cell>
|
||||
<table:table-cell><text:p>{{item.amount}}{{/claim.items}}</text:p></table:table-cell>
|
||||
</table:table-row>
|
||||
</table:table></office:text></office:body></office:document>"""
|
||||
items = [
|
||||
{"item.description": "Beitrag", "item.amount": "75.00"},
|
||||
{"item.description": "Gebühr", "item.amount": "5.00"},
|
||||
]
|
||||
|
||||
rendered = _replace_xml_placeholders(source, {}, {"claim.items": items})
|
||||
root = ElementTree.fromstring(rendered)
|
||||
rows = [element for element in root.iter() if element.tag.endswith("table-row")]
|
||||
row_text = ["".join("".join(row.itertext()).split()) for row in rows]
|
||||
|
||||
assert row_text == ["Beitrag75.00", "Gebühr5.00"]
|
||||
assert all(next(iter(row.attrib.values())) == "item-row" for row in rows)
|
||||
|
||||
|
||||
def test_claim_item_loop_removes_row_for_empty_collection() -> None:
|
||||
source = b"""<table:table xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
||||
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
|
||||
<table:table-row><table:table-cell><text:p>{{#claim.items}}{{item.description}}
|
||||
{{/claim.items}}</text:p></table:table-cell></table:table-row></table:table>"""
|
||||
|
||||
rendered = _replace_xml_placeholders(source, {}, {"claim.items": []})
|
||||
|
||||
assert not any(element.tag.endswith("table-row") for element in ElementTree.fromstring(rendered).iter())
|
||||
|
||||
|
||||
def test_default_templates_are_seeded_without_overwriting_store_version(tmp_path) -> None:
|
||||
repository = MemberRepository(tmp_path)
|
||||
repository.initialize()
|
||||
@@ -42,7 +78,7 @@ def test_default_templates_are_seeded_without_overwriting_store_version(tmp_path
|
||||
|
||||
assert template.read_text(encoding="utf-8") == "custom"
|
||||
assert {path.name for path in (repository.root / "templates").iterdir()} == {
|
||||
"Forderung.fodt",
|
||||
"Forderung mit Positionen.fodt",
|
||||
"Mahnung.fodt",
|
||||
"Mitglied.fodt",
|
||||
}
|
||||
@@ -64,8 +100,12 @@ def test_templates_are_filtered_by_available_context(tmp_path) -> None:
|
||||
}
|
||||
|
||||
assert member_templates == {"Mitglied.fodt"}
|
||||
assert claim_templates == {"Forderung.fodt", "Mitglied.fodt"}
|
||||
assert reminder_templates == {"Forderung.fodt", "Mahnung.fodt", "Mitglied.fodt"}
|
||||
assert claim_templates == {"Forderung mit Positionen.fodt", "Mitglied.fodt"}
|
||||
assert reminder_templates == {
|
||||
"Forderung mit Positionen.fodt",
|
||||
"Mahnung.fodt",
|
||||
"Mitglied.fodt",
|
||||
}
|
||||
|
||||
|
||||
def test_generated_reminder_pdf_is_stored_audited_and_linked(tmp_path, monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user