Update dollars filter and formatDollars() to display cent values
This commit is contained in:
parent
6d61839c65
commit
0382966929
@ -12,14 +12,6 @@ def iconSvg(name):
|
||||
|
||||
|
||||
def dollars(value):
|
||||
try:
|
||||
numberValue = float(value)
|
||||
except ValueError:
|
||||
numberValue = 0
|
||||
return "${:,.0f}".format(numberValue)
|
||||
|
||||
|
||||
def dollarsWithCents(value):
|
||||
try:
|
||||
numberValue = float(value)
|
||||
except ValueError:
|
||||
@ -107,7 +99,6 @@ def normalizeOrder(title):
|
||||
def register_filters(app):
|
||||
app.jinja_env.filters["iconSvg"] = iconSvg
|
||||
app.jinja_env.filters["dollars"] = dollars
|
||||
app.jinja_env.filters["dollarsWithCents"] = dollarsWithCents
|
||||
app.jinja_env.filters["usPhone"] = usPhone
|
||||
app.jinja_env.filters["readableInteger"] = readableInteger
|
||||
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
|
||||
|
@ -1,8 +1,9 @@
|
||||
export const formatDollars = (value, cents = true) => {
|
||||
if (typeof value === 'number') {
|
||||
return cents
|
||||
? `$${value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}`
|
||||
: `$${value.toFixed(0).replace(/\d(?=(\d{3})+(?!\d))/g, '$&,')}`
|
||||
return value.toLocaleString('us-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
})
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
@ -132,7 +132,7 @@
|
||||
<td><h4>{{ "task_orders.new.review.to_value"| translate }}</h4></td>
|
||||
<td class="table-cell--align-right">
|
||||
{% if task_order.budget %}
|
||||
{{ task_order.budget | dollarsWithCents }}
|
||||
{{ task_order.budget | dollars }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
@ -140,7 +140,7 @@
|
||||
<td><h4 class='task-order-form__heading funding-summary__td'>{{ "task_orders.new.review.clin_1"| translate }}</h4></td>
|
||||
<td class="table-cell--align-right">
|
||||
{% if task_order.clin_01 %}
|
||||
{{ task_order.clin_01 | dollarsWithCents }}
|
||||
{{ task_order.clin_01 | dollars }}
|
||||
{% else %}
|
||||
{{ RequiredLabel() }}
|
||||
{% endif %}
|
||||
@ -155,7 +155,7 @@
|
||||
</h4></td>
|
||||
<td class="table-cell--align-right">
|
||||
{% if task_order.clin_02 and config.CLASSIFIED %}
|
||||
{{ task_order.clin_02 | dollarsWithCents or RequiredLabel() }}
|
||||
{{ task_order.clin_02 | dollars or RequiredLabel() }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
@ -163,7 +163,7 @@
|
||||
<td><h4 class='task-order-form__heading funding-summary__td'>{{ "task_orders.new.review.clin_3"| translate }}</h4></td>
|
||||
<td class="table-cell--align-right">
|
||||
{% if task_order.clin_03 %}
|
||||
{{ task_order.clin_03 | dollarsWithCents or RequiredLabel() }}
|
||||
{{ task_order.clin_03 | dollars or RequiredLabel() }}
|
||||
{% else %}
|
||||
{{ RequiredLabel() }}
|
||||
{% endif %}
|
||||
@ -178,7 +178,7 @@
|
||||
</h4></td>
|
||||
<td class="table-cell--align-right">
|
||||
{% if task_order.clin_04 and config.CLASSIFIED %}
|
||||
{{ task_order.clin_04 | dollarsWithCents or RequiredLabel() }}
|
||||
{{ task_order.clin_04 | dollars or RequiredLabel() }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user