Skip to content
Snippets Groups Projects
Commit babb165a authored by Daniele Nicolodi's avatar Daniele Nicolodi
Browse files

timetracking: Timesheet parsing fixes

parent 491091f9
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ Mi 12 502 |164 11:31 - | |
Di 13 502 |164 9:18 - 17:31 164 | | 8.15 7.43 -0.32 +146.04
Mi 14 502 |164 8:55 - 17:36 164 | | 8.15 8.11 -0.04 +146.00
Do 15 502 | *BeA |303:Betriebsausflug | 8.15 8.15 +0.00 +146.00
Di 15 502 | #10:00 - 18:48 164 | | 8.15 8.18 +0.03 +151.46
Fr 16 503 |164 8:43 - 20:22 164 | | 6.15 10.00 +3.45 +149.45
Sa 17 951 | | | 0.00 0.00 +0.00 +149.45
So 18 952 | | | 0.00 0.00 +0.00 +149.45
......
......@@ -325,19 +325,19 @@ class Timesheet:
# ignore corrected zero amount
continue
if m := re.match(r'^(?:[A-Za-z]{2})?\s+(?P<day>\d{1,2})\s+\d{3}\s+\|'
r'(\d{3})?\s+((#|KoW)\s+)?(?:(?P<tin>\d{1,2}:\d{2})\s+-)?(?:\s+(?P<tout>\d{1,2}:\d{2}))?\s+((#|GeW)\s+)?(?:\*?(?P<code>\w+))?\s+(\d{3})?\s+\|'
r'(\d{3})?\s+((#|KoW)\s*)?(?:(?P<tin>\d{1,2}:\d{2})\s+-)?'
r'(?:\s+(?P<tout>\d{1,2}:\d{2}))?\s+((#|GeW)\s+)?(?:\*?(?P<code>\w+))?\s+(\d{3})?\s+\|'
r'(?P<notes>[^|]+)\|'
r'(?P<booking>\s+(?P<expected>\d+\.\d+)\s+(?P<worked>\d+\.\d+)'
r'\s+(?P<difference>[-+]\d+\.\d+)\s+(?P<balance>[-+]\d+\.\d+))?$', line):
r'(?:\s+(?P<expected>\d+\.\d+)\s+(?P<worked>\d+\.\d+)\s+(?P<difference>[-+]\d+\.\d+)\s+(?P<balance>[-+]\d+\.\d+))?$', line):
# entry
date = self.month.replace(day=int(m.group('day')))
tin = datetime.strptime(m.group('tin'), '%H:%M') if m.group('tin') else None
tout = datetime.strptime(m.group('tout'), '%H:%M') if m.group('tout') else None
if tin is not None or tout is not None:
self.days[date].entries.append((tin, tout))
if m.group('booking'):
for key in 'expected', 'worked', 'balance':
setattr(self.days[date], key, Duration.parse(m.group(key)))
for key in 'expected', 'worked', 'balance':
if value := m.group(key):
setattr(self.days[date], key, Duration.parse(value))
if m.group('code'):
self.days[date].code = Code(m.group('code'))
note = m.group('notes').strip()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment