diff --git a/kit_timesheet.md b/kit_timesheet.md index 092b475..d8d16d7 100644 --- a/kit_timesheet.md +++ b/kit_timesheet.md @@ -121,6 +121,9 @@ Named arguments: Whether the template should try to validate the data you entered (check if values look wrong, if you worked on a holiday, ...). If you turn this off, you can do funky things like work a negative amount of time or on Sundays. +- `sort` (default: `true`): + Whether the template should sort sort all entries in chronological order. If + you turn this off, entries are kept in their original order. - `year`: The year this time sheet is being generated for. - `month`: diff --git a/kit_timesheet.typ b/kit_timesheet.typ index 60de65d..63f404b 100644 --- a/kit_timesheet.typ +++ b/kit_timesheet.typ @@ -507,6 +507,7 @@ monthly_hours: 40, hourly_wage: [14.09], validate: true, + sort: true, carry_prev_month: "00:00", year: 2024, month: 1, @@ -521,6 +522,10 @@ entries = entries.pos() assert(entries.len() <= _kit_rows, message: "at most " + str(_kit_rows) + " entries allowed") + if sort { + entries = entries.sorted(key: entry => (entry.day, entry.end, entry.start)) + } + let monthly = monthly_hours * 60 let holiday = entries.filter(e => e.note == notes.Urlaub).map(e => e.duration).sum(default: 0) let total = entries.map(e => e.duration).sum(default: 0)