mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-08-24 22:45:18 +02:00
Remember the last-used GnuCash account per file
AppConfig now keeps a gnucash_last_accounts map (file path -> account guid). When the import dialog opens a file it already knows, it auto-selects whichever account was picked last time for that specific file instead of always defaulting to the first one alphabetically; picking a different account updates and persists the mapping right away. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
745e634a8b
commit
42cde2a0c8
@@ -48,3 +48,27 @@ def test_store_path_can_be_overridden_from_ccma_environment(tmp_path, monkeypatc
|
||||
monkeypatch.setenv("CCMA_STORE", str(tmp_path / "store"))
|
||||
|
||||
assert load_config().store_path == str(tmp_path / "store")
|
||||
|
||||
|
||||
def test_gnucash_last_account_per_file_round_trips(tmp_path, monkeypatch) -> None:
|
||||
monkeypatch.setenv("CCMA_CONFIG_DIR", str(tmp_path / "config"))
|
||||
first_file = str(tmp_path / "verein.gnucash")
|
||||
second_file = str(tmp_path / "spenden.gnucash")
|
||||
config = AppConfig(
|
||||
gnucash_last_accounts={first_file: "bank-guid", second_file: "cash-guid"}
|
||||
)
|
||||
config.save()
|
||||
|
||||
loaded = load_config()
|
||||
assert loaded.gnucash_last_accounts == {first_file: "bank-guid", second_file: "cash-guid"}
|
||||
|
||||
|
||||
def test_gnucash_last_accounts_defaults_to_empty_dict_for_malformed_value(tmp_path, monkeypatch) -> None:
|
||||
monkeypatch.setenv("CCMA_CONFIG_DIR", str(tmp_path / "config"))
|
||||
config_path = tmp_path / "config" / "config.json"
|
||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
config_path.write_text(
|
||||
json.dumps({"schema_version": 1, "gnucash_last_accounts": "not-a-dict"}), encoding="utf-8"
|
||||
)
|
||||
|
||||
assert load_config().gnucash_last_accounts == {}
|
||||
|
||||
Reference in New Issue
Block a user