Skip to content

Commit

Permalink
Merge pull request #8405 from cfpb/tccp/other-fee-tidying
Browse files Browse the repository at this point in the history
TCCP: Tidy up detail page "other fees" Jinja
  • Loading branch information
chosak committed May 13, 2024
2 parents 88c425e + e6afb2a commit 32c6cf1
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions cfgov/tccp/jinja2/tccp/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,26 @@ <h2>
<p>{{ card.fee_explanation }}</p>
{% endif %}
<div class="o-additional-details">
{% set other_fees = [card.other_fee_name, card.other_fee_name_2,
card.other_fee_name_3, card.other_fee_name_4, card.other_fee_name_5
] %}
{% set other_fees_count = other_fees | length - other_fees.count('') %}
{% if other_fees_count == 1 %}
{% set other_fees_label = 'Late, over-limit, and 1 other fee' %}
{% elif other_fees_count > 1 %}
{% set other_fees_label = 'Late, over-limit, and ' ~ other_fees_count ~ ' other fees' %}
{% set other_fees = [] %}
{% for i in range(5) %}
{% set loop_suffix = ('_' ~ (i + 1)) if i else '' %}
{% set other_fee_name = card['other_fee_name' ~ loop_suffix] %}
{% if other_fee_name %}
{% do other_fees.append({
"name": other_fee_name,
"amount": card['other_fee_amount' ~ loop_suffix],
"explanation": card['other_fee_explanation' ~ loop_suffix]
}) %}
{% endif %}
{% endfor %}

{% if other_fees %}
{% set other_fees_label = (
'Late, over-limit, and '
~ other_fees | length
~ ' other fee'
~ ('s' if other_fees | length > 1)
) %}
{% else %}
{% set other_fees_label = 'Late and over-limit fees' %}
{% endif %}
Expand Down Expand Up @@ -573,25 +585,17 @@ <h2>
<dt>Over-limit fee details</dt>
<dd>{{ card.overlimit_fee_detail }}</dd>
{% endif %}
{% if card.other_fees %}
{% for fee_name in other_fees %}
{% if fee_name %}
<dt>{{ fee_name }}</dt>
<dd>
{% if loop.first %}
{{ currency(card.other_fee_amount) ~ ' (' ~
card.other_fee_explanation ~ ')'
}}
{% else %}
{{ currency(card['other_fee_amount_' ~ loop.index]) ~ ' (' ~
card['other_fee_explanation_' ~ loop.index] ~
')'
}}
{% endif %}
</dd>
{% endif %}
{% endfor %}
{% endif %}
{% for other_fee in other_fees %}
<dt>{{ other_fee.name }}</dt>
<dd>
{{-
currency(other_fee.amount)
~ ' ('
~ other_fee.explanation
~ ')'
-}}
</dd>
{% endfor %}
</dl>
{% endcall %}
</div>
Expand Down

0 comments on commit 32c6cf1

Please sign in to comment.