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 und Schlüsselwörter - verwalten. + Kategorien und Schlüsselwörter verwalten.
@@ -157,6 +156,77 @@ ++ Einnahmen: + + {{ "%.2f"|format(total_income) }} € + +
+ ++ Ausgaben: + + {{ "%.2f"|format(total_expenses) }} € + +
+ ++ Saldo: + + {{ "%.2f"|format(total_saldo) }} € + +
+ +| + {{ t.date }} + | + ++ {{ t.applicant_name }} + | + ++ {{ "%.2f"|format(t.amount) }} € + | + +
+ Keine Transaktionen vorhanden. +
+ + {% endif %} + +