diff --git a/.gitignore b/.gitignore index 49c520a..bc2a32e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +CLAUDE.md # ---> Python uv.lock # Byte-compiled / optimized / DLL files diff --git a/src/toldg/fzf.py b/src/toldg/fzf.py index 554cfec..1e6ff51 100644 --- a/src/toldg/fzf.py +++ b/src/toldg/fzf.py @@ -5,8 +5,10 @@ import sys EXECUTABLE_NAME = "fzf.exe" if sys.platform == "win32" else "fzf" -def iterfzf(iterable, prompt="> "): - cmd = [EXECUTABLE_NAME, "--prompt=" + prompt] +def iterfzf(iterable, prompt="> ", header=None, height="50%"): + cmd = [EXECUTABLE_NAME, "--prompt=" + prompt, "--height=" + height, "--reverse"] + if header: + cmd.append("--header=" + header) encoding = sys.getdefaultencoding() proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None) if proc.stdin is None: diff --git a/src/toldg/predict.py b/src/toldg/predict.py index e1bbe34..bf55ad4 100644 --- a/src/toldg/predict.py +++ b/src/toldg/predict.py @@ -397,8 +397,9 @@ def add_account2_interactive(transaction: Transaction, categories: List[str]): """Interactively add account2 to a transaction.""" t = transaction account2 = None - prompt = f"{t.account1} {t.date} {t.description} {t.debit} > " + header = f"{t.account1} | {t.date} | {t.description} | {t.debit}" + logging.warning(f"No mapping for '{t}'.") while account2 is None: - account2 = iterfzf(categories, prompt=prompt) + account2 = iterfzf(categories, header=header) transaction.account2 = account2 print(f"Assigned category '{account2}'.") diff --git a/src/toldg/process.py b/src/toldg/process.py index 96f5b2e..6d98115 100644 --- a/src/toldg/process.py +++ b/src/toldg/process.py @@ -68,6 +68,7 @@ def get_transactions(csv_file: str, config: CsvConfig) -> list[Transaction]: def apply_mappings(transactions: list[Transaction], mappings: dict[str, Mapping]): """Apply mappings to transactions.""" + unmapped_count = 0 for t in transactions: if t.key() in mappings: mapping = mappings[t.key()] @@ -76,7 +77,9 @@ def apply_mappings(transactions: list[Transaction], mappings: dict[str, Mapping] mapping.count -= 1 t.mapping = mapping else: - logging.warning(f"No mapping for '{t}'.") + unmapped_count += 1 + if unmapped_count > 0: + logging.info(f"{unmapped_count} transactions without mappings.") for mapping in mappings.values(): assert mapping.count == 0, f"{mapping} was not used as often as expected!"