From f87b85d444b9e2b258d3db7e24c8f6ffc18aba01 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 10 Jul 2018 18:06:58 +0200 Subject: [PATCH] Fix les erreurs d'affichage de solde --- .../templates/cotisations/facture.html | 19 ++- .../templates/cotisations/new_facture.html | 148 ------------------ cotisations/views.py | 13 +- 3 files changed, 22 insertions(+), 158 deletions(-) delete mode 100644 cotisations/templates/cotisations/new_facture.html diff --git a/cotisations/templates/cotisations/facture.html b/cotisations/templates/cotisations/facture.html index 081f3f51..fbbb0f7d 100644 --- a/cotisations/templates/cotisations/facture.html +++ b/cotisations/templates/cotisations/facture.html @@ -36,12 +36,22 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endif %} {% if title %}

{{title}}

+{% else %} +

{% trans "New invoice" %}

{% endif %} -{% if balance %} -

{% trans "Current balance :" %}{{balance}}€

+{% if balance is not None %} +

+ {% trans "Current balance :" %} {{ balance }} € +

{% endif %} +
{% csrf_token %} + {% bootstrap_form factureform %} + {% if payment_method %} + {% bootstrap_form payment_method %} +
+ {% endif %} {% if articlesformset %}

{% trans "Invoice's articles" %}

@@ -64,11 +74,6 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endblocktrans %}

{% endif %} - {% bootstrap_form factureform %} - {% if payment_method %} - {% bootstrap_form payment_method %} -
- {% endif %} {% bootstrap_button action_name button_type='submit' icon='star' %} diff --git a/cotisations/templates/cotisations/new_facture.html b/cotisations/templates/cotisations/new_facture.html deleted file mode 100644 index ddb1ece8..00000000 --- a/cotisations/templates/cotisations/new_facture.html +++ /dev/null @@ -1,148 +0,0 @@ -{% extends "cotisations/sidebar.html" %} -{% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -{% endcomment %} - -{% load bootstrap3 %} -{% load staticfiles%} -{% load i18n %} - -{% block title %}{% trans "Invoices creation and edition" %}{% endblock %} - -{% block content %} -{% bootstrap_form_errors factureform %} - -
- {% csrf_token %} -

{% trans "New invoice" %}

- {% if user.solde %} -

- {% blocktrans %} - User's balance : {{ user.solde }} € - {% endblocktrans %} -

- {% endif %} - {% bootstrap_form factureform %} - {{ venteform.management_form }} -

{% trans "Invoice's articles" %}

-
- {% for form in venteform.forms %} -
- {% trans "Article" %} :   - {% bootstrap_form form label_class='sr-only' %} -   - -
- {% endfor %} -
- -

- {% blocktrans %} - Total price : 0,00 € - {% endblocktrans %} -

- {% trans "Create" as tr_create %} - {% bootstrap_button tr_create button_type='submit' icon='star' %} -
- - - -{% endblock %} diff --git a/cotisations/views.py b/cotisations/views.py index 9be079f5..c1a8d68f 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -143,13 +143,20 @@ def new_facture(request, user, userid): request, _("You need to choose at least one article.") ) + p = Paiement.objects.filter(is_balance=True) + if len(p) and p[0].can_use_payment(request.user): + balance = user.solde + else: + balance = None return form( { 'factureform': invoice_form, - 'venteform': article_formset, - 'articlelist': article_list + 'articlesformset': article_formset, + 'articlelist': article_list, + 'balance': balance, + 'action_name': _('Create'), }, - 'cotisations/new_facture.html', request + 'cotisations/facture.html', request )