Show tempo field "Billed" hours in jira issues

Hello Erveryone,

As default you can see the under the tab "Time Tracking" the values for "Estimated:", "Remaining" and "Logged" Hours.

But when you are create a worklog you have the option to choose between "Worked" and "Billed" Hours.

I now want to create an extra field with the "billed" hours under the "Time Tracking" Tab but I wasn't able to with a custom field. (see attchated screenshots)

Is it possible? (I couldn't image why not) and if yes how to?

4 answers

1 accepted

1 vote
Accepted answer

There is no way to show billed hours in the JIRA issue. If you are using the billed hours in Tempo, you can add them to the Timesheet Report view. This view can be accessed through the Issue by clicking the "Report" button in the Tempo section.

Ah i was afraid you would say that but thank you again ;-)

Hi Frank,

this is not possible as the "Time Tracking" section in the Issue view is a JIRA feature. It displays information that is available to JIRA. Hours logged in Tempo use the same database table as hours logged in JIRA, so all logged hours are displayed. As Billing is a Tempo feature is is not displayed.

Kind regards,

Susanne

hank you for your quick answer :-) Is it then possible to create a standard custom field for billed hours with the data from the tempo database? Or any other way to display the billed hours in a jira issue? (without selecting the timesheet itself)

thank you for your quick answer :-) Is it then possible to create a standard custom field for billed hours with the data from the tempo database? Or any other way to display the billed hours in a jira issue? (without selecting the timesheet itself)

Hi Frank,

if you are using the script runner add-on, maybe following code of a scripted field would be a solution for you

import java.util.List;
import java.util.Map;
import org.ofbiz.core.entity.GenericValue;
import com.atlassian.core.util.collection.EasyList;
import com.atlassian.core.util.map.EasyMap;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ofbiz.OfBizDelegator;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.worklog.Worklog;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
long returnValue = 0;
     for (Worklog worklog : ComponentAccessor.getWorklogManager().getByIssue(issue))
     {
        
         long abrechenbarerAnteil = getWorklogBilledSeconds(worklog.getId());
         if (abrechenbarerAnteil == -1L) abrechenbarerAnteil = 	worklog.getTimeSpent();
         returnValue += abrechenbarerAnteil
     }
return formatNumber(returnValue / 3600) 
private String formatNumber(Double number)
    {
        number = Math.round(number * 100) / 100;
        DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
        DecimalFormat df = new DecimalFormat();
        df.setDecimalFormatSymbols(symbols);
        return df.format(number);
    }
public long getWorklogBilledSeconds(long worklogId)
 {
   GenericValue genericValue =  get(generateWorklogParameters("Tempo.WorklogBilledHours", worklogId));
   if (genericValue == null) return -1L;
   String stringValue = genericValue.getString("value");
   if (stringValue == null || stringValue.length() < 1) return -1L;
   return Long.parseLong(stringValue);
 }
private Map generateWorklogParameters(String key, long worklogId)
 {
   return EasyMap.build("entityName", "Tempo.Worklog", "entityId", Long.valueOf(worklogId), "propertyKey", key, "type", Integer.valueOf(5));
 }
 private GenericValue get(Map fields)
 {
   OfBizDelegator delegator = ComponentAccessor.getOfBizDelegator();
   List<GenericValue> peList = delegator.findByAnd("OSPropertyEntry", fields, EasyList.build("id"));
   GenericValue pe = null;
   if ((peList != null) && (peList.size() > 0))
   {
     pe = (GenericValue)peList.get(peList.size() - 1);
   }
   if (pe != null)
   {
     String tableName = getTableName(fields);
     return delegator.findByPrimaryKey(tableName, EasyMap.build("id", pe.get("id")));
   }
   return null;
 }
 
 private String getTableName(Map fields)
 {
   String tableName = "OSPropertyString";
   Integer fieldType = (Integer)fields.get("type");
   if ((fieldType != null) && (fieldType.intValue() == 6)) {
     tableName = "OSPropertyText";
   } else if ((fieldType != null) && (fieldType.intValue() == 2)) {
     tableName = "OSPropertyNumber";
   }
   return tableName;
 }

 

Hope this helps

Cheers Julian

 

Tip:

With our SumUp add-on for JIRA, you can calculate the issue's values in the issue navigator with an easy click wink

 

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,091 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you