Formatting and formulas

Predefined filters and formulas to format the date in your template

Filters

All default jinja2 filters can be used in the template.

The following additional filters are available the template:

Not None

not_none - Avoids to print None in the template.
Usage: {{ any|not_none }}

Format Price

format_price - Formats the price to x.xx \[CUR\] e.g. 13.37 EUR.
Usage: {{ shipment_item.price|format_price }}

A factor can be specified to calculate the price of a shipment item which has amount > 1
Usage: {{ shipment_item.price|format_price(shipment_item.amount) }}

Total Price

total_price - Calculates total price of the shipment and formats it with format_price.
Usage: {{ shipment|total_price }}

Format Weight

format_weight - Formats the given weight to x.xxx kg e.g. 1.337 kg.
Usage: {{ shipment_item.weight|format_weight }}

A factor can be specified to calculate the weight of a shipment item which has amount > 1
Usage: {{ shipment_item.weight|format_weight(shipment_item.amount) }}

Total Weight

total_weight - Calculates total weight of the shipment and formats it with format_weight.
Usage: {{ shipment|total_weight }}

Format Street

format_street - Formats the street name, house number and addition of the address e.g. Fakestreet 1337, Fakeaddition.
Usage: {{ sender_address|format_street }}

Format Country

format_country - Formats the country to CC - CountryName e.g. DE - GERMANY.
Usage: {{ sender_address.country|format_country }}

Format Customer Name

format_customer_name - Formats the customer name.
Usage: {{ customer|format_customer_name }}

Order of formatting (if not provided, next is used).

  1. customer.senderName
  2. customer.companyName
  3. customer.firstName and customer.lastName

Globals

All default jinja2 globals can be used in the template.

The following additional methods are available in the template:

  • current_date - Formats local datetime.now() with the given format.
    Usage: {{ current_date("%d.%m.%Y") }}

Tests

All default jinja2 tests can be used in the template.

The following additional tests are available in the template:

  • gift - Checks if the shipment is type gift.
    Usage: {% if shipment is gift %}

  • document - Checks if the shipment is type document.
    Usage: {% if shipment is document %}

  • sample - Checks if the shipment is type sample.
    Usage: {% if shipment is sample %}

  • remand - Checks if the shipment is type remand.
    Usage: {% if shipment is remand %}

  • other - Checks if the shipment is type other.
    Usage: {% if shipment is other %}