Windows-Build / windows-exe (push) Successful in 5m7s
- Airtime: Auszahlung in % je Händler (0 % = keine). Im Export als eine Summenzeile, die Einzelposten in einer eigenen Airtime-Liste (zweite Excel-Datei). - Jahresbonus Neuaktivierung: Betrag je Karte nach Staffel (Standard 1-9: 5 € ... ab 40: voll), Standard-Staffel änderbar, eigene Staffel je Händler möglich. - Provisionsarten: Airtime/Jahresbonus werden erkannt, Behandlung je Provisionsart umstellbar. - Export: freenet und Vodafone standardmäßig in einer Datei, Positionen mit 0,00 € weglassen. - Händler-Dialog: GROSSBUCHSTABEN-Regel als Häkchen (ging verloren, wenn „Hinzufügen“ vergessen wurde). - Windows: Hauptfenster ist ein echtes Programmfenster mit unsichtbarem Rahmen – Andocken am Bildschirmrand, Win+Pfeiltasten und natives Größe-Ziehen; Trennsteg baut erst beim Loslassen neu auf. - DB-Schema v3 (Migration), Tests für alles Neue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
"""Speicherorte und Einstellungen.
|
||
|
||
Die Einstellungen liegen als JSON in %APPDATA%\\Provisionsmanager95\\einstellungen.json.
|
||
Darin steht u. a. der Pfad zur Datenbank – der kann bewusst auf ein Netzlaufwerk
|
||
zeigen, wenn mehrere PCs (nacheinander) mit denselben Händlerdaten arbeiten sollen.
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
import os
|
||
from pathlib import Path
|
||
|
||
APP_DIR_NAME = "Provisionsmanager95"
|
||
|
||
|
||
def app_dir() -> Path:
|
||
base = os.environ.get("PROVTOOL_HOME")
|
||
if base:
|
||
p = Path(base)
|
||
elif os.name == "nt" and os.environ.get("APPDATA"):
|
||
p = Path(os.environ["APPDATA"]) / APP_DIR_NAME
|
||
else:
|
||
p = Path.home() / ".config" / APP_DIR_NAME
|
||
p.mkdir(parents=True, exist_ok=True)
|
||
return p
|
||
|
||
|
||
def _settings_file() -> Path:
|
||
return app_dir() / "einstellungen.json"
|
||
|
||
|
||
DEFAULTS = {
|
||
"db_pfad": None, # None = Standard im App-Verzeichnis
|
||
"export_ordner": None,
|
||
"import_ordner": None,
|
||
"export_kopfzeile": False,
|
||
"export_summe": True,
|
||
"export_anbieter_getrennt": False, # freenet + Vodafone in einer Datei
|
||
"export_null_weglassen": True,
|
||
}
|
||
|
||
|
||
def load() -> dict:
|
||
data = dict(DEFAULTS)
|
||
f = _settings_file()
|
||
if f.exists():
|
||
try:
|
||
data.update(json.loads(f.read_text(encoding="utf-8")))
|
||
except (OSError, ValueError):
|
||
pass
|
||
return data
|
||
|
||
|
||
def save(data: dict) -> None:
|
||
_settings_file().write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
|
||
|
||
|
||
def db_path(settings: dict | None = None) -> Path:
|
||
settings = settings or load()
|
||
if settings.get("db_pfad"):
|
||
return Path(settings["db_pfad"])
|
||
return app_dir() / "provisionen.db"
|