1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-24 19:20:29 +02:00

Don't delete Sogé credits if the user don't have enough money on its note, stay positive :)

This commit is contained in:
Yohann D'ANELLO
2020-04-22 03:57:19 +02:00
parent b23814aef0
commit 640f0f9a31
4 changed files with 212 additions and 146 deletions

View File

@ -2,6 +2,7 @@
{% load static %}
{% load i18n %}
{% load pretty_money %}
{% load perms %}
{% block content %}
<div class="card bg-light shadow">
@ -13,6 +14,11 @@
<dt class="col-xl-6 text-right">{% trans 'user'|capfirst %}</dt>
<dd class="col-xl-6"><a href="{% url 'member:user_detail' pk=object.user.pk %}">{{ object.user }}</a></dd>
{% if "note.view_note_balance"|has_perm:object.user.note %}
<dt class="col-xl-6 text-right">{% trans 'balance'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.user.note.balance|pretty_money }}</dd>
{% endif %}
<dt class="col-xl-6 text-right">{% trans 'transactions'|capfirst %}</dt>
<dd class="col-xl-6">
{% for transaction in object.transactions.all %}
@ -38,11 +44,20 @@
{% trans "This credit is already validated." %}
</div>
{% else %}
{% if object.user.note.balance < object.amount %}
<div class="alert alert-warning">
{% trans "Warning: if you don't validate this credit, the note of the user doesn't have enough money to pay its memberships." %}
{% trans "Please ask the user to credit its note before deleting this credit." %}
</div>
{% endif %}
<form method="post">
{% csrf_token %}
<div class="btn-group btn-block">
<button name="validate" class="btn btn-success">{% trans "Validate" %}</button>
<button name="delete" class="btn btn-danger">{% trans "Delete" %}</button>
{% if object.user.note.balance >= object.amount %}
<button name="delete" class="btn btn-danger">{% trans "Delete" %}</button>
{% endif %}
</div>
</form>
{% endif %}