From 005d5be68630ce7f9a55851bb39acee8af9f2c7e Mon Sep 17 00:00:00 2001 From: Alexander Malzkuhn Date: Mon, 28 Apr 2025 14:04:18 +0200 Subject: [PATCH] =?UTF-8?q?Summenabschnitt=20API=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zeitsollbestimmung hat noch Fehler --- api.py | 38 ++++++++++++++++++++++------------- users/testuser1/settings.json | 20 +++++++++--------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/api.py b/api.py index c073871..66610f2 100644 --- a/api.py +++ b/api.py @@ -15,7 +15,7 @@ import calendar @ui.page('/api/overview/month/{username}-{year}-{month}') def page(username: str, year: int, month: int): - #try: + try: current_user = user(username) ui.page_title(f"Bericht für {current_user.fullname} für {calendar.month_name[month]} {year}") ui.label(datetime.now().strftime('%d.%m.%Y')).classes('absolute top-5 right-5') @@ -65,8 +65,7 @@ def page(username: str, year: int, month: int): for i in list(user_absent): if int(i) == day: booking_text += absence_entries[user_absent[i]]["name"] + " " - except Exception as e: - print(e) + except: pass # Buchungen behandeln @@ -130,6 +129,7 @@ def page(username: str, year: int, month: int): if time_duty < 0: saldo = 0 total = "" + booking_text = "Kein Arbeitsverhältnis" else: saldo = int(time_sum) - int(time_duty) # Nach Abwesenheitseinträgen suchen @@ -147,20 +147,30 @@ def page(username: str, year: int, month: int): rows.append({'date': current_day_date, 'bookings': booking_text, 'is_time': is_time, 'target_time': target_time, 'total': total}) - - - - #rows = [ - # {'date': '1.1.2024', 'bookings': '12345', 'is_time': '12345', 'target_time': '98765', 'total': 123} - #] - overview_table = ui.table(columns=columns, rows=rows).classes('w-120') # Zeilenumbruch umsetzen overview_table.add_slot('body-cell', r''' {{ props.value }} ''') - #except Exception as e: -# print(e) -# ui.markdown('#Fehler') -# ui.markdown('Benutzer existiert nicht') \ No newline at end of file + # Überstundenzusammenfassung + + with ui.grid(columns=2).classes('w-full gap-0'): + ui.markdown("Überstunden aus Vormonat:") + last_months_overtime = current_user.get_last_months_overtime(year, month) + ui.markdown(f"{convert_seconds_to_hours(last_months_overtime)} h") + ui.markdown("Überstunden diesen Monat:") + ui.markdown(f"{convert_seconds_to_hours(general_saldo)} h") + ui.markdown("**Überstunden Gesamt:**") + overtime_overall = last_months_overtime + general_saldo + ui.markdown(f"**{convert_seconds_to_hours(overtime_overall)} h**") + + except Exception as e: + print(str(type(e).__name__) + " " + str(e)) + if type(e) == UnboundLocalError: + ui.markdown('#Fehler') + ui.markdown('Benutzer existiert nicht') + else: + ui.markdown('#Fehler') + ui.markdown(str(type(e))) + ui.markdown(str(e)) \ No newline at end of file diff --git a/users/testuser1/settings.json b/users/testuser1/settings.json index 83a6dee..e0141a6 100644 --- a/users/testuser1/settings.json +++ b/users/testuser1/settings.json @@ -3,16 +3,6 @@ "fullname": "Pia Paulina", "password": "123456789", "workhours": { - "2025-04-03": { - "1": "4", - "2": "8", - "3": "8", - "4": "8", - "5": "8", - "6": "0", - "7": "0", - "vacation": "35" - }, "2025-05-13": { "1": "0", "2": "0", @@ -32,6 +22,16 @@ "6": "6", "7": "7", "vacation": "0" + }, + "2025-03-01": { + "1": "4", + "2": "8", + "3": "8", + "4": "8", + "5": "8", + "6": 0, + "7": 0, + "vacation": "30" } } } \ No newline at end of file