(8.16.X) Estimate at completion (EaC)
Description
Estimate at Completion (EaC) = Time Spent + Remaining Estimate.
Configuration
1. Create a Projectrak Script field called "Estimate at completion (EaC)"
2. Insert the following Groovy script and modify accordingly to your instance:
Groovy Script
estimate-at-completion.groovy
package deiser.profields.scripts
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.project.Project
import com.atlassian.jira.web.bean.PagerFilter
def PROJECT_ID = project.id
def searchService = ComponentAccessor.getOSGiComponentInstanceOfType(SearchService)
def jiraAuthenticationContext = ComponentAccessor.jiraAuthenticationContext
def loggedInUser = jiraAuthenticationContext.getLoggedInUser()
def query = JqlQueryBuilder.newBuilder().where().project(PROJECT_ID).buildQuery()
def sumTimeSpent = 0L
def sumRemainingEstimate = 0L
def sumOriginalEstimate = 0L
searchService.search(loggedInUser, query, PagerFilter.unlimitedFilter).results
.each { issue ->
sumTimeSpent += issue.getTimeSpent() == null ? 0 : issue.getTimeSpent()
sumOriginalEstimate += issue.getOriginalEstimate() == null ? 0 : issue.getOriginalEstimate()
sumRemainingEstimate += issue.getEstimate() == null ? 0 : issue.getEstimate()
}
def estimateAtCompletion = sumTimeSpent + sumRemainingEstimate
return estimateAtCompletion
3. Configure the project's layout including "Estimate at completion (EaC)"
4. Associate the layout to the projectt you need this information to be applied to.
5. The result should be something like this: (please, keep in mind that this is only an example and your results should vary from what it is shown in the screenshot).