Show tempo field "Billed" hours in jira issues

yim Consultant February 2, 2014

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
Answer accepted
Susanne Götz [Tempo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2014

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.

yim Consultant February 2, 2014

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

1 vote
Julian Riedinger _Decadis AG_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2015

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

 

 

Bram V June 5, 2020

As the code above did not work for me, I figured out a better way to get Tempo Billable time from the worklogs using Scriptrunner. Added the code here: https://community.atlassian.com/t5/Jira-Software-questions/Getting-Tempo-billable-hours-for-issue-in-a-ScriptRunner/qaq-p/1312330#U1399106

Cristian _Southend_ July 26, 2021

@Julian Riedinger _Decadis AG_ 

Thanks 

Your code has solved many doubts and I was able to apply it to my problem
but there is a problem, never enter this function

long abrechenbarerAnteil = getWorklogBilledSeconds(worklog.getId());

And I can't know for what reason

Could you help me?

Thanks

1 vote
Susanne Götz [Tempo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2014

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

yim Consultant February 2, 2014

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)

0 votes
yim Consultant February 2, 2014

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)

Suggest an answer

Log in or Sign up to answer