mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:03:10 +00:00
Permet de gérer les moyens de paiement
This commit is contained in:
parent
0670a0c8a2
commit
db63896697
3 changed files with 28 additions and 1 deletions
|
@ -2,4 +2,8 @@
|
|||
|
||||
{% block sidebar %}
|
||||
<p><a href="{% url "cotisations:index" %}">Liste des factures</a></p>
|
||||
<p><a href="{% url "cotisations:add-article" %}">Ajouter un article</a></p>
|
||||
<p><a href="{% url "cotisations:del-article" %}">Retirer un article</a></p>
|
||||
<p><a href="{% url "cotisations:add-paiement" %}">Ajouter un moyen de paiement</a></p>
|
||||
<p><a href="{% url "cotisations:del-paiement" %}">Retirer un moyen de paiement</a></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,6 +7,8 @@ urlpatterns = [
|
|||
url(r'^edit_facture/(?P<factureid>[0-9]+)$', views.edit_facture, name='edit-facture'),
|
||||
url(r'^add_article/$', views.add_article, name='add-article'),
|
||||
url(r'^del_article/$', views.del_article, name='del-article'),
|
||||
url(r'^add_paiement/$', views.add_paiement, name='add-paiement'),
|
||||
url(r'^del_paiement/$', views.del_paiement, name='del-paiement'),
|
||||
url(r'^$', views.index, name='index'),
|
||||
]
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.contrib import messages
|
|||
from django.db.models import Max, ProtectedError
|
||||
|
||||
from .models import Facture, Article, Cotisation, Article
|
||||
from .forms import NewFactureForm, EditFactureForm, ArticleForm, DelArticleForm, DelPaiementForm
|
||||
from .forms import NewFactureForm, EditFactureForm, ArticleForm, DelArticleForm, PaiementForm, DelPaiementForm
|
||||
from users.models import User
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
@ -99,6 +99,27 @@ def del_article(request):
|
|||
return redirect("/cotisations/")
|
||||
return form({'factureform': article}, 'cotisations/facture.html', request)
|
||||
|
||||
def add_paiement(request):
|
||||
paiement = PaiementForm(request.POST or None)
|
||||
if paiement.is_valid():
|
||||
paiement.save()
|
||||
messages.success(request, "Le moyen de paiement a été ajouté")
|
||||
return redirect("/cotisations/")
|
||||
return form({'factureform': paiement}, 'cotisations/facture.html', request)
|
||||
|
||||
def del_paiement(request):
|
||||
paiement = DelPaiementForm(request.POST or None)
|
||||
if paiement.is_valid():
|
||||
paiement_dels = paiement.cleaned_data['paiements']
|
||||
for paiement_del in paiement_dels:
|
||||
try:
|
||||
paiement_del.delete()
|
||||
messages.success(request, "Le moyen de paiement a été supprimé")
|
||||
except ProtectedError:
|
||||
messages.error(request, "Le moyen de paiement %s est affecté à au moins une facture, vous ne pouvez pas le supprimer" % paiement_del)
|
||||
return redirect("/cotisations/")
|
||||
return form({'factureform': paiement}, 'cotisations/facture.html', request)
|
||||
|
||||
def index(request):
|
||||
facture_list = Facture.objects.order_by('date').reverse()
|
||||
return render(request, 'cotisations/index.html', {'facture_list': facture_list})
|
||||
|
|
Loading…
Reference in a new issue