Category overhaul #20

Merged
mathias2784 merged 18 commits from category-overhaul into master 2026-10-27 18:08:10 +00:00
Showing only changes of commit c7e4b68dfb - Show all commits
+15 -6
View File
@@ -73,6 +73,10 @@ def _reader_raw_comdirect(path: Path) -> CsV2DictMulti:
account_name: str | None = None account_name: str | None = None
header: list[str] = [] header: list[str] = []
result: CsV2DictMulti = {} result: CsV2DictMulti = {}
# Comdirect groups "new" transactions (marked with "neu") under a header
# line that carries only their Buchungstag; remember it until the next
# transaction row for the same account.
pending_book_date: dict[str, str] = {}
for line in lines: for line in lines:
if expect_next == EXPECT_LINE.ACCOUNT_NAME: if expect_next == EXPECT_LINE.ACCOUNT_NAME:
matches = re.findall(PATTERN_ACCOUNT_NAME, line) matches = re.findall(PATTERN_ACCOUNT_NAME, line)
@@ -91,13 +95,18 @@ def _reader_raw_comdirect(path: Path) -> CsV2DictMulti:
expect_next = EXPECT_LINE.DATA expect_next = EXPECT_LINE.DATA
elif expect_next == EXPECT_LINE.DATA: elif expect_next == EXPECT_LINE.DATA:
data = re.findall(PATTERN_DATA, line) data = re.findall(PATTERN_DATA, line)
if data: if not data:
assert account_name is not None
result[account_name].append(
{column: value for column, value in zip(header, data)}
)
else:
expect_next = EXPECT_LINE.ACCOUNT_NAME expect_next = EXPECT_LINE.ACCOUNT_NAME
elif len(data) == 1:
# Group header line (single Buchungstag for the "neu" rows below).
assert account_name is not None
pending_book_date[account_name] = data[0]
else:
assert account_name is not None
row = {column: value for column, value in zip(header, data)}
if data[0] == "neu" and account_name in pending_book_date:
row["Buchungstag"] = pending_book_date.pop(account_name)
result[account_name].append(row)
else: else:
expect_next = EXPECT_LINE.ACCOUNT_NAME expect_next = EXPECT_LINE.ACCOUNT_NAME
return result return result