mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-01 14:41:25 -04:00
Add filter for formatting a number as currency
This is used on the usage page, but is likely to become useful in other places now that letter rates can be greater than £1.
This commit is contained in:
@@ -521,6 +521,13 @@ def nl2br(value):
|
||||
return ''
|
||||
|
||||
|
||||
def format_number_in_pounds_as_currency(number):
|
||||
if number >= 1:
|
||||
return f"£{number:,.2f}"
|
||||
|
||||
return f"{number * 100:.0f}p"
|
||||
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
return User.from_id(user_id)
|
||||
@@ -798,6 +805,7 @@ def add_template_filters(application):
|
||||
format_notification_status_as_time,
|
||||
format_notification_status_as_field_status,
|
||||
format_notification_status_as_url,
|
||||
format_number_in_pounds_as_currency,
|
||||
formatters.formatted_list,
|
||||
nl2br,
|
||||
format_phone_number_human_readable,
|
||||
|
||||
Reference in New Issue
Block a user