(8.4.1) Remaining budget
Title | Remaining budget |
---|---|
Description | It is the remain result of the Budget minus the Incurred Cost |
Objective | Get to know what is the current remaining budget |
Audience |
|
What does a Jira Project Represent? | A Jira Project of any type, where cost tracking is a valuable asset |
Focus | Project tracking and monitorization |
Configuration
1. Create a Projectrak Number field called "Budget".
2. Create a Projectrak Script field called "Incurred Cost"
3. Create a Projectrak Script field called "Remaining budget.
4. Insert the following Groovy script and modify according to your instance into "Remaining budget" field
Pre-requisites:
- Projectrak Numeric field called "Budget"
- Projectrak Script field called "Incurred Cost"
Description: It returns the calculation of the Budget minus the Incurred Cost in the current project
Use in: It should be used as a Projectrak Script field
Variables in context:
- project [com.atlassian.jira.project.Project]: The current project
Groovy Script
package deiser.profields.scripts import com.atlassian.jira.component.ComponentAccessor import com.deiser.jira.profields.api.field.FieldService import com.deiser.jira.profields.api.field.number.NumberField import com.deiser.jira.profields.api.field.script.ScriptField import com.deiser.jira.profields.api.value.ValueService import java.text.NumberFormat // Configuration def BUDGET_FIELD_ID = 20 def INCURRED_COST_FIELD_ID = 22 // Components def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class) def valueService = ComponentAccessor.getOSGiComponentInstanceOfType(ValueService.class) def jiraAuthenticationContext = ComponentAccessor.jiraAuthenticationContext // Get the fields def budgetField = fieldService.get(BUDGET_FIELD_ID) def incurredCostField = fieldService.get(INCURRED_COST_FIELD_ID) // Get the field values in the current project def budget = valueService.getValue(project, (NumberField) budgetField) ?: 0 def incurredCost = valueService.getValue(project, (ScriptField) incurredCostField)?:"0" def incurredCostBigDecimal = new BigDecimal(incurredCost) // Returns the difference between the budget and the incurred cost def numberFormat = NumberFormat.getInstance(jiraAuthenticationContext.locale) numberFormat.maximumFractionDigits = 0 numberFormat.minimumFractionDigits = 0 numberFormat.groupingUsed = false return numberFormat.format((budget - incurredCostBigDecimal)<0?0:(budget - incurredCostBigDecimal))
5. Configure the project's layout including all of the fields created.
6. Associate the Layout to the project you need this information to be applied to.
7. The result show 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).