Add jinja filters for just dollars and just cents
This commit is contained in:
parent
3c7fe2cf24
commit
aecab933b0
@ -18,6 +18,13 @@ def dollars(value):
|
||||
numberValue = 0
|
||||
return "${:,.2f}".format(numberValue)
|
||||
|
||||
def justDollars(value):
|
||||
raw = dollars(value)
|
||||
return raw[:-3]
|
||||
|
||||
def justCents(value):
|
||||
raw = dollars(value)
|
||||
return raw[-3:]
|
||||
|
||||
def usPhone(number):
|
||||
phone = re.sub(r"\D", "", number)
|
||||
@ -99,6 +106,8 @@ def normalizeOrder(title):
|
||||
def register_filters(app):
|
||||
app.jinja_env.filters["iconSvg"] = iconSvg
|
||||
app.jinja_env.filters["dollars"] = dollars
|
||||
app.jinja_env.filters["justDollars"] = justDollars
|
||||
app.jinja_env.filters["justCents"] = justCents
|
||||
app.jinja_env.filters["usPhone"] = usPhone
|
||||
app.jinja_env.filters["readableInteger"] = readableInteger
|
||||
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
|
||||
|
@ -20,8 +20,28 @@
|
||||
{{ Icon('info') }}
|
||||
</button>
|
||||
<span class='portfolio-header__budget--dollars'>
|
||||
{{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | dollars }}
|
||||
{{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | justDollars }}
|
||||
</span>
|
||||
<span>
|
||||
{{ portfolio.task_orders | selectattr('is_active') | sum(attribute='budget') | justCents }}
|
||||
</span>
|
||||
</div>
|
||||
<div class='portfolio-funding__header--funded-through {{ "funded" if funding_end_date is not none and funded else "unfunded"}}'>
|
||||
{% if funding_end_date and funded %}
|
||||
{{ Icon('ok') }}
|
||||
Funded through
|
||||
<local-datetime
|
||||
timestamp='{{ funding_end_date }}'
|
||||
format="M/D/YYYY">
|
||||
</local-datetime>
|
||||
{% elif funding_end_date and not funded %}
|
||||
{{ Icon('alert') }}
|
||||
Funded period ends
|
||||
<local-datetime
|
||||
timestamp='{{ funding_end_date }}'
|
||||
format="M/D/YYYY">
|
||||
</local-datetime>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class='row links'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user