diff --git a/.csv b/.csv deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/.ipynb_checkpoints/arbeitsstundenzettel-checkpoint.ipynb b/.ipynb_checkpoints/arbeitsstundenzettel-checkpoint.ipynb deleted file mode 100644 index 88f300398e5f9df7ca882b2534f57146a9e01486..0000000000000000000000000000000000000000 --- a/.ipynb_checkpoints/arbeitsstundenzettel-checkpoint.ipynb +++ /dev/null @@ -1,682 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import scipy as sp\n", - "import datetime as dt\n", - "import holidays\n", - "import csv\n", - "import random\n", - "import itertools" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "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_time * 60, 60))\n", - " \n", - " return time" - ] - }, - { - "cell_type": "code", - "execution_count": 87, - "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", - " \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(2):\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", - " break\n", - " else:\n", - " print(\"Too many workhours per week given!\")\n", - " break\n", - " \n", - " made_up_workinghours = []\n", - " \n", - " if (workdays_total + workdays_per_week > len(date_list)):\n", - " for j in range(len(date_list)):\n", - " made_up_workinghours.append([date_list[j]])\n", - " else:\n", - " for j in range(workdays_total + workdays_per_week):\n", - "\n", - " random_workingday = random.choice(date_list)\n", - " date_list = [remaining_date for remaining_date in date_list if remaining_date != random_workingday]\n", - "\n", - " made_up_workinghours.append([random_workingday])\n", - " \n", - " made_up_workinghours.sort()\n", - " used_workinghours = 0\n", - "\n", - " for i in range(len(made_up_workinghours)):\n", - " \n", - " if (used_workinghours == workhours_total):\n", - " \n", - " break\n", - "\n", - " elif (used_workinghours < workhours_total) and (i == len(made_up_workinghours) - 1):\n", - " print(\"Hey:\" + str(workhours_total-used_workinghours))\n", - " print(weeks)\n", - " \n", - " missing_hours = workhours_total - used_workinghours\n", - " missing_hours_partial = int(missing_hours / int(weeks) * 12) / 12\n", - " \n", - " print(missing_hours_partial)\n", - " \"\"\"\n", - " for m in range(len(made_up_workinghours)):\n", - " \n", - " if (m % workdays_per_week) - workdays_per_week == 0:\n", - " \n", - " print(m)\n", - " if (workhours_total - used_workinghours > missing_hours_partial):\n", - " made_up_workinghours[m][6] = made_up_workinghours[m][6] + missing_hours_partial\n", - " made_up_workinghours[m][5] = float2duration(made_up_workinghours[m][6])\n", - " used_workinghours = used_workinghours + missing_hours_partial\n", - " else:\n", - " remaining_hours = workhours_total - used_workinghours\n", - " made_up_workinghours[m][6] = made_up_workinghours[m][6] + remaining_hours\n", - " made_up_workinghours[m][5] = float2duration(made_up_workinghours[m][6])\n", - " used_workinghours = used_workinghours + remaining_hours\n", - " \"\"\" \n", - " break\n", - " \n", - " elif (used_workinghours > workhours_total):\n", - " \n", - " overworked_hours = used_workinghours - workhours_total\n", - "\n", - " made_up_workinghours[i-1][6] = made_up_workinghours[i-1][6] - overworked_hours\n", - " made_up_workinghours[i-1][5] = float2duration(made_up_workinghours[i-1][6])\n", - " used_workinghours = used_workinghours - overworked_hours\n", - " \n", - " break\n", - "\n", - " else:\n", - " \n", - " if (workhours_per_week <= 14):\n", - " made_up_duration = int(workhours_per_week / workdays_per_week) + (random.randint(-2,2) / 4) + 0.5\n", - " elif (workhours_per_week <= 17):\n", - " made_up_duration = int(workhours_per_week / workdays_per_week) + (random.randint(-2,2) / 4)\n", - " else:\n", - " made_up_duration = int(workhours_per_week / workdays_per_week * 2) / 2\n", - "\n", - " made_up_start_time = random.randint(9,12)\n", - "\n", - " made_up_break = random.randint(0,4) / 4\n", - " made_up_end_time = made_up_start_time + made_up_duration + made_up_break\n", - "\n", - " made_up_workinghours[i].append(float2time(made_up_start_time))\n", - " made_up_workinghours[i].append(made_up_start_time)\n", - " made_up_workinghours[i].append(float2time(made_up_end_time))\n", - " made_up_workinghours[i].append(made_up_end_time)\n", - " made_up_workinghours[i].append(float2duration(made_up_duration))\n", - " made_up_workinghours[i].append(made_up_duration)\n", - " made_up_workinghours[i].append(float2duration(made_up_break))\n", - " made_up_workinghours[i].append(made_up_break)\n", - " made_up_workinghours[i].append(6)\n", - " made_up_workinghours[i].append(6)\n", - "\n", - " used_workinghours = used_workinghours + made_up_duration\n", - " \n", - " made_up_workinghours = [empty_day for empty_day in made_up_workinghours if len(empty_day) > 1]\n", - " \n", - " for workingday in range(len(made_up_workinghours)):\n", - " \n", - " workingday_date = made_up_workinghours[workingday][0]\n", - " this_calendar_week = get_calendar_week(workingday_date)\n", - " \n", - " workingdays_in_this_calendar_week = [workingdays[0] for workingdays in made_up_workinghours if get_calendar_week(workingdays[0]) == this_calendar_week]\n", - " workingdays_in_this_calendar_week_deduplicated = []\n", - " \n", - " for date in workingdays_in_this_calendar_week:\n", - " if date not in workingdays_in_this_calendar_week_deduplicated:\n", - " workingdays_in_this_calendar_week_deduplicated.append(date)\n", - " \n", - " #print(workingdays_in_this_calendar_week_deduplicated)\n", - " week_sum = 0\n", - " \n", - " for date in workingdays_in_this_calendar_week_deduplicated:\n", - " for workinghours in made_up_workinghours:\n", - " if date == workinghours[0]:\n", - " week_sum = week_sum + workinghours[6]\n", - "\n", - " if (week_sum > 19):\n", - " week_check_success = False\n", - " print(week_sum)\n", - " #break\n", - " else:\n", - " week_check_success = True\n", - " print(week_sum)\n", - " \n", - " #print(week_check_success)\n", - "\n", - " if (used_workinghours == workhours_total) and (week_check_success == True):\n", - " break\n", - "\n", - " #print(str(retry/100) + \"%\", end='\\r')\n", - " \n", - " if retry == 0:\n", - " print(\"I did it!\")\n", - " elif retry + 1 < 10000:\n", - " print(\"I ran into some trouble making up working hours. I retried \" + str(retry + 1) + \" times, but now I did it!\")\n", - " elif retry + 1 >= 10000:\n", - " print(\"I ran into some trouble making up working hours. I retried \" + str(retry + 1) + \" times and couldn't do it! I have no idea what happend, please restart me!\")\n", - "\n", - " return made_up_workinghours" - ] - }, - { - "cell_type": "code", - "execution_count": 88, - "metadata": {}, - "outputs": [], - "source": [ - "# Definition der Vertragsdaten\n", - "\n", - "start = dt.date(2018, 1, 1)\n", - "end = dt.date(2018, 3, 31)\n", - "\n", - "workhours_per_week = 19\n", - "workdays_per_week = 5" - ] - }, - { - "cell_type": "code", - "execution_count": 89, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Anzahl ganzer Monate: 3\n", - "Anzahl Monate: 3.0\n", - "Anzahl Wochen: 12.86\n", - "Anzahl Tagen: 90\n", - "Arbeitstage (Gesamt): 64\n", - "Arbeitsstunden (Gesamt): 244\n", - "Arbeitsstunden pro Monat (Ø): 81\n", - "Urlaubsanspruch in Stunden: 19\n", - "Urlaubstage: 5\n", - "Hey:6.0\n", - "12.857142857142858\n", - "0.5\n", - "10.5\n", - "10.5\n", - "10.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "14.0\n", - "14.0\n", - "14.0\n", - "14.0\n", - "Hey:6.0\n", - "12.857142857142858\n", - "0.5\n", - "10.5\n", - "10.5\n", - "10.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "14.0\n", - "14.0\n", - "14.0\n", - "14.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "14.0\n", - "14.0\n", - "14.0\n", - "14.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "21.0\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "17.5\n", - "I ran into some trouble making up working hours. I retried 2 times, but now I did it!\n", - "[[[datetime.date(2018, 1, 3) '09.00' 9 '12.30' 12.5 '03:30' 3.5 '00:00'\n", - " 0.0 6 6]\n", - " [datetime.date(2018, 1, 4) '09.00' 9 '12.45' 12.75 '03:30' 3.5 '00:15'\n", - " 0.25 6 6]\n", - " [datetime.date(2018, 1, 5) '09.00' 9 '13.15' 13.25 '03:30' 3.5 '00:45'\n", - " 0.75 6 6]\n", - " [datetime.date(2018, 1, 8) '11.00' 11 '14.45' 14.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 9) '09.00' 9 '12.30' 12.5 '03:30' 3.5 '00:00'\n", - " 0.0 6 6]\n", - " [datetime.date(2018, 1, 10) '10.00' 10 '14.00' 14.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 1, 11) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 1, 12) '12.00' 12 '15.45' 15.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 13) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 1, 15) '11.00' 11 '14.45' 14.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 17) '09.00' 9 '12.45' 12.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 18) '10.00' 10 '14.00' 14.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 1, 20) '10.00' 10 '13.45' 13.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 22) '12.00' 12 '15.30' 15.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 1, 23) '12.00' 12 '15.45' 15.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 24) '11.00' 11 '15.15' 15.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 1, 25) '12.00' 12 '15.45' 15.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 1, 26) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 1, 27) '12.00' 12 '15.30' 15.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 1, 29) '11.00' 11 '15.15' 15.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 1, 31) '12.00' 12 '15.30' 15.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 2, 1) '11.00' 11 '14.45' 14.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 2, 2) '09.00' 9 '13.15' 13.25 '03:30' 3.5 '00:45'\n", - " 0.75 6 6]\n", - " [datetime.date(2018, 2, 5) '09.00' 9 '13.30' 13.5 '03:30' 3.5 '01:00'\n", - " 1.0 6 6]\n", - " [datetime.date(2018, 2, 6) '09.00' 9 '13.00' 13.0 '03:30' 3.5 '00:30'\n", - " 0.5 6 6]\n", - " [datetime.date(2018, 2, 7) '10.00' 10 '13.30' 13.5 '03:30' 3.5 '00:00'\n", - " 0.0 6 6]\n", - " [datetime.date(2018, 2, 8) '10.00' 10 '14.00' 14.0 '03:30' 3.5 '00:30'\n", - " 0.5 6 6]\n", - " [datetime.date(2018, 2, 9) '11.00' 11 '14.30' 14.5 '03:30' 3.5 '00:00'\n", - " 0.0 6 6]\n", - " [datetime.date(2018, 2, 10) '12.00' 12 '15.30' 15.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 2, 13) '09.00' 9 '13.30' 13.5 '03:30' 3.5 '01:00'\n", - " 1.0 6 6]\n", - " [datetime.date(2018, 2, 14) '11.00' 11 '15.15' 15.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 15) '09.00' 9 '12.30' 12.5 '03:30' 3.5 '00:00'\n", - " 0.0 6 6]\n", - " [datetime.date(2018, 2, 16) '12.00' 12 '16.15' 16.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 17) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 2, 19) '09.00' 9 '12.45' 12.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 2, 20) '11.00' 11 '14.30' 14.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 2, 21) '09.00' 9 '13.15' 13.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 22) '12.00' 12 '16.15' 16.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 23) '11.00' 11 '15.30' 15.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 2, 24) '11.00' 11 '15.15' 15.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 26) '12.00' 12 '16.15' 16.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 27) '12.00' 12 '16.15' 16.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 2, 28) '12.00' 12 '15.30' 15.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 3, 1) '11.00' 11 '14.45' 14.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 3, 2) '12.00' 12 '15.45' 15.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 3, 3) '11.00' 11 '15.15' 15.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 3, 5) '10.00' 10 '14.30' 14.5 '03:30' 3.5 '01:00'\n", - " 1.0 6 6]\n", - " [datetime.date(2018, 3, 7) '09.00' 9 '13.00' 13.0 '03:30' 3.5 '00:30'\n", - " 0.5 6 6]\n", - " [datetime.date(2018, 3, 8) '11.00' 11 '14.45' 14.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 3, 9) '11.00' 11 '15.00' 15.0 '03:30' 3.5 '00:30'\n", - " 0.5 6 6]\n", - " [datetime.date(2018, 3, 10) '10.00' 10 '14.15' 14.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 3, 12) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 3, 13) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 3, 14) '09.00' 9 '13.00' 13.0 '03:30' 3.5 '00:30'\n", - " 0.5 6 6]\n", - " [datetime.date(2018, 3, 15) '10.00' 10 '13.45' 13.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 3, 16) '10.00' 10 '14.15' 14.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 3, 17) '11.00' 11 '15.00' 15.0 '03:30' 3.5\n", - " '00:30' 0.5 6 6]\n", - " [datetime.date(2018, 3, 19) '11.00' 11 '15.30' 15.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 3, 20) '11.00' 11 '14.30' 14.5 '03:30' 3.5\n", - " '00:00' 0.0 6 6]\n", - " [datetime.date(2018, 3, 21) '12.00' 12 '16.30' 16.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 3, 22) '09.00' 9 '13.15' 13.25 '03:30' 3.5\n", - " '00:45' 0.75 6 6]\n", - " [datetime.date(2018, 3, 23) '10.00' 10 '14.30' 14.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 3, 24) '10.00' 10 '13.45' 13.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]\n", - " [datetime.date(2018, 3, 26) '12.00' 12 '16.30' 16.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 3, 27) '09.00' 9 '13.00' 13.0 '03:30' 3.5 '00:30'\n", - " 0.5 6 6]\n", - " [datetime.date(2018, 3, 28) '10.00' 10 '14.30' 14.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 3, 29) '10.00' 10 '14.30' 14.5 '03:30' 3.5\n", - " '01:00' 1.0 6 6]\n", - " [datetime.date(2018, 3, 30) '10.00' 10 '13.45' 13.75 '03:30' 3.5\n", - " '00:15' 0.25 6 6]]]\n", - "238.0\n" - ] - } - ], - "source": [ - "# Definition der Arbeitszeiten\n", - "# Beispieldatei\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", - "# Hinweis: Die Headerzeile muss mit # auskommentiert sein!\n", - "\n", - "filename = 'arbeitszeiten.csv'\n", - "filename = None\n", - "\n", - "workinghours = []\n", - "\n", - "if filename == None:\n", - " \n", - " made_up = make_up_workinghours(2, start, end, workhours_per_week, workdays_per_week)\n", - " workinghours.append(made_up)\n", - "\n", - "else:\n", - " \n", - " with open(filename) 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)\n", - " \n", - "print(sp.asarray(workinghours))\n", - "\n", - "gesamt = 0\n", - "\n", - "for x in range(len(workinghours[0])):\n", - " gesamt = gesamt + workinghours[0][x][6]\n", - " \n", - "print(gesamt)" - ] - }, - { - "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/.ipynb_checkpoints/arbeitsstundenzettel-gui-checkpoint.ipynb b/.ipynb_checkpoints/arbeitsstundenzettel-gui-checkpoint.ipynb deleted file mode 100644 index 71f4d46eca0edda84f0c157e96ce9d64ea738080..0000000000000000000000000000000000000000 --- a/.ipynb_checkpoints/arbeitsstundenzettel-gui-checkpoint.ipynb +++ /dev/null @@ -1,147 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import sys\n", - "from PyQt5.QtCore import QDate, QTime, QDateTime, Qt\n", - "from PyQt5.QtWidgets import QWidget, QToolTip, QPushButton, QApplication, QDesktopWidget, QMainWindow, QAction, qApp\n", - "from PyQt5.QtGui import QIcon, QFont " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2018-05-29\n", - "Tuesday, May 29, 2018\n", - "Tue May 29 18:23:20 2018\n", - "6:23:20 PM CEST\n" - ] - } - ], - "source": [ - "now = QDate.currentDate()\n", - "\n", - "print(now.toString(Qt.ISODate))\n", - "print(now.toString(Qt.DefaultLocaleLongDate))\n", - "\n", - "datetime = QDateTime.currentDateTime()\n", - "\n", - "print(datetime.toString())\n", - "\n", - "time = QTime.currentTime()\n", - "\n", - "print(time.toString(Qt.DefaultLocaleLongDate))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Hauptfenster(QMainWindow):\n", - " \n", - " def __init__(self):\n", - " super().__init__()\n", - " \n", - " self.initUI()\n", - " \n", - " \n", - " def initUI(self):\n", - " \n", - " QToolTip.setFont(QFont('SansSerif', 10))\n", - " \n", - " open = QAction('&Open', self)\n", - " open.setStatusTip('open csv-file')\n", - " open.setShortcut('Ctrl+O')\n", - " \n", - " save = QAction('&Save', self)\n", - " save.setStatusTip('save as csv-file')\n", - " save.setShortcut('Ctrl+S')\n", - " \n", - " create = QAction('&Create', self)\n", - " create.setStatusTip('create pdf-file')\n", - " create.setShortcut('Ctrl+P')\n", - " \n", - " exit = QAction('&Exit', self) \n", - " exit.setStatusTip('exit application')\n", - " exit.setShortcut('Ctrl+Q')\n", - " exit.triggered.connect(qApp.quit)\n", - "\n", - " self.resize(1080, 768)\n", - " self.center()\n", - " self.setWindowTitle('Arbeitsstundenzettel für Faule')\n", - " self.setWindowIcon(QIcon('icon.png')) \n", - "\n", - " self.statusBar().showMessage('Copyright Felix Lammermann, 2018, Version: Alpha-1.00')\n", - "\n", - " menubar = self.menuBar()\n", - " fileMenu = menubar.addMenu('&File')\n", - " fileMenu.addAction(open)\n", - " fileMenu.addAction(save)\n", - " fileMenu.addAction(create)\n", - " fileMenu.addAction(exit)\n", - "\n", - " self.show()\n", - " \n", - " def center(self):\n", - " \n", - " qr = self.frameGeometry()\n", - " cp = QDesktopWidget().availableGeometry().center()\n", - " qr.moveCenter(cp)\n", - " self.move(qr.topLeft())\n", - " \n", - "if __name__ == '__main__':\n", - " \n", - " app = QApplication(sys.argv)\n", - " ex = Hauptfenster()\n", - " sys.exit(app.exec_())" - ] - }, - { - "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/.ipynb_checkpoints/arbeitsstundenzettel2-checkpoint.ipynb b/.ipynb_checkpoints/arbeitsstundenzettel2-checkpoint.ipynb deleted file mode 100644 index 65e08e76eeda45f9d417fb7c60eb7bc157215c3b..0000000000000000000000000000000000000000 --- a/.ipynb_checkpoints/arbeitsstundenzettel2-checkpoint.ipynb +++ /dev/null @@ -1,488 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 80, - "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 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": 96, - "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_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": 210, - "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", - " \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", - " break\n", - " else:\n", - " print(\"Too many workhours per week given!\")\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 = random.randint(0,4) / 4\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 = 1\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", - " 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 and len(made_up_workinghours) < workdays_total + workdays_per_week):\n", - " \n", - " break\n", - " \n", - " if retry == 0:\n", - " print(\"I did it!\")\n", - " elif retry + 1 < 10000:\n", - " print(\"I ran into some trouble making up working hours. I retried \" + str(retry + 1) + \" times, but now I did it!\")\n", - " elif retry + 1 >= 10000:\n", - " print(\"I ran into some trouble making up working hours. I retried \" + str(retry + 1) + \" times and couldn't do it! I have no idea what happend, please restart me!\")\n", - "\n", - " return made_up_workinghours" - ] - }, - { - "cell_type": "code", - "execution_count": 196, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Last name: Lammermann\n", - "First name(s): Felix\n", - "Date of birth: 23.01.1995\n", - "Name of Institute: Physikalisches Institut\n", - "Street of Institute: Erwin-Rommel-Straße 1\n", - "Post code of Institute: 91058\n", - "City of Institute: Erlangen\n" - ] - } - ], - "source": [ - "# Definition der Vertragsdaten\n", - "\n", - "start = dt.date(2018, 11, 1)\n", - "end = dt.date(2019, 1, 31)\n", - "\n", - "workhours_per_week = 10\n", - "workdays_per_week = 3\n", - "\n", - "# User Input Persönliche Daten\n", - "\n", - "name = input(\"Last name: \")\n", - "firstname = input(\"First name(s): \")\n", - "dateofbirth = input(\"Date of birth: \")\n", - "institute = input(\"Name of Institute: \")\n", - "street = input(\"Street of Institute: \")\n", - "postcode = input(\"Post code of Institute: \")\n", - "city = input(\"City of Institute: \")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Anzahl ganzer Monate: 3\n", - "Anzahl Monate: 3.07\n", - "Anzahl Wochen: 13.14\n", - "Anzahl Tagen: 92\n", - "Arbeitstage (Gesamt): 39\n", - "Arbeitsstunden (Gesamt): 131\n", - "Arbeitsstunden pro Monat (Ø): 42\n", - "Urlaubsanspruch in Stunden: 10\n", - "Urlaubstage: 3\n" - ] - } - ], - "source": [ - "workdays_per_week = 3\n", - "# Definition der Arbeitszeiten\n", - "# Beispieldatei\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", - "# Hinweis: Die Headerzeile muss mit # auskommentiert sein!\n", - "\n", - "filename = 'arbeitszeiten.csv'\n", - "filename = None\n", - "\n", - "workinghours = []\n", - "\n", - "if filename == None:\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('===INSTITUTE===', institute)\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 = ['pdflatex', '-interaction', 'nonstopmode', filename + '.tex']\n", - " proc = subprocess.Popen(texcmd)\n", - " proc.communicate()\n", - "\n", - " retcode = proc.returncode\n", - " if not retcode == 0:\n", - " os.unlink(filename + '.tex')\n", - " raise ValueError('Error {} executing command: {}'.format(retcode, ' '.join(texcmd))) \n", - "\n", - " os.unlink(filename + '.tex')\n", - " os.unlink(filename + '.log')\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 -}