Skip to content

Commit

Permalink
Merge pull request #187 from dbosk/send-copy-of-final-timesheet-to-TA
Browse files Browse the repository at this point in the history
Improves `timesheets show`, adapts to HR+ 8
  • Loading branch information
dbosk authored Oct 18, 2024
2 parents 25a6d65 + 06baacb commit 3f10704
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 17 deletions.
26 changes: 24 additions & 2 deletions src/nytid/cli/hr.nw
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,8 @@ We let this command just print a summary of each time sheet.
def cli_show_timesheets(<<argument [[user_regex]] to match TAs>> = ".*",
<<option [[reverse]] to adjust sort order>>,
<<option [[all]] to show all timesheets>>,
<<option for CSV delimiter>>):
<<option for CSV delimiter>>,
<<option for [[date_regex]] to filter by date>>,):
"""
Shows stored time sheets for TAs.
"""
Expand All @@ -1668,6 +1669,7 @@ def cli_show_timesheets(<<argument [[user_regex]] to match TAs>> = ".*",
<<set [[timesheets]] depending on [[all]]>>
for timesheet in timesheets:
<<skip if [[user_regex]] doesn't match [[timesheet]]>>
<<skip if [[date_regex]] doesn't match [[timesheet]]>>
<<skip if we've already printed a timesheet for [[user]]>>
<<print [[timesheet]]>>
<<option [[reverse]] to adjust sort order>>=
Expand All @@ -1694,6 +1696,8 @@ timesheets = sorted(timesheets_dir.glob(f"*.json"),
@

We can check if the time sheet file matches the user's username.
For example, the file name might be
[[dbosk.2024-09-26T14:28:39.434834.json]].
<<skip if [[user_regex]] doesn't match [[timesheet]]>>=
username = timesheet.name.split(".")[0]
if not user_pattern.match(username):
Expand All @@ -1702,14 +1706,32 @@ if not user_pattern.match(username):
user_pattern = re.compile(user_regex)
@

In the same fashion, we want to filter on dates.
<<skip if [[date_regex]] doesn't match [[timesheet]]>>=
if date_regex and not date_pattern.match(timesheet.name.split(".")[1]):
continue
<<timesheets iteration variables>>=
if date_regex:
date_pattern = re.compile(date_regex)
<<option for [[date_regex]] to filter by date>>=
date_regex: Annotated[str, date_regex_opt] = None
<<argument and option definitions>>=
date_regex_opt = typer.Option(help="Filter time sheets by date. This is a "
"regex matching the date of the time "
"sheet.")
@


In the same fashion, we can check if we've already printed a time sheet for the
user.
If we haven't printed one, we add the user to the set of printed users and
proceed to the printing step.
We need to do like this since we might want to print the newest time sheet of
several matching users.
Consequently, we don't want to skip when we want to print all time sheets for
the TAs.
<<skip if we've already printed a timesheet for [[user]]>>=
if username in printed_users:
if username in printed_users and not all:
continue
else:
printed_users.add(username)
Expand Down
43 changes: 28 additions & 15 deletions src/nytid/cli/init.nw
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ The same if the UG group is empty (since that would regex match any course in
UG).
<<look up [[ug_path]], or skip if none exists>>=
ug_path=$(nytid courses config ${course} ug.assistants 2>/dev/null \
| sed "s/.*= //")
| sed "s/.*= //")
test "$?" -eq 0 || continue
test -n "${ug_path}" || continue
@
Expand Down Expand Up @@ -878,7 +878,16 @@ And if so, we can create the contract with the correct start date.

\subsection{Generating time sheets for hourly TAs}

The TAs that are paid by the hour must submit time sheets according to HR.
Now with the new HR system, HR+ 8, the TAs should report their hours directly
in that system.
Then the course responsible should approve them.
This means that we no longer need the [[nytid hr timesheets generate]]
functionality as it was originally intended.
But we can describe how it works, in case we can use it for something else.

The idea of the previous system was as follows.
The TAs that are paid by the hour previously had to submit time sheets
according to HR.
However, then we must check them.
It's better that we generate them automatically from the sign-up sheet, then we
know they're correct as long as the sign-up sheet is correct.
Expand Down Expand Up @@ -917,7 +926,7 @@ end date.
Another thing to note is that we used the [[--draft]] option.
This will generate a draft time sheet directly in the terminal.
Without the draft option, we would get a file with the signed time sheet, you
can see it in \cref{FigTimesheet}.
can see the signed time sheet in \cref{FigTimesheet}.

\begin{figure}
\centering
Expand Down Expand Up @@ -955,7 +964,8 @@ This way we can do calculations on the data, which we need to do (see

With this construction, we can automate the generation of time sheets on a
monthly basis.
<<nytid.monthly.sh>>=
However, we no longer need this, this is just for reference.
<<sending signed time sheets>>=
<<timesheets variables>>

for course in ${TIMESHEETS_COURSES}
Expand Down Expand Up @@ -1089,18 +1099,21 @@ reference.

\subsection{Send time-sheet drafts to the TAs}

We shouldn't send the time sheets to HR before the TAs have had a chance to
check them.
They will sometimes have things to update due to changes, even though all
One thing we can continue doing, despite the new HR+ 8 system, is to send
drafts of the time sheets to the TAs.
Then the TAs can use them as a base to report their hours in HR+ 8.

The TAs will sometimes have things to update due to changes, even though all
changes should be made in advance.
So we want them to update the sheet before they submit to HR+.
The same goes for the amanuensis, we want to send them a draft of the mertid
that they've done.
We want them to keep track of how many hours too many or too few they've
worked.
And give them the option to report the hours to get paid.

The structure of the code is similar to that of
[[<<nytid.monthly.sh>>]].
[[<<sending signed time sheets>>]].
<<nytid.premonthly.sh>>=
<<timesheet draft variables>>
<<timesheet draft functions>>
Expand Down Expand Up @@ -1175,23 +1188,23 @@ Du har ${sum_hours} timmar i bokningsarket för ${course}.

$(if <<[[sum_hours]] > 0>>; then
echo "
Den första nästa månad (${next_month}) kommer alla tider i
bokningsarket att tidrapporteras automatiskt åt dig. För
tillfället är det tiderna nedan (även bifogat som CSV-fil).
Du kan rapportera in timmarna nedan i KTH HR. Gör det kring
månadsskiftet för att få betalt i slutet av ${next_month}.
Tiderna finns även bifogat som CSV-fil.
" | fmt
elif <<[[sum_hours]] < 0>>; then
echo "
Du har just nu fått mer betalt än du har jobbat. Du behöver
jobba in de timmar som saknas.
jobba in de timmar som saknas. Se nedan.
" | fmt
else
echo "
Du har ändrat pass, men alla timmar går jämnt ut.
" | fmt
fi)

Om något är fel, uppdatera bokningsarket eller svara på detta
mail snarast!
Om något är fel, uppdatera bokningsarket och svara på detta
mail!

Daniel

Expand Down Expand Up @@ -1238,7 +1251,7 @@ CSV-filen.)
$(if <<[[sum_hours]] > 0>>; then
echo "
Du ligger på plus och kan rapportera in ${sum_hours} timmar som
mertid i HR+. Men svara då på detta mail och meddela att du gör det.
mertid i KTH HR. Men svara då på detta mail och meddela att du gör det.
Bra jobbat!
" | fmt
elif <<[[sum_hours]] < 0>>; then
Expand Down

0 comments on commit 3f10704

Please sign in to comment.