{% load custom_tags_and_filters %}
{% if "adjustment_requests"|customization:"adjustment_requests_enabled" %}
    {% with content_type=charge|content_type %}
        {% url 'create_adjustment_request' content_type.id charge.id as create_adjustment_request %}
        {% if not charge.validated %}
            {% if not existing_adjustments or content_type.id not in existing_adjustments or charge.id not in existing_adjustments|get_item:content_type.id %}
                <span class="usage-charge-adjustment-button">
                    {% if "adjustment_requests"|customization:"charges_validation_enabled" == "enabled" %}
                        {% url 'validate_charge' content_type.id charge.id as validate_charge_url %}
                        {% button size="small" type="save" onclick="validate_charge('"|concat:validate_charge_url|concat:"', this)" value="Validate" icon="glyphicon-check" %}
                    {% endif %}
                    {% button size="small" type="warn" url=create_adjustment_request value="Request an adjustment" icon="glyphicon-flag" %}
                </span>
            {% else %}
                <span class="usage-charge-adjustment-button" title="An adjustment request already exists for this charge">
                    {% button size="small" type="warn" url=create_adjustment_request value="Request an adjustment" icon="glyphicon-flag" disabled="true" %}
                </span>
            {% endif %}
        {% endif %}
    {% endwith %}
{% endif %}
