From fbb41c3cd530cb0dd7f9e9dfe87a05f47e6197b5 Mon Sep 17 00:00:00 2001 From: Skia Date: Thu, 29 Dec 2016 01:08:08 +0100 Subject: [PATCH] Improve UX for accounting linked operation --- .../accounting/journal_details.jinja | 11 ++- .../templates/accounting/operation_edit.jinja | 10 +++ accounting/views.py | 6 +- locale/fr/LC_MESSAGES/django.po | 89 ++++++++++++------- 4 files changed, 81 insertions(+), 35 deletions(-) diff --git a/accounting/templates/accounting/journal_details.jinja b/accounting/templates/accounting/journal_details.jinja index 425ae36b..e38dfe7d 100644 --- a/accounting/templates/accounting/journal_details.jinja +++ b/accounting/templates/accounting/journal_details.jinja @@ -62,7 +62,16 @@ {% else %} {% trans %}No{% endtrans %} {% endif %} - {{ o.remark }} + {{ o.remark }} + {% if not o.linked_operation and o.target_type == "ACCOUNT" and not o.target.has_open_journal() %} +

+{% trans %}Warning: this operation has no linked operation because the targeted club account has no opened journal.{% endtrans %} +

+

+{% trans url=o.target.get_absolute_url() %}Open a journal in this club account, then save this operation again to make the linked operation.{% endtrans %} +

+ {% endif %} + {% if o.invoice %} {{ o.invoice.name }} {% else %} diff --git a/accounting/templates/accounting/operation_edit.jinja b/accounting/templates/accounting/operation_edit.jinja index 4605ad93..b40fdb1b 100644 --- a/accounting/templates/accounting/operation_edit.jinja +++ b/accounting/templates/accounting/operation_edit.jinja @@ -38,6 +38,16 @@ form.accounting_type }}

{{ form.label.errors }} {{ form.label }}

{{ form.done.errors }} {{ form.done }}

+ {% if form.instance.linked_operation %} + {% set obj = form.instance.linked_operation %} +

{% trans %}Linked operation:{% endtrans %}
+ + {{obj.journal.club_account.bank_account }} > + {{ obj.journal.club_account }} > + {{ obj.journal }} > + n°{{ obj.number }} +

+ {% endif %}

{% endblock %} diff --git a/accounting/views.py b/accounting/views.py index 6984ec24..a561d614 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -5,7 +5,7 @@ from django.core.urlresolvers import reverse_lazy, reverse from django.utils.translation import ugettext_lazy as _ from django.forms.models import modelform_factory from django.core.exceptions import PermissionDenied -from django.forms import HiddenInput +from django.forms import HiddenInput, TextInput from django.db import transaction from django.db.models import Sum from django.conf import settings @@ -237,7 +237,7 @@ class OperationForm(forms.ModelForm): class Meta: model = Operation fields = ['amount', 'remark', 'journal', 'target_type', 'target_id', 'target_label', 'date', 'mode', - 'cheque_number', 'invoice', 'simpleaccounting_type', 'accounting_type', 'label', 'done'] + 'cheque_number', 'invoice', 'simpleaccounting_type', 'accounting_type', 'label', 'done' ] widgets = { 'journal': HiddenInput, 'target_id': HiddenInput, @@ -281,7 +281,7 @@ class OperationForm(forms.ModelForm): inst = self.instance club_account = inst.target acc_type = AccountingType.objects.exclude(movement_type="NEUTRAL").exclude( - movement_type=inst.accounting_type.movement_type).first() # Select a random opposite accounting type + movement_type=inst.accounting_type.movement_type).order_by('code').first() # Select a random opposite accounting type op = Operation( journal=club_account.get_open_journal(), amount=inst.amount, diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 002c873b..2ee7274b 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-26 00:34+0100\n" +"POT-Creation-Date: 2016-12-29 01:01+0100\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Skia \n" "Language-Team: AE info \n" @@ -327,7 +327,7 @@ msgstr "Compte en banque : " #: launderette/templates/launderette/launderette_admin.jinja:16 #: launderette/views.py:154 sas/templates/sas/album.jinja:26 #: sas/templates/sas/moderation.jinja:18 sas/templates/sas/picture.jinja:66 -#: sas/templates/sas/picture.jinja.py:116 +#: sas/templates/sas/picture.jinja:116 msgid "Delete" msgstr "Supprimer" @@ -351,11 +351,12 @@ msgstr "Nouveau compte club" #: accounting/templates/accounting/bank_account_details.jinja:26 #: accounting/templates/accounting/bank_account_list.jinja:21 #: accounting/templates/accounting/club_account_details.jinja:55 -#: accounting/templates/accounting/journal_details.jinja:73 club/views.py:54 +#: accounting/templates/accounting/journal_details.jinja:82 club/views.py:54 #: com/templates/com/news_admin_list.jinja:39 -#: com/templates/com/news_admin_list.jinja:71 core/templates/core/file.jinja:38 -#: core/templates/core/page.jinja:31 core/templates/core/user_tools.jinja:38 -#: core/views/user.py:152 counter/templates/counter/cash_summary_list.jinja:53 +#: com/templates/com/news_admin_list.jinja:71 +#: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31 +#: core/templates/core/user_tools.jinja:38 core/views/user.py:152 +#: counter/templates/counter/cash_summary_list.jinja:53 #: counter/templates/counter/counter_list.jinja:17 #: counter/templates/counter/counter_list.jinja:32 #: counter/templates/counter/counter_list.jinja:47 @@ -466,8 +467,8 @@ msgstr "Non" #: accounting/templates/accounting/club_account_details.jinja:54 #: com/templates/com/news_admin_list.jinja:38 -#: com/templates/com/news_admin_list.jinja:70 core/templates/core/file.jinja:36 -#: core/templates/core/page.jinja:28 +#: com/templates/com/news_admin_list.jinja:70 +#: core/templates/core/file.jinja:36 core/templates/core/page.jinja:28 msgid "View" msgstr "Voir" @@ -570,7 +571,24 @@ msgstr "Fichier" msgid "PDF" msgstr "PDF" -#: accounting/templates/accounting/journal_details.jinja:76 +#: accounting/templates/accounting/journal_details.jinja:68 +msgid "" +"Warning: this operation has no linked operation because the targeted club " +"account has no opened journal." +msgstr "" +"Attention: cette opération n'a pas d'opération liée parce qu'il n'y a pas de " +"classeur ouvert dans le compte club cible" + +#: accounting/templates/accounting/journal_details.jinja:71 +#, python-format +msgid "" +"Open a journal in this club account, then save this " +"operation again to make the linked operation." +msgstr "" +"Ouvrez un classeur dans ce compte club, puis sauver " +"cette opération à nouveau pour créer l'opération liée." + +#: accounting/templates/accounting/journal_details.jinja:85 msgid "Generate" msgstr "Générer" @@ -632,7 +650,11 @@ msgstr "Il n'y a pas d'étiquette dans ce compte club." msgid "Edit operation" msgstr "Éditer l'opération" -#: accounting/templates/accounting/operation_edit.jinja:41 +#: accounting/templates/accounting/operation_edit.jinja:43 +msgid "Linked operation:" +msgstr "Opération liée : " + +#: accounting/templates/accounting/operation_edit.jinja:51 #: com/templates/com/news_edit.jinja:66 core/templates/core/create.jinja:12 #: core/templates/core/edit.jinja:7 core/templates/core/edit.jinja.py:15 #: core/templates/core/edit.jinja:20 core/templates/core/file_edit.jinja:8 @@ -796,11 +818,12 @@ msgstr "L'utilisateur doit être cotisant pour faire partie d'un club" msgid "User is already member of that club" msgstr "L'utilisateur est déjà membre de ce club" -#: club/models.py:166 +#: club/models.py:161 msgid "past member" msgstr "Anciens membres" -#: club/templates/club/club_list.jinja:4 club/templates/club/club_list.jinja:24 +#: club/templates/club/club_list.jinja:4 +#: club/templates/club/club_list.jinja:24 msgid "Club list" msgstr "Liste des clubs" @@ -862,8 +885,8 @@ msgstr "Du" msgid "To" msgstr "Au" -#: club/templates/club/club_sellings.jinja:5 club/views.py:59 club/views.py:216 -#: counter/templates/counter/counter_main.jinja:19 +#: club/templates/club/club_sellings.jinja:5 club/views.py:59 +#: club/views.py:219 counter/templates/counter/counter_main.jinja:19 #: counter/templates/counter/last_ops.jinja:35 msgid "Sellings" msgstr "Ventes" @@ -885,7 +908,7 @@ msgstr "Quantité : " msgid "units" msgstr "unités" -#: club/templates/club/club_sellings.jinja:20 club/views.py:167 +#: club/templates/club/club_sellings.jinja:20 club/views.py:170 #: core/templates/core/user_account_detail.jinja:18 #: core/templates/core/user_account_detail.jinja:51 #: counter/templates/counter/cash_summary_list.jinja:33 counter/views.py:77 @@ -975,23 +998,24 @@ msgstr "Outils" msgid "Props" msgstr "Propriétés" -#: club/views.py:103 core/views/forms.py:204 counter/views.py:38 +#: club/views.py:106 core/views/forms.py:204 counter/views.py:38 msgid "Select user" msgstr "Choisir un utilisateur" -#: club/views.py:150 sas/views.py:81 sas/views.py:131 sas/views.py:181 +#: club/views.py:153 sas/views.py:81 sas/views.py:131 sas/views.py:181 msgid "You do not have the permission to do that" msgstr "Vous n'avez pas la permission de faire cela" -#: club/views.py:165 counter/views.py:908 +#: club/views.py:168 counter/views.py:908 msgid "Begin date" msgstr "Date de début" -#: club/views.py:166 com/views.py:81 counter/views.py:909 election/views.py:130 +#: club/views.py:169 com/views.py:81 counter/views.py:909 +#: election/views.py:131 msgid "End date" msgstr "Date de fin" -#: club/views.py:180 core/templates/core/user_stats.jinja:27 +#: club/views.py:183 core/templates/core/user_stats.jinja:27 #: counter/views.py:989 msgid "Product" msgstr "Produit" @@ -1071,8 +1095,9 @@ msgid "News admin" msgstr "Administration des nouvelles" #: com/templates/com/news_admin_list.jinja:9 -#: com/templates/com/news_detail.jinja:5 com/templates/com/news_detail.jinja:11 -#: com/templates/com/news_list.jinja:4 com/templates/com/news_list.jinja:28 +#: com/templates/com/news_detail.jinja:5 +#: com/templates/com/news_detail.jinja:11 com/templates/com/news_list.jinja:4 +#: com/templates/com/news_list.jinja:28 msgid "News" msgstr "Nouvelles" @@ -1194,7 +1219,7 @@ msgstr "Message d'info" msgid "Alert message" msgstr "Message d'alerte" -#: com/views.py:80 election/views.py:129 +#: com/views.py:80 election/views.py:130 msgid "Start date" msgstr "Date de début" @@ -1910,11 +1935,13 @@ msgstr "login" msgid "Lost password?" msgstr "Mot de passe perdu ?" -#: core/templates/core/macros.jinja:27 core/templates/core/user_detail.jinja:27 +#: core/templates/core/macros.jinja:27 +#: core/templates/core/user_detail.jinja:27 msgid "Born: " msgstr "Né le : " -#: core/templates/core/macros.jinja:31 core/templates/core/user_detail.jinja:48 +#: core/templates/core/macros.jinja:31 +#: core/templates/core/user_detail.jinja:48 msgid "Promo: " msgstr "Promo : " @@ -3196,7 +3223,7 @@ msgstr "Vous avez déjà soumis votre vote." msgid "You have voted in this election." msgstr "Vous avez déjà voté pour cette élection." -#: election/templates/election/election_detail.jinja:266 election/views.py:81 +#: election/templates/election/election_detail.jinja:266 election/views.py:82 msgid "Blank vote" msgstr "Vote blanc" @@ -3255,23 +3282,23 @@ msgstr "au" msgid "Polls open from" msgstr "Votes ouverts du" -#: election/views.py:43 +#: election/views.py:44 msgid "You have selected too much candidates." msgstr "Vous avez sélectionné trop de candidats." -#: election/views.py:58 +#: election/views.py:59 msgid "User to candidate" msgstr "Utilisateur se présentant" -#: election/views.py:101 +#: election/views.py:102 msgid "This role already exists for this election" msgstr "Ce rôle existe déjà pour cette élection" -#: election/views.py:131 +#: election/views.py:132 msgid "Start candidature" msgstr "Début des candidatures" -#: election/views.py:132 +#: election/views.py:133 msgid "End candidature" msgstr "Fin des candidatures"