From 16c97890e336bcba848d5c9798e5732fc8b4e9b3 Mon Sep 17 00:00:00 2001 From: hubobel Date: Sat, 20 Jun 2026 17:33:37 +0200 Subject: [PATCH] WebApp Design modern --- app.py | 81 +++++++++++++++++++++++++++++++++++++++++- requirements.txt | 3 +- static/style.css | 10 ++++++ templates/index.html | 83 ++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 169 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 3d761e2..4dee0cd 100644 --- a/app.py +++ b/app.py @@ -5,19 +5,98 @@ import sys import json from pathlib import Path from flask import redirect +from datetime import datetime app = Flask(__name__) BASE_DIR = Path(__file__).parent CATEGORIES_FILE = BASE_DIR / "Kategorien.json" +def get_current_week_data(): + year, week, _ = datetime.now().isocalendar() + + summary_file = ( + BASE_DIR + / "Transaktionen" + / str(year) + / "summary" + / f"category_summary_{year}_KW{week:02d}.json" + ) + + transactions_file = ( + BASE_DIR + / "Transaktionen" + / str(year) + / "categorized_json" + / f"categorized_transactions_{year}_KW{week:02d}.json" + ) + + summary = None + transactions = [] + + total_income = 0 + total_expenses = 0 + total_saldo = 0 + + if summary_file.exists(): + + with open( + summary_file, + encoding="utf-8" + ) as f: + + summary = json.load(f) + + for values in summary.values(): + + total_income += values["income"] + total_expenses += values["expenses"] + total_saldo += values["saldo"] + + if transactions_file.exists(): + + with open( + transactions_file, + encoding="utf-8" + ) as f: + + transactions = json.load(f) + + return ( + year, + week, + summary, + transactions, + total_income, + total_expenses, + total_saldo + ) +@app.route("/") @app.route("/") def index(): - return render_template("index.html") + ( + year, + week, + summary, + transactions, + total_income, + total_expenses, + total_saldo + ) = get_current_week_data() + return render_template( + "index.html", + year=year, + week=week, + summary=summary, + transactions=transactions[:10], + total_income=total_income, + total_expenses=total_expenses, + total_saldo=total_saldo + ) @app.route("/run/balance", methods=["POST"]) def run_balance(): diff --git a/requirements.txt b/requirements.txt index 052b718..8ab6f1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ fints openpyxl -mt-940 \ No newline at end of file +mt-940 +flask \ No newline at end of file diff --git a/static/style.css b/static/style.css index 16c72a4..127a664 100644 --- a/static/style.css +++ b/static/style.css @@ -183,4 +183,14 @@ text-decoration: underline; .tag a:hover { color: #202020; +} + +.transaction-table { + width: 100%; + border-collapse: collapse; +} + +.transaction-table td { + padding: 6px; + border-bottom: 1px solid #eee; } \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 09d7ed0..11f6be8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -88,14 +88,14 @@ + value="{{ year }}"> KW: + value="{{ week }}">

@@ -119,14 +119,14 @@ + value="{{ year }}"> KW: + value="{{ week }}">

@@ -143,8 +143,7 @@

Kategorien

- Kategorien und Schlüsselwörter - verwalten. + Kategorien und Schlüsselwörter verwalten.

@@ -157,6 +156,77 @@ +
+ +

+ KW{{ week }} +

+ +

+ Einnahmen: + + {{ "%.2f"|format(total_income) }} € + +

+ +

+ Ausgaben: + + {{ "%.2f"|format(total_expenses) }} € + +

+ +

+ Saldo: + + {{ "%.2f"|format(total_saldo) }} € + +

+ +
+ +
+ +

+ Letzte Transaktionen +

+ + {% if transactions %} + + + + {% for t in transactions[-10:]|reverse %} + + + + + + + + + + + + {% endfor %} + +
+ {{ t.date }} + + {{ t.applicant_name }} + + {{ "%.2f"|format(t.amount) }} € +
+ + {% else %} + +

+ Keine Transaktionen vorhanden. +

+ + {% endif %} + +
+ ``` @@ -171,4 +241,5 @@ Hintergasse © 2026 +