{% extends admin.getTemplate('base_list_field') %}
{% block field %}
    {%- spaceless %}
        {% set balance = object.user.adherent.emlcAccount.balance %}
        {% set ceiling = object.user.adherent.ceiling %}
        {% if 
            not ceiling 
            or household_based_allowance and not simplified_household_based_allowance and (not object.user.adherent.householdAdultCount or not object.user.adherent.cotisationAmount)
            or simplified_household_based_allowance and (not object.user.adherent.householdCount or not object.user.adherent.cotisationAmount)
        %}
            {% set class = 'label label-warning' %}
            {% set text = 'profil incomplet' %}
        {% elseif balance > ceiling %}
            {% set class = 'label label-danger' %}
            {% set text = balance ~ ' > ' ~ ceiling %}
        {% else %}
            {% set class = 'label label-success' %}
            {% set text = balance ~ " &leq; " ~ ceiling %}
        {% endif %}
        <span class="{{ class }}">{{ text|raw }}</span>
    {% endspaceless -%}
{% endblock %}
