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
|
numberValue = 0
|
||||||
return "${:,.2f}".format(numberValue)
|
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):
|
def usPhone(number):
|
||||||
phone = re.sub(r"\D", "", number)
|
phone = re.sub(r"\D", "", number)
|
||||||
@ -99,6 +106,8 @@ def normalizeOrder(title):
|
|||||||
def register_filters(app):
|
def register_filters(app):
|
||||||
app.jinja_env.filters["iconSvg"] = iconSvg
|
app.jinja_env.filters["iconSvg"] = iconSvg
|
||||||
app.jinja_env.filters["dollars"] = dollars
|
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["usPhone"] = usPhone
|
||||||
app.jinja_env.filters["readableInteger"] = readableInteger
|
app.jinja_env.filters["readableInteger"] = readableInteger
|
||||||
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
|
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
|
||||||
|
@ -20,9 +20,29 @@
|
|||||||
{{ Icon('info') }}
|
{{ Icon('info') }}
|
||||||
</button>
|
</button>
|
||||||
<span class='portfolio-header__budget--dollars'>
|
<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>
|
</span>
|
||||||
</div>
|
</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>
|
||||||
<div class='row links'>
|
<div class='row links'>
|
||||||
{% if user_can(permissions.VIEW_USAGE_DOLLARS) %}
|
{% if user_can(permissions.VIEW_USAGE_DOLLARS) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user