Firmendaten portabel suchen + Menuepunkt zum Auswaehlen
Die config.json des Rechnungstools wurde nur unter dem festen Entwicklungspfad gesucht - als EXE auf einem anderen Rechner haette der Bericht keinen Briefkopf bekommen. Jetzt: neben dem Programm, im Nachbarordner, in Dokumente, und ueber "Daten -> Firmendaten waehlen". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
80967de26f
commit
2b7990b1b6
2 changed files with 35 additions and 5 deletions
17
app.py
17
app.py
|
|
@ -90,6 +90,8 @@ class App(tk.Tk):
|
|||
daten.add_command(label="Markierte Buchung löschen (Entf)", command=self.buchung_loeschen)
|
||||
daten.add_separator()
|
||||
daten.add_command(label="Steuersatz ändern…", command=self.satz_aendern)
|
||||
daten.add_command(label="Firmendaten des Rechnungstools wählen…",
|
||||
command=self.firma_waehlen)
|
||||
leiste.add_cascade(label="Daten", menu=daten)
|
||||
self.config(menu=leiste)
|
||||
|
||||
|
|
@ -355,6 +357,21 @@ class App(tk.Tk):
|
|||
fenster.bind("<Return>", lambda _e: speichern())
|
||||
eingabe.focus_set()
|
||||
|
||||
def firma_waehlen(self):
|
||||
"""config.json des Rechnungstools zeigen – sie liefert den Briefkopf des Berichts."""
|
||||
pfad = filedialog.askopenfilename(
|
||||
title="config.json des Rechnungstools wählen",
|
||||
initialfile="config.json",
|
||||
filetypes=[("Einstellungsdatei", "config.json"), ("Alle Dateien", "*.*")])
|
||||
if not pfad:
|
||||
return
|
||||
self.journal.setze("rechnungstool_config", os.path.abspath(pfad))
|
||||
self.firma = firma_lib.lade(os.path.abspath(pfad))
|
||||
name = self.firma.get("name", "")
|
||||
self.melde(f"Briefkopf: {name} (aus {os.path.basename(pfad)})")
|
||||
messagebox.showinfo("Firmendaten",
|
||||
f"Der Bericht trägt jetzt den Briefkopf von:\n\n{name}", parent=self)
|
||||
|
||||
def altbestand_importieren(self):
|
||||
pfad = filedialog.askopenfilename(
|
||||
title="Alte Beherbergungssteuer-Tabelle wählen",
|
||||
|
|
|
|||
21
firma.py
21
firma.py
|
|
@ -11,15 +11,28 @@ Bericht wird trotzdem gedruckt (nur ohne Logo/Bankzeile).
|
|||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
|
||||
log = logging.getLogger("bst.firma")
|
||||
|
||||
SUCHPFADE = [
|
||||
r"C:\claude\rechnungstool\config.json",
|
||||
os.path.join(os.path.expanduser("~"), "Documents", "rechnungstool", "config.json"),
|
||||
_HIER = os.path.dirname(os.path.abspath(
|
||||
sys.argv[0] if getattr(sys, "frozen", False) else __file__))
|
||||
_HEIM = os.path.expanduser("~")
|
||||
|
||||
|
||||
def _suchpfade():
|
||||
"""Übliche Orte der config.json des Rechnungstools – erst neben uns, dann daneben."""
|
||||
kandidaten = [
|
||||
os.path.join(_HIER, "config.json"), # direkt daneben gelegt
|
||||
os.path.join(_HIER, "..", "rechnungstool", "config.json"),
|
||||
os.path.join(_HIER, "..", "Rechnungstool", "config.json"),
|
||||
os.path.join(_HEIM, "Documents", "rechnungstool", "config.json"),
|
||||
os.path.join(_HEIM, "Documents", "Rechnungstool", "config.json"),
|
||||
r"C:\claude\rechnungstool\config.json", # Entwicklungsrechner
|
||||
]
|
||||
return [os.path.normpath(p) for p in kandidaten]
|
||||
|
||||
ERSATZ = {
|
||||
"name": "Campinghof Bartl",
|
||||
|
|
@ -32,7 +45,7 @@ ERSATZ = {
|
|||
|
||||
def config_pfad(gespeichert: str = "") -> str:
|
||||
"""Erster gefundener Pfad zur config.json des Rechnungstools ('' = keiner)."""
|
||||
for p in ([gespeichert] if gespeichert else []) + SUCHPFADE:
|
||||
for p in ([gespeichert] if gespeichert else []) + _suchpfade():
|
||||
if p and os.path.isfile(p):
|
||||
return os.path.abspath(p)
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue