The following configuration allows to apply a restriction on the sum of hours a user can log in a single day, counting work logs in any issue.
Enforce work logs through transitions
First we need to enforce users to log all the work using transitions in our workflows, instead of using "Log Work" operation at the issue screen. To do it we will:
Administration > Add-ons > Manage add-ons > Filter by "System" > Issue Operations Plugin > Disable module "View Issue Ops Bar Work Link"
User properties
We will use two user properties to store in order to implement this restriction. These two user properties are created and updated automatically, so we don't need to create them manually:
Now we are ready to add validations and post-functions to transitions "Log Work", that will implement the restriction on the number of hours a user can log per day. In this particular example we will restrict the sum of hours a user can log in any issue to 12 per day:
Add Boolean Validator with math, date-time or text-string terms to transitions "Log Work" with the following configuration:
Boolean expression used is:
userProperty("Time Logged Last Day (minutes)", %{00020}) = "" OR toNumber(userProperty("Time Logged Last Day (minutes)", %{00020})) + {00141} <= 12 * 60 OR datePart({00057}, LOCAL) > toNumber(userProperty("Date of Last Work Log", %{00020})) AND {00141} <= 12 * 60
Note that:
Once validation is added, transition "Log Work" will look like this:
We will add 4 post-functions to transitions "Log Work". Now we describe each of them by execution order:
Post-function 1: Set a field as a function of other fields
This post-function will store in "Ephemeral number 1" the value that should take user property "Time Logged Last Day (minutes)" after transition execution:
The 3 setting rules (one rule per line) used are:
[userProperty("Time Logged Last Day (minutes)", %{00020}) = "" OR userProperty("Date of Last Work Log", %{00020}) = ""]{00141}
[toNumber(userProperty("Date of Last Work Log", %{00020})) = datePart({00057}, LOCAL)]toNumber(userProperty("Time Logged Last Day (minutes)", %{00020})) + {00141}
[{00141} > 0]{00141}
Post-function 2: Set or create a user property
This post-function will set (or create in case it doesn't exist yet) user property "Time Logged Last Day (minutes)" with the value stored in "Ephemeral number 1":
Note that:
Post-function 3: Copy parsed text to a field
This post-function will store in "Ephemeral string 1" the value that should take user property "Date of Last Work Log" after transition execution:
Text to be parsed in advanced mode is:
{00141} > 0 ? datePart({00057}, LOCAL) : userProperty("Date of Last Work Log", %{00020})
Post-function 4: Set or create a user property
This post-function will set (or create in case it doesn't exist yet) user property "Date of Last Work Log" with the value stored in "Ephemeral string 1":
Note that:
Once all the post-functions have been inserted, transition "Log Work" will look like this: