mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-24 07:53:47 +00:00
Fix la validation de facture.
This commit is contained in:
parent
a1ec5eb831
commit
3861ce9870
2 changed files with 18 additions and 15 deletions
|
@ -26,23 +26,26 @@ def accept_payment(request, factureid):
|
||||||
The view called when an online payment has been accepted.
|
The view called when an online payment has been accepted.
|
||||||
"""
|
"""
|
||||||
invoice = get_object_or_404(Facture, id=factureid)
|
invoice = get_object_or_404(Facture, id=factureid)
|
||||||
messages.success(
|
if invoice.valid:
|
||||||
request,
|
|
||||||
_("The payment of %(amount)s € has been accepted.") % {
|
|
||||||
'amount': invoice.prix_total()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# In case a cotisation was bought, inform the user, the
|
|
||||||
# cotisation time has been extended too
|
|
||||||
if any(purchase.type_cotisation for purchase in invoice.vente_set.all()):
|
|
||||||
messages.success(
|
messages.success(
|
||||||
request,
|
request,
|
||||||
_("The cotisation of %(member_name)s has been \
|
_("The payment of %(amount)s € has been accepted.") % {
|
||||||
extended to %(end_date)s.") % {
|
'amount': invoice.prix_total()
|
||||||
'member_name': request.user.pseudo,
|
|
||||||
'end_date': request.user.end_adhesion()
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
# In case a cotisation was bought, inform the user, the
|
||||||
|
# cotisation time has been extended too
|
||||||
|
if any(purchase.type_cotisation for purchase in invoice.vente_set.all()):
|
||||||
|
messages.success(
|
||||||
|
request,
|
||||||
|
_("The cotisation of %(member_name)s has been \
|
||||||
|
extended to %(end_date)s.") % {
|
||||||
|
'member_name': request.user.pseudo,
|
||||||
|
'end_date': request.user.end_adhesion()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
invoice.delete()
|
||||||
return redirect(reverse(
|
return redirect(reverse(
|
||||||
'users:profil',
|
'users:profil',
|
||||||
kwargs={'userid': request.user.id}
|
kwargs={'userid': request.user.id}
|
||||||
|
|
|
@ -162,7 +162,7 @@ def new_facture(request, user, userid):
|
||||||
is_online_payment = new_invoice_instance.paiement == (
|
is_online_payment = new_invoice_instance.paiement == (
|
||||||
Paiement.objects.get_or_create(
|
Paiement.objects.get_or_create(
|
||||||
moyen='Rechargement en ligne')[0])
|
moyen='Rechargement en ligne')[0])
|
||||||
new_invoice_instance.valid = is_online_payment
|
new_invoice_instance.valid = not is_online_payment
|
||||||
# Saving the invoice
|
# Saving the invoice
|
||||||
new_invoice_instance.save()
|
new_invoice_instance.save()
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ def new_facture(request, user, userid):
|
||||||
if is_online_payment:
|
if is_online_payment:
|
||||||
content = online_payment.PAYMENT_SYSTEM[
|
content = online_payment.PAYMENT_SYSTEM[
|
||||||
AssoOption.get_cached_value('payment')
|
AssoOption.get_cached_value('payment')
|
||||||
](invoice, request)
|
](new_invoice_instance, request)
|
||||||
return render(request, 'cotisations/payment.html', content)
|
return render(request, 'cotisations/payment.html', content)
|
||||||
|
|
||||||
# In case a cotisation was bought, inform the user, the
|
# In case a cotisation was bought, inform the user, the
|
||||||
|
|
Loading…
Reference in a new issue