How can I calculate the contractual penalties for issues that are in SLA breached?

Hi @Fra!

I am sorry for the delay in providing you with an answer!

Firstly, to calculate how many days are over the target, it would be necessary to know the targets. eazyBI does not import SLA target hours as separate property as JIRA does not provide this information for all states during a cycle.

There is an option to use JavaScript calculated field to get the goal where possible during import (replace NNNNN with the SLA custom field ID). The following works on the server app, if you are looking to do this on Jira Cloud, please try to add the advanced settings and let me know if you have problems importing it.

[jira.customfield_sla1_goal]
data_type="decimal"
name = "SLA 1 goal"
javascript_code = '''

var hours=0.0;

if (issue.fields.customfield_NNNNN){
	cCycles = issue.fields.customfield_NNNNN.completeCycles;
	if (cCycles) {
		hours=cCycles[0].goalTime/1000/3600;
	} else {
		oCycle=issue.fields.customfield_NNNNN.ongoingCycle;
		if (oCycle) {
			hours = (oCycle.elapsedTime+oCycle.remainingTime)/1000/3600;
		}
	}
}
if (hours>0) {

issue.fields.customfield_sla1_goal=hours;}
'''

After importing, you can use the target property in a report. See a similar report with Time to resolution target breached:

Additionally to the default measures, there are two formulas used:

1 Days over target subtracting the target from elapsed hours

Cache(
CASE WHEN 
  [Measures].[Issue Time to resolution target] < 
  [Measures].[Time to resolution Elapsed hours]
THEN 
  ([Measures].[Time to resolution Elapsed hours] -
  [Measures].[Issue Time to resolution target]) / 8 -- divide hours by 8 to get days
END)

2 Penalty, which for the IP-48 issue calculates as 130 per first three days and 100 for the remaining 0.17 days

Sum(
  Filter(Descendants(
    [Issue].CurrentMember, [Issue].[Issue]
  ), [Measures].[Time to resolution - Breached] > 0 AND
     [Measures].[Time to resolution Elapsed hours] > 0), -- get all breached issues with Elapsed hours
CASE 
WHEN [Measures].[Issue Time to resolution target] = 8 -- use target as SLA group. If 8h, then
THEN
  CASE WHEN [Measures].[Days over target] < 1
    THEN 80 * [Measures].[Days over target]
  ELSE 80 + ([Measures].[Days over target]-1) * 50
  END
WHEN [Measures].[Issue Time to resolution target] = 40 -- if target is 40h, then 130 penalty for first three days and 100 for the rest of days
THEN
  CASE WHEN [Measures].[Days over target] < 3
    THEN 130 * [Measures].[Days over target]
  ELSE 130*3 + ([Measures].[Days over target]-3) * 100
  END
END
)

Lauma / support@eazybi.com

1 Like