diff --git a/csv/2018-02-arbeitsstunden.csv b/csv/2018-02-arbeitsstunden.csv new file mode 100644 index 0000000000000000000000000000000000000000..bb38d299bbcb23e98e81ab753f2b2c5bae4bf9ea --- /dev/null +++ b/csv/2018-02-arbeitsstunden.csv @@ -0,0 +1,21 @@ +01.02.2018,Do,10.00,11.30,01:30,00:00, +02.02.2018,Fr,09.00,11.30,02:30,00:00, +05.02.2018,Mo,10.00,12.00,02:00,00:00, +06.02.2018,Di,10.00,10.30,00:30,00:00, +07.02.2018,Mi,12.00,14.00,02:00,00:00, +08.02.2018,Do,11.00,13.30,02:30,00:00, +09.02.2018,Fr,11.00,11.30,00:30,00:00, +12.02.2018,Mo,12.00,13.30,01:30,00:00, +13.02.2018,Di,11.00,13.30,02:30,00:00, +14.02.2018,Mi,09.00,12.00,03:00,00:00, +15.02.2018,Do,09.00,12.45,03:30,00:15, +16.02.2018,Fr,09.00,11.30,02:00,00:30, +19.02.2018,Mo,10.00,14.15,03:30,00:45,Urlaub +20.02.2018,Di,12.00,14.00,02:00,00:00, +21.02.2018,Mi,11.00,13.45,02:30,00:15, +22.02.2018,Do,09.00,11.00,02:00,00:00, +23.02.2018,Fr,11.00,12.00,01:00,00:00, +26.02.2018,Mo,10.00,11.00,01:00,00:00, +27.02.2018,Di,10.00,12.30,02:30,00:00, +28.02.2018,Mi,12.00,13.30,01:30,00:00, +Gesamt,,,,40:00,, diff --git a/csv/2018-03-arbeitsstunden.csv b/csv/2018-03-arbeitsstunden.csv new file mode 100644 index 0000000000000000000000000000000000000000..203b2e23e0504ef8ed36850b0de5afe3952f73ba --- /dev/null +++ b/csv/2018-03-arbeitsstunden.csv @@ -0,0 +1,23 @@ +01.03.2018,Do,11.00,13.30,01:30,01:00, +02.03.2018,Fr,11.00,14.30,03:30,00:00, +05.03.2018,Mo,09.00,10.30,01:30,00:00, +06.03.2018,Di,10.00,12.30,02:30,00:00, +07.03.2018,Mi,11.00,14.30,02:30,01:00, +08.03.2018,Do,11.00,13.30,02:30,00:00, +09.03.2018,Fr,09.00,10.00,01:00,00:00, +12.03.2018,Mo,12.00,12.30,00:30,00:00, +13.03.2018,Di,10.00,11.15,01:00,00:15, +14.03.2018,Mi,10.00,12.45,02:30,00:15, +15.03.2018,Do,09.00,09.30,00:30,00:00, +16.03.2018,Fr,12.00,13.30,01:30,00:00, +19.03.2018,Mo,09.00,13.00,04:00,00:00, +20.03.2018,Di,11.00,12.00,01:00,00:00, +21.03.2018,Mi,10.00,14.00,03:30,00:30, +22.03.2018,Do,10.00,10.30,00:30,00:00, +23.03.2018,Fr,12.00,14.15,02:00,00:15, +26.03.2018,Mo,09.00,10.00,01:00,00:00, +27.03.2018,Di,10.00,12.00,02:00,00:00, +28.03.2018,Mi,10.00,11.00,01:00,00:00, +29.03.2018,Do,12.00,13.30,01:30,00:00, +30.03.2018,Fr,12.00,13.00,01:00,00:00, +Gesamt,,,,38:30,, diff --git a/csv/2018-04-arbeitsstunden.csv b/csv/2018-04-arbeitsstunden.csv new file mode 100644 index 0000000000000000000000000000000000000000..91b94cefbf0c773736404b81c3e31acf69b29938 --- /dev/null +++ b/csv/2018-04-arbeitsstunden.csv @@ -0,0 +1,22 @@ +02.04.2018,Mo,12.00,15.00,03:00,00:00, +03.04.2018,Di,10.00,13.30,03:30,00:00,Urlaub +04.04.2018,Mi,10.00,11.00,01:00,00:00, +05.04.2018,Do,09.00,10.00,01:00,00:00, +06.04.2018,Fr,12.00,13.30,01:30,00:00, +09.04.2018,Mo,11.00,13.45,02:00,00:45, +10.04.2018,Di,10.00,12.00,02:00,00:00, +11.04.2018,Mi,10.00,10.30,00:30,00:00, +12.04.2018,Do,10.00,13.30,02:30,01:00, +13.04.2018,Fr,10.00,13.45,03:30,00:15, +16.04.2018,Mo,10.00,12.30,02:30,00:00, +17.04.2018,Di,12.00,15.30,03:30,00:00, +18.04.2018,Mi,09.00,12.00,03:00,00:00, +19.04.2018,Do,10.00,13.00,03:00,00:00, +20.04.2018,Fr,10.00,11.30,01:30,00:00, +23.04.2018,Mo,09.00,10.30,01:30,00:00, +24.04.2018,Di,11.00,13.00,02:00,00:00, +25.04.2018,Mi,12.00,16.00,03:00,01:00,Urlaub +26.04.2018,Do,12.00,14.30,02:30,00:00, +27.04.2018,Fr,09.00,11.30,02:30,00:00, +30.04.2018,Mo,12.00,15.00,03:00,00:00, +Gesamt,,,,48:30,, diff --git a/csv/2018-05-arbeitsstunden.csv b/csv/2018-05-arbeitsstunden.csv new file mode 100644 index 0000000000000000000000000000000000000000..9e87a4fb8fa54cef9b68e9a5845afc3119b73013 --- /dev/null +++ b/csv/2018-05-arbeitsstunden.csv @@ -0,0 +1,24 @@ +01.05.2018,Di,11.00,12.30,01:30,00:00, +02.05.2018,Mi,10.00,12.00,02:00,00:00, +03.05.2018,Do,12.00,13.15,01:00,00:15, +04.05.2018,Fr,11.00,13.30,02:30,00:00, +07.05.2018,Mo,12.00,13.30,01:30,00:00, +08.05.2018,Di,09.00,12.30,03:30,00:00, +09.05.2018,Mi,11.00,12.00,01:00,00:00, +10.05.2018,Do,10.00,11.15,01:00,00:15, +11.05.2018,Fr,12.00,14.00,02:00,00:00, +14.05.2018,Mo,10.00,13.00,03:00,00:00,Urlaub +15.05.2018,Di,09.00,12.00,03:00,00:00, +16.05.2018,Mi,10.00,12.00,01:00,01:00, +17.05.2018,Do,09.00,11.30,02:30,00:00, +18.05.2018,Fr,09.00,11.00,02:00,00:00, +21.05.2018,Mo,10.00,11.00,00:30,00:30, +22.05.2018,Di,12.00,13.30,01:30,00:00, +23.05.2018,Mi,10.00,12.30,02:30,00:00, +24.05.2018,Do,12.00,14.30,02:30,00:00, +25.05.2018,Fr,12.00,14.00,02:00,00:00, +28.05.2018,Mo,12.00,15.45,03:00,00:45, +29.05.2018,Di,12.00,14.00,02:00,00:00, +30.05.2018,Mi,09.00,10.00,01:00,00:00, +31.05.2018,Do,09.00,10.30,01:30,00:00, +Gesamt,,,,44:00,, diff --git a/pdf/2018-02-arbeitsstunden.pdf b/pdf/2018-02-arbeitsstunden.pdf new file mode 100644 index 0000000000000000000000000000000000000000..efedbd3d81ce182fe99b6ce3f7baf3e9df4952eb Binary files /dev/null and b/pdf/2018-02-arbeitsstunden.pdf differ diff --git a/pdf/2018-03-arbeitsstunden.pdf b/pdf/2018-03-arbeitsstunden.pdf new file mode 100644 index 0000000000000000000000000000000000000000..d200437df783473e2b4561906a32eeb0f715e1eb Binary files /dev/null and b/pdf/2018-03-arbeitsstunden.pdf differ diff --git a/pdf/2018-04-arbeitsstunden.pdf b/pdf/2018-04-arbeitsstunden.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ca14d9ceb80b262adf3913e99b7c19e09a1a6830 Binary files /dev/null and b/pdf/2018-04-arbeitsstunden.pdf differ diff --git a/pdf/2018-05-arbeitsstunden.pdf b/pdf/2018-05-arbeitsstunden.pdf new file mode 100644 index 0000000000000000000000000000000000000000..81490fcf99680dabf9e7b64b2cfce97805ff6d5d Binary files /dev/null and b/pdf/2018-05-arbeitsstunden.pdf differ diff --git a/python/.ipynb_checkpoints/arbeitsstundenzettel2-checkpoint.ipynb b/python/.ipynb_checkpoints/arbeitsstundenzettel2-checkpoint.ipynb deleted file mode 100644 index 7402a2beaf4092cfff2d29539fd6dcbd29fe6a93..0000000000000000000000000000000000000000 --- a/python/.ipynb_checkpoints/arbeitsstundenzettel2-checkpoint.ipynb +++ /dev/null @@ -1,594 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import scipy as sp\n", - "import datetime as dt\n", - "import holidays\n", - "import csv\n", - "import random\n", - "import itertools\n", - "import os\n", - "import os.path\n", - "import subprocess\n", - "import locale\n", - "import calendar as cal\n", - "\n", - "locale = locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def diff_full_months(start, end):\n", - "\n", - " start = start\n", - " end = end + dt.timedelta( days = 1 )\n", - " \n", - " full_months = (end.year - start.year) * 12 + end.month - start.month\n", - " \n", - " if start.day > end.day:\n", - " full_months = full_months - 1\n", - " \n", - " return full_months\n", - "\n", - "def diff_months(start, end):\n", - " \n", - " months = ((end + dt.timedelta( days = 1 )) - start).days / 30\n", - " \n", - " return months\n", - "\n", - "def diff_weeks(start, end):\n", - " \n", - " weeks = ((end + dt.timedelta( days = 1 )) - start).days / 7\n", - " \n", - " return weeks\n", - "\n", - "def get_calendar_week(date):\n", - " \n", - " calendar_week = date.isocalendar()[1]\n", - " \n", - " return int(calendar_week)\n", - "\n", - "def float2time(float_time):\n", - " \n", - " time = '{0:02.0f}.{1:02.0f}'.format(*divmod(float_time * 60, 60))\n", - " \n", - " return time\n", - "\n", - "def float2duration(float_time):\n", - " \n", - " time = '{0:02.0f}:{1:02.0f}'.format(*divmod(float(float_time) * 60, 60))\n", - " \n", - " return time\n", - "\n", - "def check_day_hours(list_of_workinghours, workingday_list_position, timestep):\n", - " \n", - " if list_of_workinghours[workingday_list_position][7] + timestep <= 6:\n", - " return True\n", - " else:\n", - " return False\n", - "\n", - "def check_week_hours(list_of_workinghours, workingday_list_position, timestep, list_of_filled_workinghours):\n", - " \n", - " current_calendar_week = get_calendar_week(list_of_workinghours[workingday_list_position][0])\n", - " list_of_affected_days = [same_calendar_week for same_calendar_week in list_of_workinghours if get_calendar_week(same_calendar_week[0]) == current_calendar_week]\n", - " list_of_other_affected_days = [same_calendar_week for same_calendar_week in list_of_filled_workinghours if get_calendar_week(same_calendar_week[0]) == current_calendar_week]\n", - " \n", - " for a in range(len(list_of_other_affected_days)):\n", - " list_of_affected_days.append(list_of_other_affected_days[a])\n", - " \n", - " week_sum = 0\n", - " for x in range(len(list_of_affected_days)):\n", - " week_sum = week_sum + list_of_affected_days[x][7]\n", - "\n", - " if week_sum + timestep <= 19:\n", - " return True\n", - " else:\n", - " return False\n", - "\n", - "def move_filled_day(list_of_workinghours, workingday_list_position, list_of_filled_workinghours):\n", - " \n", - " list_of_filled_workinghours.append(list_of_workinghours[workingday_list_position])\n", - " list_of_workinghours = [unfilled_day for unfilled_day in list_of_workinghours if unfilled_day not in list_of_filled_workinghours]\n", - "\n", - " return list_of_workinghours, list_of_filled_workinghours\n", - " print(\"Day \" + list_of_workinghours[workingday_list_position][0].strftime(\"%Y-%m-%d\") + \" full and moved.\")\n", - " \n", - "def move_filled_week(list_of_workinghours, workingday_list_position, list_of_filled_workinghours):\n", - " \n", - " current_calendar_week = get_calendar_week(list_of_workinghours[workingday_list_position][0])\n", - " list_of_affected_days = [same_calendar_week for same_calendar_week in list_of_workinghours if get_calendar_week(same_calendar_week[0]) == current_calendar_week]\n", - " \n", - " for x in range(len(list_of_affected_days)):\n", - " list_of_filled_workinghours.append(list_of_affected_days[x])\n", - " list_of_workinghours = [unfilled_day for unfilled_day in list_of_workinghours if unfilled_day not in list_of_filled_workinghours]\n", - "\n", - " return list_of_workinghours, list_of_filled_workinghours\n", - " print(\"Week \" + str(current_calendar_week) + \" full.\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def make_up_workinghours(month, start, end, workhours_per_week, workdays_per_week, already_worked = 0):\n", - " \n", - " full_months = diff_full_months(start, end)\n", - " months = diff_months(start, end)\n", - " weeks = diff_weeks(start, end)\n", - " days = (end - start).days + 1\n", - " workdays_total = int(workdays_per_week * weeks)\n", - " workhours_total = int(workhours_per_week * weeks)\n", - " workhours_per_month = int(workhours_per_week * weeks / months)\n", - " holidayhours_total = int(1 / 3 * workhours_per_week * full_months)\n", - " holidaydays_total = int(1 / 3 * workdays_per_week * full_months + 0.5)\n", - "\n", - " print(\"\")\n", - " print(\"Anzahl ganzer Monate: \", full_months)\n", - " print(\"Anzahl Monate: \", round(months,2))\n", - " print(\"Anzahl Wochen: \", round(weeks,2))\n", - " print(\"Anzahl Tagen: \", int(days))\n", - " print(\"Arbeitstage (Gesamt): \", workdays_total)\n", - " print(\"Arbeitsstunden (Gesamt): \", workhours_total)\n", - " print(\"Arbeitsstunden pro Monat (Ø):\", workhours_per_month)\n", - " print(\"Urlaubsanspruch in Stunden: \", holidayhours_total)\n", - " print(\"Urlaubstage: \", holidaydays_total)\n", - " print(\"\")\n", - " \n", - " full_date_list = [start + dt.timedelta( days = x ) for x in range(0, days)]\n", - " holiday_list = holidays.Holidays(start.year, 'BY').get_holiday_list()[0] + holidays.Holidays(end.year, 'BY').get_holiday_list()[0]\n", - "\n", - " for retry in range(10000):\n", - " \n", - " if (workhours_per_week <= 15 and workdays_per_week <= 4):\n", - " date_list = [day for day in full_date_list if day.weekday() < 5]\n", - " date_list = [day for day in date_list if day not in holiday_list]\n", - " elif (workhours_per_week <= 19 and workdays_per_week <= 5):\n", - " date_list = [day for day in full_date_list if day.weekday() < 6]\n", - " date_list = [day for day in date_list if day not in holiday_list]\n", - " elif (workhours_per_week <= 19):\n", - " print(\"Too many workdays per week given!\")\n", - " print(\"\")\n", - " break\n", - " else:\n", - " print(\"Too many workhours per week given!\")\n", - " print(\"\")\n", - " break\n", - "\n", - " made_up_workinghours = []\n", - " make_up_workinghours = []\n", - " \n", - " for i in range(len(date_list)):\n", - " \n", - " workingday = date_list[i]\n", - " make_up_start_time = random.randint(9,12)\n", - " make_up_end_time = random.randint(16,20)\n", - " make_up_duration = 0.0\n", - " make_up_break = sp.random.choice([0, 0.25, 0.5, 0.75, 1.0], p=[0.8, 0.05, 0.05, 0.05, 0.05])\n", - " \n", - " make_up_workinghours.append([workingday])\n", - " make_up_workinghours[i].append(workingday.strftime(\"%d.%m.%Y\"))\n", - " make_up_workinghours[i].append(cal.day_abbr[workingday.weekday()])\n", - " make_up_workinghours[i].append(make_up_start_time)\n", - " make_up_workinghours[i].append(float2time(make_up_start_time))\n", - " make_up_workinghours[i].append(make_up_end_time)\n", - " make_up_workinghours[i].append(float2time(make_up_end_time))\n", - " make_up_workinghours[i].append(make_up_duration)\n", - " make_up_workinghours[i].append(float2duration(make_up_duration))\n", - " make_up_workinghours[i].append(make_up_break)\n", - " make_up_workinghours[i].append(float2duration(make_up_break))\n", - " make_up_workinghours[i].append('')\n", - " \n", - " used_workinghours = 0\n", - " timestep = 0.5\n", - "\n", - " while (used_workinghours < workhours_total):\n", - " \n", - " if (used_workinghours + timestep > workhours_total):\n", - " timestep = timestep / 2\n", - "\n", - " if (len(make_up_workinghours) == 0):\n", - " break\n", - " \n", - " random_workingday = random.randint( 0, len(make_up_workinghours) - 1 ) \n", - " check_week = check_week_hours(make_up_workinghours, random_workingday, timestep, made_up_workinghours)\n", - " check_day = check_day_hours(make_up_workinghours, random_workingday, timestep)\n", - " \n", - " if (check_week == True and check_day == True):\n", - " \n", - " make_up_duration = make_up_workinghours[random_workingday][7] + timestep\n", - "\n", - " make_up_workinghours[random_workingday][7] = make_up_duration\n", - " make_up_workinghours[random_workingday][8] = float2duration(make_up_duration)\n", - "\n", - " used_workinghours = used_workinghours + timestep\n", - " \n", - " elif (check_week == True and check_day == False):\n", - " \n", - " make_up_workinghours, made_up_workinghours = move_filled_day(make_up_workinghours, random_workingday, made_up_workinghours)\n", - " \n", - " else:\n", - " \n", - " make_up_workinghours, made_up_workinghours = move_filled_week(make_up_workinghours, random_workingday, made_up_workinghours)\n", - " \n", - " if (used_workinghours == workhours_total):\n", - " \n", - " remaining_filled_days = [filled_day for filled_day in make_up_workinghours if filled_day[7] != 0] \n", - " \n", - " for j in range(len(remaining_filled_days)):\n", - " \n", - " made_up_workinghours.append(remaining_filled_days[j])\n", - " \n", - " break\n", - " \n", - " for i in range(len(made_up_workinghours)):\n", - " \n", - " made_up_start_time = made_up_workinghours[i][3]\n", - " made_up_duration = made_up_workinghours[i][7]\n", - " made_up_break = made_up_workinghours[i][9]\n", - "\n", - " made_up_end_time = made_up_start_time + made_up_duration + made_up_break\n", - " \n", - " made_up_workinghours[i][5] = made_up_end_time\n", - " made_up_workinghours[i][6] = float2time(made_up_end_time)\n", - " \n", - " used_holidayhours = 0\n", - "\n", - " while (used_holidayhours < holidayhours_total):\n", - "\n", - " random_holidayday = random.randint( 0, len(made_up_workinghours) - 1 )\n", - "\n", - " if (made_up_workinghours[random_holidayday][7] >= holidayhours_total / holidaydays_total - 0.5):\n", - "\n", - " made_up_workinghours[random_holidayday][11] = \"Urlaub\"\n", - " used_holidayhours = used_holidayhours + made_up_workinghours[random_holidayday][7]\n", - " \n", - " if (used_holidayhours == holidayhours_total):\n", - " \n", - " break\n", - " \n", - " if (used_workinghours == workhours_total and used_holidayhours == holidayhours_total):\n", - " \n", - " break\n", - " \n", - " if retry == 0:\n", - " print(\n", - "'''I finished making up working hours for you.\n", - "You can find the data in the csv-folder.'''\n", - " )\n", - " print(\"\")\n", - " elif retry + 1 < 10000:\n", - " print(\n", - "'''I ran into some trouble making up working hours.\n", - "I retried ''' + str(retry + 1) + ''' times, but now I finished.\n", - "You can find the data in the csv-folder.'''\n", - " )\n", - " print(\"\")\n", - " elif retry + 1 >= 10000:\n", - " print(\n", - "'''I ran into some trouble making up working hours.\n", - "I retried ''' + str(retry + 1) + ''' times and couldn't do it!\n", - "I have no idea what happend, please restart me!'''\n", - " )\n", - " print(\"\")\n", - "\n", - " return made_up_workinghours" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# User Input Vertragsdaten\n", - "\n", - "print(\"\")\n", - "start_date = input(\n", - "'''What is the start date of your contract? (dd.mm.yyyy)\n", - "> '''\n", - ")\n", - "end_date = input(\n", - "'''What is the end date of your contract? (dd.mm.yyyy)\n", - "> '''\n", - ")\n", - "\n", - "start = dt.datetime.strptime(start_date, \"%d.%m.%Y\")\n", - "end = dt.datetime.strptime(end_date, \"%d.%m.%Y\")\n", - "\n", - "print(\"\")\n", - "workhours_per_week = float(input(\n", - "'''How many hours do you have to work per week?\n", - "> '''\n", - "))\n", - "workdays_per_week = float(input(\n", - "'''How many days do you have to work per week?\n", - "> '''\n", - "))\n", - "\n", - "# User Input Persönliche Daten\n", - "\n", - "print(\"\")\n", - "name = input(\n", - "'''What is your last name?\n", - "> '''\n", - ")\n", - "firstname = input(\n", - "'''What is your first name(s)?\n", - "> '''\n", - ")\n", - "dateofbirth = input(\n", - "'''What is your date of birth? (dd.mm.yyyy)\n", - "> '''\n", - ")\n", - "\n", - "# User Input Institut\n", - "\n", - "print(\"\")\n", - "instituteabbr = input(\n", - "'''Please specify your institute?\n", - "You may use one of the following shortcodes:\n", - "\n", - " physics: Department Physik\n", - " ecap: Erlangen Centre for Astroparticle Physics\n", - " lap: Lehrstuhl für Angewandt Physik\n", - "\n", - "> '''\n", - ")\n", - "\n", - "list_of_implemented_institutes = [f for f in os.listdir(\"institutes/\") if os.path.isfile(os.path.join(\"institutes/\", f))]\n", - "\n", - "if instituteabbr in list_of_implemented_institutes:\n", - " with open('institutes/' + instituteabbr, 'r') as institutefile:\n", - " instituteinfo = institutefile.read()\n", - " exec(instituteinfo)\n", - "else:\n", - " print(\"\")\n", - " print(\"Your institute is not registered yet, please provide me with some details.\")\n", - " institute = input(\n", - "'''Name of your institute?\n", - "> '''\n", - " )\n", - " street = input(\n", - "'''Street of your institute?\n", - "> '''\n", - " )\n", - " city = input(\n", - "'''City of your institute?\n", - "> '''\n", - " )\n", - " postcode = input(\n", - "'''Post code of your institute?\n", - "> '''\n", - " )\n", - " faculty = input(\n", - "'''Which faculty does your institute belong to?\n", - "Currently implemented are:\n", - "\n", - " fau: Friedrich-Alexander-University\n", - " philtheo: Faculty of Humanities, Social Sciences and Theology\n", - " recht: Faculty of Law\n", - " wirt: Faculty of Business and Economics\n", - " rechtwirt: Faculty of Business, Economics and Law\n", - " med: Faculty of Medicine\n", - " nat: Faculty of Sciences\n", - " tech: Faculty of Engeneering\n", - " \n", - "> '''\n", - " )\n", - " wanna_give_me_a_logo = input(\n", - "'''Do you want to specify a file for your own logo? (yes/no)\n", - "> ''')\n", - " if (wanna_give_me_a_logo == \"y\" or wanna_give_me_a_logo == \"yes\"):\n", - " logo = input(\n", - "'''Where can I find the logo-file?\n", - "> '''\n", - " )\n", - " else:\n", - " print(\"I will proceed without an institute logo.\")\n", - "\n", - "# User Input Arbeitsstunden\n", - "\n", - "print(\"\")\n", - "filename = input(\n", - "'''Where can I find the csv-file containing working hours?\n", - "The file must be written in the following format:\n", - " \n", - " # iso-date , start , end , duration , break , comment\n", - " 2018-02-01 , 10:00 , 13:00 , 3:00 , 0:30 , \n", - " 2018-02-02 , 10:00 , 12:00 , 2:00 , , \n", - " 2018-02-05 , 10:00 , 11:00 , 1:00 , , \n", - " 2018-02-06 , 10:00 , 13:00 , 3:00 , , \n", - " 2018-02-08 , 10:00 , 13:00 , 3:00 , , Urlaub\n", - "\n", - "Header must start with number sign # to mark it as a comment!\n", - "If left empty I can still generate a preview.\n", - "\n", - "> '''\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "# Überprüfung Arbeitszeiten\n", - "\n", - "workinghours = []\n", - "\n", - "if filename == '':\n", - " \n", - " print(\"\")\n", - " should_i_make_up_workinghours = input(\n", - "'''Do you want me to generate a preview of my capabilities? (yes/no)\n", - "\n", - "> '''\n", - " )\n", - "\n", - " if (should_i_make_up_workinghours == \"y\" or should_i_make_up_workinghours == \"yes\"):\n", - " \n", - " made_up = make_up_workinghours(2, start, end, workhours_per_week, workdays_per_week)\n", - " workinghours.append(made_up)\n", - "\n", - " for m in range(int(diff_months(start,end) + 0.5)):\n", - "\n", - " month = (start.month + m - 1) % 12 + 1\n", - " monthname = cal.month_name[month]\n", - "\n", - " entries = [day for day in workinghours[0] if day[0].month == month]\n", - " entries.sort()\n", - "\n", - " year = entries[0][0].year\n", - "\n", - " filename = str(year) + '-' + '{0:0>2}'.format(month) + '-arbeitsstunden'\n", - "\n", - " with open('csv/' + filename + '.csv', 'w') as csvfile:\n", - " file = csv.writer(csvfile)\n", - " for row in entries:\n", - " file.writerow([row[1],row[2],row[4],row[6],row[8],row[10],row[11]])\n", - "\n", - " with open('tex/arbeitsstundenzettel.tex', 'r') as texfile:\n", - " texcode = texfile.read().replace('\\n', '')\n", - "\n", - " texcode = texcode.replace('===NAME===', name)\n", - " texcode = texcode.replace('===FIRSTNAME===', firstname)\n", - " texcode = texcode.replace('===DATEOFBIRTH===', dateofbirth)\n", - " texcode = texcode.replace('===FACULTY===', faculty)\n", - " texcode = texcode.replace('===INSTITUTE===', institute)\n", - " texcode = texcode.replace('===INSTITUTELOGO===', logo)\n", - " texcode = texcode.replace('===STREET===', street)\n", - " texcode = texcode.replace('===POSTCODE===', postcode)\n", - " texcode = texcode.replace('===CITY===', city)\n", - " texcode = texcode.replace('===MONTH===', monthname + ' ' + str(year))\n", - " texcode = texcode.replace('===FILENAME===', 'csv/' + filename + '.csv')\n", - "\n", - " with open(filename + '.tex', 'w') as texfile:\n", - " texfile.write(texcode)\n", - "\n", - " texcmd = ['rubber', '--pdf', filename + '.tex']\n", - " proc = subprocess.Popen(texcmd)\n", - " proc.communicate()\n", - "\n", - " returncode = proc.returncode\n", - " if not returncode == 0:\n", - " os.unlink(filename + '.tex')\n", - " print(\"\")\n", - " raise ValueError('Error {} executing command: {}'.format(returncode, ' '.join(texcmd)))\n", - " else:\n", - " print(\n", - "'''I finished the compilation of your working hours sheet for ''' + str(year) + '-' + '{0:0>2}'.format(month) + '''.\n", - "You can find it in the pdf-folder, it is named ''' + filename + '''.pdf.'''\n", - " )\n", - " print(\"\")\n", - "\n", - " os.unlink(filename + '.tex')\n", - " os.unlink(filename + '.log')\n", - " os.unlink(filename + '.aux')\n", - "\n", - " os.rename(filename + '.pdf', \"pdf/\" + filename + '.pdf')\n", - " \n", - "else:\n", - " \n", - " with open(filename, 'r') as csvfile:\n", - " file = csv.reader(\n", - " filter(lambda row: row[0]!='#', csvfile),\n", - " delimiter=',',\n", - " )\n", - " for row in file:\n", - " row = [x.strip(' ') for x in row]\n", - " workinghours.append(row)\n", - " \n", - " if (dt.datetime.strptime(workinghours[0][0], \"%Y-%m-%d\").date() - start).days < 0:\n", - " print(\"Es wurden Daten angegeben, die vor dem Beginn des Arbeitsvertrages liegen!\")\n", - " elif (dt.datetime.strptime(workinghours[0][0], \"%Y-%m-%d\").month - start.month) > 0:\n", - " missing_months_at_start = dt.datetime.strptime(workinghours[0][0], \"%Y-%m-%d\").month - start.month\n", - " if missing_months_at_start == 1:\n", - " print(\"Für den erste Monat in der Vertragslaufzeit wurden keine Arbeitszeiten angegeben!\")\n", - " else:\n", - " print(\"Für die ersten \" + str(missing_months_at_start) + \" Monate in der Vertragslaufzeit wurden keine Arbeitszeiten angegeben!\")\n", - "\n", - " if (end - dt.datetime.strptime(workinghours[-1][0], \"%Y-%m-%d\").date()).days < 0:\n", - " print(\"Es wurden Daten angegeben, die nach dem Ende des Arbeitsvertrages liegen!\")\n", - " elif (end.month - dt.datetime.strptime(workinghours[-1][0], \"%Y-%m-%d\").month) > 0:\n", - " missing_months_at_end = end.month - dt.datetime.strptime(workinghours[-1][0], \"%Y-%m-%d\").month\n", - " if missing_months_at_end == 1:\n", - " print(\"Für den letzten Monat in der Vertragslaufzeit wurden keine Arbeitszeiten angegeben!\")\n", - " else:\n", - " print(\"Für die letzten \" + str(missing_months_at_end) + \" Monate in der Vertragslaufzeit wurden keine Arbeitszeiten angegeben!\")\n", - "\n", - " made_up = make_up_workinghours(2, start, end, workhours_per_week, workdays_per_week)\n", - " workinghours.append(made_up)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/python/arbeitsstundenzettel.ipynb b/python/arbeitsstundenzettel.ipynb index 7402a2beaf4092cfff2d29539fd6dcbd29fe6a93..b87dc0bd23c8e36994a6683e20955b719a3ec941 100644 --- a/python/arbeitsstundenzettel.ipynb +++ b/python/arbeitsstundenzettel.ipynb @@ -454,12 +454,18 @@ "\n", " year = entries[0][0].year\n", "\n", + " total = 0\n", + " for x in range(len(entries)):\n", + " total = total + entries[x][7]\n", + " \n", " filename = str(year) + '-' + '{0:0>2}'.format(month) + '-arbeitsstunden'\n", "\n", " with open('csv/' + filename + '.csv', 'w') as csvfile:\n", " file = csv.writer(csvfile)\n", " for row in entries:\n", " file.writerow([row[1],row[2],row[4],row[6],row[8],row[10],row[11]])\n", + " \n", + " file.writerow([\"Gesamt\",\"\",\"\",\"\",float2duration(total),\"\",\"\"])\n", "\n", " with open('tex/arbeitsstundenzettel.tex', 'r') as texfile:\n", " texcode = texfile.read().replace('\\n', '')\n", diff --git a/python/arbeitsstundenzettel.py b/python/arbeitsstundenzettel.py index df955672c6fe45f59336c1e162f1e4452a0fb9a7..c20d82f136a196fca854882c5db7628cf934f735 100644 --- a/python/arbeitsstundenzettel.py +++ b/python/arbeitsstundenzettel.py @@ -438,12 +438,18 @@ if filename == '': year = entries[0][0].year + total = 0 + for x in range(len(entries)): + total = total + entries[x][7] + filename = str(year) + '-' + '{0:0>2}'.format(month) + '-arbeitsstunden' with open('csv/' + filename + '.csv', 'w') as csvfile: file = csv.writer(csvfile) for row in entries: file.writerow([row[1],row[2],row[4],row[6],row[8],row[10],row[11]]) + + file.writerow(["Gesamt","","","",float2duration(total),"",""]) with open('tex/arbeitsstundenzettel.tex', 'r') as texfile: texcode = texfile.read().replace('\n', '') diff --git a/tex/arbeitsstundenzettel.tex b/tex/arbeitsstundenzettel.tex index a4c9a7dc3b59c63e7fdd896379226099c0fb09a0..3310bc0e6363cab72d453ae294a41600bf1d8808 100644 --- a/tex/arbeitsstundenzettel.tex +++ b/tex/arbeitsstundenzettel.tex @@ -68,11 +68,18 @@ \csvreader[ late after line=\\\midrule, late after last line=\\\bottomrule, - filter not equal={\csvcolvi}{}, + filter not equal={\csvcolv}{}, ] {===FILENAME===} {} - {\csvcoli~ {\normalfont\small\csvcolii} & \csvcoliii~Uhr & \ifthenelse{\equal{\csvcolvi}{00:00}}{--}{\csvcolvi~Std.} & \csvcoliv~Uhr & \csvcolv~Std. & \csvcolvii} + { + \csvcoli~ {\normalfont\small\csvcolii} & + \ifthenelse{\equal{\csvcoliii}{}}{}{\csvcoliii~Uhr} & + \ifthenelse{\equal{\csvcolvi}{00:00}}{--}{\ifthenelse{\equal{\csvcolvi}{}}{}{\csvcolvi~Std.}} & + \ifthenelse{\equal{\csvcoliv}{}}{}{\csvcoliv~Uhr} & + \ifthenelse{\equal{\csvcolv}{}}{}{\csvcolv~Std.} & + \ifthenelse{\equal{\csvcolvii}{}}{}{\csvcolvii} + } \end{tabularx} \vfill \begin{tabularx}{\textwidth}{lcXcXc}