mirror of https://gitlab.crans.org/bde/nk20
🐛 Fix treasury
This commit is contained in:
parent
9c3e978a41
commit
b0398e59b8
|
@ -1,11 +1,10 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import datetime
|
||||
|
||||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Submit
|
||||
from django import forms
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from note_kfet.inputs import DatePickerInput, AmountInput
|
||||
|
||||
|
@ -19,12 +18,13 @@ class InvoiceForm(forms.ModelForm):
|
|||
|
||||
# Django forms don't support date fields. We have to add it manually
|
||||
date = forms.DateField(
|
||||
initial=datetime.date.today,
|
||||
widget=DatePickerInput()
|
||||
initial=timezone.now,
|
||||
widget=DatePickerInput(),
|
||||
)
|
||||
|
||||
def clean_date(self):
|
||||
self.instance.date = self.data.get("date")
|
||||
return self.instance.date
|
||||
|
||||
class Meta:
|
||||
model = Invoice
|
||||
|
@ -36,7 +36,11 @@ class ProductForm(forms.ModelForm):
|
|||
model = Product
|
||||
fields = '__all__'
|
||||
widgets = {
|
||||
"amount": AmountInput()
|
||||
"amount": AmountInput(
|
||||
attrs={
|
||||
"negative": True,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,6 +119,12 @@ class LinkTransactionToRemittanceForm(forms.ModelForm):
|
|||
"""
|
||||
Attach a special transaction to a remittance.
|
||||
"""
|
||||
remittance = forms.ModelChoiceField(
|
||||
queryset=Remittance.objects.none(),
|
||||
label=_("Remittance"),
|
||||
empty_label=_("No attached remittance"),
|
||||
required=False,
|
||||
)
|
||||
|
||||
# Since we use a proxy model for special transactions, we add manually the fields related to the transaction
|
||||
last_name = forms.CharField(label=_("Last name"))
|
||||
|
@ -123,7 +133,7 @@ class LinkTransactionToRemittanceForm(forms.ModelForm):
|
|||
|
||||
bank = forms.Field(label=_("Bank"))
|
||||
|
||||
amount = forms.IntegerField(label=_("Amount"), min_value=0)
|
||||
amount = forms.IntegerField(label=_("Amount"), min_value=0, widget=AmountInput(), disabled=True, required=False)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -133,33 +143,19 @@ class LinkTransactionToRemittanceForm(forms.ModelForm):
|
|||
|
||||
self.fields["remittance"].queryset = Remittance.objects.filter(closed=False)
|
||||
|
||||
def clean_last_name(self):
|
||||
"""
|
||||
Replace the first name in the information of the transaction.
|
||||
"""
|
||||
self.instance.transaction.last_name = self.data.get("last_name")
|
||||
self.instance.transaction.clean()
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
self.instance.transaction.last_name = cleaned_data["last_name"]
|
||||
self.instance.transaction.first_name = cleaned_data["first_name"]
|
||||
self.instance.transaction.bank = cleaned_data["bank"]
|
||||
return cleaned_data
|
||||
|
||||
def clean_first_name(self):
|
||||
def save(self, commit=True):
|
||||
"""
|
||||
Replace the last name in the information of the transaction.
|
||||
Save the transaction and the remittance.
|
||||
"""
|
||||
self.instance.transaction.first_name = self.data.get("first_name")
|
||||
self.instance.transaction.clean()
|
||||
|
||||
def clean_bank(self):
|
||||
"""
|
||||
Replace the bank in the information of the transaction.
|
||||
"""
|
||||
self.instance.transaction.bank = self.data.get("bank")
|
||||
self.instance.transaction.clean()
|
||||
|
||||
def clean_amount(self):
|
||||
"""
|
||||
Replace the amount of the transaction.
|
||||
"""
|
||||
self.instance.transaction.amount = self.data.get("amount")
|
||||
self.instance.transaction.clean()
|
||||
self.instance.transaction.save()
|
||||
return super().save(commit)
|
||||
|
||||
class Meta:
|
||||
model = SpecialTransactionProxy
|
||||
|
|
|
@ -82,7 +82,7 @@ class Product(models.Model):
|
|||
verbose_name=_("Designation"),
|
||||
)
|
||||
|
||||
quantity = models.PositiveIntegerField(
|
||||
quantity = models.IntegerField(
|
||||
verbose_name=_("Quantity")
|
||||
)
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ class RemittanceTable(tables.Table):
|
|||
model = Remittance
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('id', 'date', 'remittance_type', 'comment', 'count', 'amount', 'view',)
|
||||
order_by = ('-date',)
|
||||
|
||||
|
||||
class SpecialTransactionTable(tables.Table):
|
||||
|
@ -100,7 +101,8 @@ class SpecialTransactionTable(tables.Table):
|
|||
}
|
||||
model = SpecialTransaction
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('id', 'source', 'destination', 'last_name', 'first_name', 'bank', 'amount', 'reason',)
|
||||
fields = ('created_at', 'source', 'destination', 'last_name', 'first_name', 'bank', 'amount', 'reason',)
|
||||
order_by = ('-created_at',)
|
||||
|
||||
|
||||
class SogeCreditTable(tables.Table):
|
||||
|
|
|
@ -238,7 +238,7 @@ class RemittanceListView(LoginRequiredMixin, TemplateView):
|
|||
|
||||
closed_remittances = RemittanceTable(
|
||||
data=Remittance.objects.filter(closed=True).filter(
|
||||
PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).reverse().all(),
|
||||
PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all(),
|
||||
prefix="closed-remittances-",
|
||||
)
|
||||
closed_remittances.paginate(page=self.request.GET.get("closed-remittances-page", 1), per_page=10)
|
||||
|
@ -281,8 +281,6 @@ class RemittanceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView)
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context["table"] = RemittanceTable(data=Remittance.objects.filter(
|
||||
PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all())
|
||||
data = SpecialTransaction.objects.filter(specialtransactionproxy__remittance=self.object).filter(
|
||||
PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all()
|
||||
context["special_transactions"] = SpecialTransactionTable(
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-05 16:18+0200\n"
|
||||
"POT-Creation-Date: 2020-08-05 16:49+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -187,13 +187,13 @@ msgid "Type"
|
|||
msgstr ""
|
||||
|
||||
#: apps/activity/tables.py:77 apps/member/forms.py:103
|
||||
#: apps/registration/forms.py:70 apps/treasury/forms.py:120
|
||||
#: apps/registration/forms.py:70 apps/treasury/forms.py:126
|
||||
#: apps/wei/forms/registration.py:95
|
||||
msgid "Last name"
|
||||
msgstr ""
|
||||
|
||||
#: apps/activity/tables.py:79 apps/member/forms.py:108
|
||||
#: apps/registration/forms.py:75 apps/treasury/forms.py:122
|
||||
#: apps/registration/forms.py:75 apps/treasury/forms.py:128
|
||||
#: apps/wei/forms/registration.py:100 templates/note/transaction_form.html:129
|
||||
msgid "First name"
|
||||
msgstr ""
|
||||
|
@ -347,7 +347,7 @@ msgid "Credit amount"
|
|||
msgstr ""
|
||||
|
||||
#: apps/member/forms.py:113 apps/registration/forms.py:80
|
||||
#: apps/treasury/forms.py:124 apps/wei/forms/registration.py:105
|
||||
#: apps/treasury/forms.py:130 apps/wei/forms/registration.py:105
|
||||
#: templates/note/transaction_form.html:135
|
||||
msgid "Bank"
|
||||
msgstr ""
|
||||
|
@ -687,7 +687,7 @@ msgstr ""
|
|||
msgid "Reason"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/forms.py:87 apps/treasury/tables.py:117
|
||||
#: apps/note/forms.py:87 apps/treasury/tables.py:119
|
||||
msgid "Valid"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ msgstr ""
|
|||
msgid "Treasury"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/forms.py:84 apps/treasury/forms.py:132
|
||||
#: apps/treasury/forms.py:84 apps/treasury/forms.py:138
|
||||
#: templates/activity/activity_form.html:9
|
||||
#: templates/activity/activity_invite.html:8
|
||||
#: templates/django_filters/rest_framework/form.html:5
|
||||
|
@ -1193,8 +1193,20 @@ msgstr ""
|
|||
msgid "You can't change the type of the remittance."
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/forms.py:126 apps/treasury/tables.py:47
|
||||
#: apps/treasury/tables.py:113 templates/note/transaction_form.html:97
|
||||
#: apps/treasury/forms.py:120 apps/treasury/models.py:207
|
||||
#: apps/treasury/tables.py:77 apps/treasury/tables.py:85
|
||||
#: templates/treasury/invoice_list.html:13
|
||||
#: templates/treasury/remittance_list.html:13
|
||||
#: templates/treasury/sogecredit_list.html:13
|
||||
msgid "Remittance"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/forms.py:121
|
||||
msgid "No attached remittance"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/forms.py:132 apps/treasury/tables.py:47
|
||||
#: apps/treasury/tables.py:115 templates/note/transaction_form.html:97
|
||||
#: templates/treasury/remittance_form.html:18
|
||||
msgid "Amount"
|
||||
msgstr ""
|
||||
|
@ -1291,13 +1303,6 @@ msgstr ""
|
|||
msgid "Remittance #{:d}: {}"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/models.py:207 apps/treasury/tables.py:76
|
||||
#: apps/treasury/tables.py:84 templates/treasury/invoice_list.html:13
|
||||
#: templates/treasury/remittance_list.html:13
|
||||
#: templates/treasury/sogecredit_list.html:13
|
||||
msgid "Remittance"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/models.py:211
|
||||
msgid "special transaction proxy"
|
||||
msgstr ""
|
||||
|
@ -1342,19 +1347,19 @@ msgstr ""
|
|||
msgid "View"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/tables.py:78
|
||||
#: apps/treasury/tables.py:79
|
||||
msgid "Add"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/tables.py:86
|
||||
#: apps/treasury/tables.py:87
|
||||
msgid "Remove"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/tables.py:124
|
||||
#: apps/treasury/tables.py:126
|
||||
msgid "Yes"
|
||||
msgstr ""
|
||||
|
||||
#: apps/treasury/tables.py:124
|
||||
#: apps/treasury/tables.py:126
|
||||
msgid "No"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2147,16 +2152,16 @@ msgid ""
|
|||
"activate your account."
|
||||
msgstr ""
|
||||
|
||||
#: templates/registration/email_validation_email_sent.html:4
|
||||
#: templates/registration/email_validation_email_sent.html:5
|
||||
msgid "Account activation"
|
||||
msgstr ""
|
||||
|
||||
#: templates/registration/email_validation_email_sent.html:7
|
||||
#: templates/registration/email_validation_email_sent.html:8
|
||||
msgid ""
|
||||
"An email has been sent. Please click on the link to activate your account."
|
||||
msgstr ""
|
||||
|
||||
#: templates/registration/email_validation_email_sent.html:11
|
||||
#: templates/registration/email_validation_email_sent.html:12
|
||||
msgid ""
|
||||
"You must also go to the Kfet to pay your membership. The WEI registration "
|
||||
"includes the BDE membership."
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-05 16:18+0200\n"
|
||||
"POT-Creation-Date: 2020-08-05 16:49+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -188,13 +188,13 @@ msgid "Type"
|
|||
msgstr "Type"
|
||||
|
||||
#: apps/activity/tables.py:77 apps/member/forms.py:103
|
||||
#: apps/registration/forms.py:70 apps/treasury/forms.py:120
|
||||
#: apps/registration/forms.py:70 apps/treasury/forms.py:126
|
||||
#: apps/wei/forms/registration.py:95
|
||||
msgid "Last name"
|
||||
msgstr "Nom de famille"
|
||||
|
||||
#: apps/activity/tables.py:79 apps/member/forms.py:108
|
||||
#: apps/registration/forms.py:75 apps/treasury/forms.py:122
|
||||
#: apps/registration/forms.py:75 apps/treasury/forms.py:128
|
||||
#: apps/wei/forms/registration.py:100 templates/note/transaction_form.html:129
|
||||
msgid "First name"
|
||||
msgstr "Prénom"
|
||||
|
@ -348,7 +348,7 @@ msgid "Credit amount"
|
|||
msgstr "Montant à créditer"
|
||||
|
||||
#: apps/member/forms.py:113 apps/registration/forms.py:80
|
||||
#: apps/treasury/forms.py:124 apps/wei/forms/registration.py:105
|
||||
#: apps/treasury/forms.py:130 apps/wei/forms/registration.py:105
|
||||
#: templates/note/transaction_form.html:135
|
||||
msgid "Bank"
|
||||
msgstr "Banque"
|
||||
|
@ -694,7 +694,7 @@ msgstr "Destination"
|
|||
msgid "Reason"
|
||||
msgstr "Raison"
|
||||
|
||||
#: apps/note/forms.py:87 apps/treasury/tables.py:117
|
||||
#: apps/note/forms.py:87 apps/treasury/tables.py:119
|
||||
msgid "Valid"
|
||||
msgstr "Valide"
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ msgstr "Invalider l'inscription"
|
|||
msgid "Treasury"
|
||||
msgstr "Trésorerie"
|
||||
|
||||
#: apps/treasury/forms.py:84 apps/treasury/forms.py:132
|
||||
#: apps/treasury/forms.py:84 apps/treasury/forms.py:138
|
||||
#: templates/activity/activity_form.html:9
|
||||
#: templates/activity/activity_invite.html:8
|
||||
#: templates/django_filters/rest_framework/form.html:5
|
||||
|
@ -1222,8 +1222,20 @@ msgstr "La remise est déjà fermée."
|
|||
msgid "You can't change the type of the remittance."
|
||||
msgstr "Vous ne pouvez pas changer le type de la remise."
|
||||
|
||||
#: apps/treasury/forms.py:126 apps/treasury/tables.py:47
|
||||
#: apps/treasury/tables.py:113 templates/note/transaction_form.html:97
|
||||
#: apps/treasury/forms.py:120 apps/treasury/models.py:207
|
||||
#: apps/treasury/tables.py:77 apps/treasury/tables.py:85
|
||||
#: templates/treasury/invoice_list.html:13
|
||||
#: templates/treasury/remittance_list.html:13
|
||||
#: templates/treasury/sogecredit_list.html:13
|
||||
msgid "Remittance"
|
||||
msgstr "Remise"
|
||||
|
||||
#: apps/treasury/forms.py:121
|
||||
msgid "No attached remittance"
|
||||
msgstr "Pas de remise associée"
|
||||
|
||||
#: apps/treasury/forms.py:132 apps/treasury/tables.py:47
|
||||
#: apps/treasury/tables.py:115 templates/note/transaction_form.html:97
|
||||
#: templates/treasury/remittance_form.html:18
|
||||
msgid "Amount"
|
||||
msgstr "Montant"
|
||||
|
@ -1320,13 +1332,6 @@ msgstr "remises"
|
|||
msgid "Remittance #{:d}: {}"
|
||||
msgstr "Remise n°{:d} : {}"
|
||||
|
||||
#: apps/treasury/models.py:207 apps/treasury/tables.py:76
|
||||
#: apps/treasury/tables.py:84 templates/treasury/invoice_list.html:13
|
||||
#: templates/treasury/remittance_list.html:13
|
||||
#: templates/treasury/sogecredit_list.html:13
|
||||
msgid "Remittance"
|
||||
msgstr "Remise"
|
||||
|
||||
#: apps/treasury/models.py:211
|
||||
msgid "special transaction proxy"
|
||||
msgstr "Proxy de transaction spéciale"
|
||||
|
@ -1373,19 +1378,19 @@ msgstr "Nombre de transactions"
|
|||
msgid "View"
|
||||
msgstr "Voir"
|
||||
|
||||
#: apps/treasury/tables.py:78
|
||||
#: apps/treasury/tables.py:79
|
||||
msgid "Add"
|
||||
msgstr "Ajouter"
|
||||
|
||||
#: apps/treasury/tables.py:86
|
||||
#: apps/treasury/tables.py:87
|
||||
msgid "Remove"
|
||||
msgstr "supprimer"
|
||||
|
||||
#: apps/treasury/tables.py:124
|
||||
#: apps/treasury/tables.py:126
|
||||
msgid "Yes"
|
||||
msgstr "Oui"
|
||||
|
||||
#: apps/treasury/tables.py:124
|
||||
#: apps/treasury/tables.py:126
|
||||
msgid "No"
|
||||
msgstr "Non"
|
||||
|
||||
|
@ -2218,18 +2223,18 @@ msgstr ""
|
|||
"Le lien est invalide. Le jeton a sans doute expiré. Merci de nous contacter "
|
||||
"pour activer votre compte."
|
||||
|
||||
#: templates/registration/email_validation_email_sent.html:4
|
||||
#: templates/registration/email_validation_email_sent.html:5
|
||||
msgid "Account activation"
|
||||
msgstr "Activation du compte"
|
||||
|
||||
#: templates/registration/email_validation_email_sent.html:7
|
||||
#: templates/registration/email_validation_email_sent.html:8
|
||||
msgid ""
|
||||
"An email has been sent. Please click on the link to activate your account."
|
||||
msgstr ""
|
||||
"Un email vient de vous être envoyé. Merci de cliquer sur le lien de "
|
||||
"validation pour activer votre compte."
|
||||
|
||||
#: templates/registration/email_validation_email_sent.html:11
|
||||
#: templates/registration/email_validation_email_sent.html:12
|
||||
msgid ""
|
||||
"You must also go to the Kfet to pay your membership. The WEI registration "
|
||||
"includes the BDE membership."
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="input-group">
|
||||
<input class="form-control mx-auto d-block" type="number" min="0" step="0.01"
|
||||
<input class="form-control mx-auto d-block" type="number" {% if not widget.attrs.negative %}min="0"{% endif %} step="0.01"
|
||||
{% if widget.value != None and widget.value != "" %}value="{{ widget.value }}"{% endif %}
|
||||
name="{{ widget.name }}"
|
||||
{% for name, value in widget.attrs.items %}
|
||||
|
|
Loading…
Reference in New Issue