Skip to main content
Skip table of contents

Formatting templates

Within sumUp, calculation rules are used in nearly every context to tell the app which fields should be calculated and which output format should be used.

To further customize the output format, velocity templates can be used!

On this page you'll find some predefined templates that can be used right away to adapt a rule's output format.

Velocity template

To use a custom output format in the rule, select Velocity template as shown:

velocity template add new rule.png

The velocity context

If you're unfamiliar with velocity templates, you might want to check out the official documentation.

The Velocity Context is initialized with the following content:

These keys can be used within the templates to customize the format.

key

Class

Description

$value

java.lang.BigDecimal

The computed value.

$number

com.atlassian.jira.util.velocity.NumberTool

A helper class to format numeric values.

$math

SINCE VERSION 3.6.0

org.apache.velocity.tools.generic.MathTool

A helper class for doing math calculations.

$jiraDateTimeUtils

internal

A helper class which has one function:

getTimeFormatedString(long value).

This function formats timespan according to the time configuration in JIRA.

$formatter

java.text.SimpleDateFormat

JavaSimpleDate format with format ("EEE, d MMM yyyy h:mm a")


Templates

Default format

XML
#if($value)
$value
#end

Hours format

Assumes that the value is in seconds.

XML
#set($H = '#')
#if($value)
#set($v = $value.doubleValue()/3600.0)
$number.format("$H.$H$H",$v)h
#end

Jira timespan format

Assumes that the value is in seconds.

XML
#if($value)
$jiraDateTimeUtils.getTimeFormatedString($value.longValue())
#end

Days, hours and minutes format

Assumes that the value is in minutes.

XML
#set($H = '#')
#set($intMin = 999999)
#set($intHour = 999999)
#set($Min = $value.doubleValue())
#set($Hour = 0)
#set($Day = 0)

#if($value)#foreach($numMin in [ 1..$intMin ] )
    #if($Min < 60 )
        #break
    #else
        #set($Min = $Min - 60)
        #set($Hour = $Hour + 1)
    #end

#end#foreach($numHour in [ 1..$intHour ] )
    #if($Hour < 24 )
        #break
    #else
        #set($Hour = $Hour - 24)
        #set($Day = $Day + 1)
    #end
#end

$number.format("$H.",$Day)$number.format("$H.",$Hour)$number.format("$H",$Min)
#end

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.