diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index c4afa200..c31ea6a5 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -2359,6 +2359,22 @@ "description": "Voir toutes les notes" } }, + { + "model": "permission.permission", + "pk": 151, + "fields": { + "model": [ + "treasury", + "invoice" + ], + "query": "{}", + "type": "delete", + "mask": 3, + "field": "", + "permanent": false, + "description": "Supprimer une facture" + } + }, { "model": "permission.role", "pk": 1, @@ -2539,7 +2555,8 @@ 143, 146, 147, - 150 + 150, + 151 ] } }, @@ -2695,7 +2712,8 @@ 147, 148, 149, - 150 + 150, + 151 ] } }, diff --git a/apps/treasury/forms.py b/apps/treasury/forms.py index b5f9284e..38da324d 100644 --- a/apps/treasury/forms.py +++ b/apps/treasury/forms.py @@ -4,9 +4,8 @@ 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 +from note_kfet.inputs import AmountInput from .models import Invoice, Product, Remittance, SpecialTransactionProxy @@ -16,19 +15,25 @@ class InvoiceForm(forms.ModelForm): Create and generate invoices. """ - # Django forms don't support date fields. We have to add it manually - date = forms.DateField( - initial=timezone.now, - widget=DatePickerInput(), - ) + def clean(self): + if self.instance and self.instance.locked: + for field_name in self.fields: + self.cleaned_data[field_name] = getattr(self.instance, field_name) + self.errors.clear() + return self.cleaned_data + return super().clean() - def clean_date(self): - self.instance.date = self.data.get("date") - return self.instance.date + def save(self, commit=True): + """ + If the invoice is locked, don't save it + """ + if not self.instance.locked: + super().save(commit) + return self.instance class Meta: model = Invoice - exclude = ('bde', 'tex', ) + exclude = ('bde', 'date', 'tex', ) class ProductForm(forms.ModelForm): diff --git a/apps/treasury/models.py b/apps/treasury/models.py index adbda701..2d6d93dc 100644 --- a/apps/treasury/models.py +++ b/apps/treasury/models.py @@ -61,6 +61,13 @@ class Invoice(models.Model): acquitted = models.BooleanField( verbose_name=_("Acquitted"), + default=False, + ) + + locked = models.BooleanField( + verbose_name=_("Locked"), + help_text=_("An invoice can't be edited when it is locked."), + default=False, ) tex = models.TextField( @@ -74,6 +81,12 @@ class Invoice(models.Model): The advantage is to never change the template. Warning: editing this model regenerate the tex source, so be careful. """ + + old_invoice = Invoice.objects.filter(id=self.id) + if old_invoice.exists(): + if old_invoice.get().locked: + raise ValidationError(_("This invoice is locked and can no longer be edited.")) + products = self.products.all() self.place = "Gif-sur-Yvette" @@ -103,7 +116,7 @@ class Product(models.Model): invoice = models.ForeignKey( Invoice, - on_delete=models.PROTECT, + on_delete=models.CASCADE, related_name="products", verbose_name=_("invoice"), ) diff --git a/apps/treasury/tables.py b/apps/treasury/tables.py index c7bdb6eb..b8843d0d 100644 --- a/apps/treasury/tables.py +++ b/apps/treasury/tables.py @@ -14,19 +14,39 @@ class InvoiceTable(tables.Table): """ List all invoices. """ - id = tables.LinkColumn("treasury:invoice_update", - args=[A("pk")], - text=lambda record: _("Invoice #{:d}").format(record.id), ) + id = tables.LinkColumn( + "treasury:invoice_update", + args=[A("pk")], + text=lambda record: _("Invoice #{:d}").format(record.id), + ) - invoice = tables.LinkColumn("treasury:invoice_render", - verbose_name=_("Invoice"), - args=[A("pk")], - accessor="pk", - text="", - attrs={ - 'a': {'class': 'fa fa-file-pdf-o'}, - 'td': {'data-turbolinks': 'false'} - }) + invoice = tables.LinkColumn( + "treasury:invoice_render", + verbose_name=_("Invoice"), + args=[A("pk")], + accessor="pk", + text="", + attrs={ + 'a': {'class': 'fa fa-file-pdf-o'}, + 'td': {'data-turbolinks': 'false'} + } + ) + + delete = tables.LinkColumn( + 'treasury:invoice_delete', + args=[A('pk')], + verbose_name=_("delete"), + text=_("Delete"), + attrs={ + 'th': { + 'id': 'delete-membership-header' + }, + 'a': { + 'class': 'btn btn-danger', + 'data-type': 'delete-membership' + } + }, + ) class Meta: attrs = { diff --git a/apps/treasury/urls.py b/apps/treasury/urls.py index 8606fb5b..e7c09639 100644 --- a/apps/treasury/urls.py +++ b/apps/treasury/urls.py @@ -3,9 +3,9 @@ from django.urls import path -from .views import InvoiceCreateView, InvoiceListView, InvoiceUpdateView, InvoiceRenderView, RemittanceListView,\ - RemittanceCreateView, RemittanceUpdateView, LinkTransactionToRemittanceView, UnlinkTransactionToRemittanceView,\ - SogeCreditListView, SogeCreditManageView +from .views import InvoiceCreateView, InvoiceListView, InvoiceUpdateView, InvoiceDeleteView, InvoiceRenderView,\ + RemittanceListView, RemittanceCreateView, RemittanceUpdateView, LinkTransactionToRemittanceView,\ + UnlinkTransactionToRemittanceView, SogeCreditListView, SogeCreditManageView app_name = 'treasury' urlpatterns = [ @@ -13,6 +13,7 @@ urlpatterns = [ path('invoice/', InvoiceListView.as_view(), name='invoice_list'), path('invoice/create/', InvoiceCreateView.as_view(), name='invoice_create'), path('invoice//', InvoiceUpdateView.as_view(), name='invoice_update'), + path('invoice//delete/', InvoiceDeleteView.as_view(), name='invoice_delete'), path('invoice/render//', InvoiceRenderView.as_view(), name='invoice_render'), # Remittance app paths diff --git a/apps/treasury/views.py b/apps/treasury/views.py index 4ac8822b..b3da4d69 100644 --- a/apps/treasury/views.py +++ b/apps/treasury/views.py @@ -18,7 +18,7 @@ from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, UpdateView, DetailView from django.views.generic.base import View, TemplateView -from django.views.generic.edit import BaseFormView +from django.views.generic.edit import BaseFormView, DeleteView from django_tables2 import SingleTableView from note.models import SpecialTransaction, NoteSpecial, Alias from note_kfet.settings.base import BASE_DIR @@ -97,14 +97,20 @@ class InvoiceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): form.helper = FormHelper() # Remove form tag on the generation of the form in the template (already present on the template) form.helper.form_tag = False - # Fill the intial value for the date field, with the initial date of the model instance - form.fields['date'].initial = form.instance.date # The formset handles the set of the products - form_set = ProductFormSet(instance=form.instance) + form_set = ProductFormSet(instance=self.object) context['formset'] = form_set context['helper'] = ProductFormSetHelper() context['no_cache'] = True + if self.object.locked: + for field_name in form.fields: + form.fields[field_name].disabled = True + for f in form_set.forms: + for field_name in f.fields: + f.fields[field_name].disabled = True + + return context def form_valid(self, form): @@ -131,6 +137,17 @@ class InvoiceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): return reverse_lazy('treasury:invoice_list') +class InvoiceDeleteView(ProtectQuerysetMixin, LoginRequiredMixin, DeleteView): + """ + Delete a non-validated WEI registration + """ + model = Invoice + extra_context = {"title": _("Delete invoice")} + + def get_success_url(self): + return reverse_lazy('treasury:invoice_list') + + class InvoiceRenderView(LoginRequiredMixin, View): """ Render Invoice as a generated PDF with the given information and a LaTeX template diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 4d957992..20b8f3e7 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-08-06 22:27+0200\n" +"POT-Creation-Date: 2020-08-07 11:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -96,7 +96,7 @@ msgid "type" msgstr "" #: apps/activity/models.py:87 apps/logs/models.py:22 apps/member/models.py:280 -#: apps/note/models/notes.py:126 apps/treasury/models.py:253 +#: apps/note/models/notes.py:126 apps/treasury/models.py:266 #: apps/wei/models.py:160 templates/treasury/sogecredit_detail.html:14 #: templates/wei/survey.html:16 msgid "user" @@ -194,18 +194,18 @@ msgstr "" msgid "remove" msgstr "" -#: apps/activity/tables.py:79 apps/note/forms.py:76 apps/treasury/models.py:172 +#: apps/activity/tables.py:79 apps/note/forms.py:76 apps/treasury/models.py:185 msgid "Type" msgstr "" #: apps/activity/tables.py:81 apps/member/forms.py:106 -#: apps/registration/forms.py:70 apps/treasury/forms.py:130 +#: apps/registration/forms.py:70 apps/treasury/forms.py:135 #: apps/wei/forms/registration.py:94 msgid "Last name" msgstr "" #: apps/activity/tables.py:83 apps/member/forms.py:111 -#: apps/registration/forms.py:75 apps/treasury/forms.py:132 +#: apps/registration/forms.py:75 apps/treasury/forms.py:137 #: apps/wei/forms/registration.py:99 templates/note/transaction_form.html:131 msgid "First name" msgstr "" @@ -280,7 +280,8 @@ msgid "edit" msgstr "" #: apps/logs/models.py:63 apps/note/tables.py:137 apps/note/tables.py:165 -#: apps/permission/models.py:129 apps/wei/tables.py:73 +#: apps/permission/models.py:129 apps/treasury/tables.py:38 +#: apps/wei/tables.py:73 msgid "delete" msgstr "" @@ -367,7 +368,7 @@ msgid "Credit amount" msgstr "" #: apps/member/forms.py:116 apps/registration/forms.py:80 -#: apps/treasury/forms.py:134 apps/wei/forms/registration.py:104 +#: apps/treasury/forms.py:139 apps/wei/forms/registration.py:104 #: templates/note/transaction_form.html:137 msgid "Bank" msgstr "" @@ -715,7 +716,7 @@ msgstr "" msgid "Reason" msgstr "" -#: apps/note/forms.py:87 apps/treasury/tables.py:119 +#: apps/note/forms.py:87 apps/treasury/tables.py:139 msgid "Valid" msgstr "" @@ -960,7 +961,7 @@ msgstr "" msgid "membership transaction" msgstr "" -#: apps/note/models/transactions.py:344 apps/treasury/models.py:259 +#: apps/note/models/transactions.py:344 apps/treasury/models.py:272 msgid "membership transactions" msgstr "" @@ -976,8 +977,10 @@ msgstr "" msgid "No reason specified" msgstr "" -#: apps/note/tables.py:139 apps/note/tables.py:167 apps/wei/tables.py:74 -#: apps/wei/tables.py:100 templates/treasury/sogecredit_detail.html:59 +#: apps/note/tables.py:139 apps/note/tables.py:167 apps/treasury/tables.py:39 +#: apps/wei/tables.py:74 apps/wei/tables.py:100 +#: templates/treasury/invoice_confirm_delete.html:28 +#: templates/treasury/sogecredit_detail.html:59 #: templates/wei/weiregistration_confirm_delete.html:32 msgid "Delete" msgstr "" @@ -1197,44 +1200,44 @@ msgstr "" msgid "Treasury" msgstr "" -#: apps/treasury/forms.py:88 apps/treasury/forms.py:142 +#: apps/treasury/forms.py:93 apps/treasury/forms.py:147 #: templates/activity/activity_form.html:9 #: templates/activity/activity_invite.html:8 #: templates/django_filters/rest_framework/form.html:5 #: templates/member/add_members.html:31 templates/member/club_form.html:9 #: templates/note/transactiontemplate_form.html:15 -#: templates/treasury/invoice_form.html:56 templates/wei/bus_form.html:13 +#: templates/treasury/invoice_form.html:64 templates/wei/bus_form.html:13 #: templates/wei/busteam_form.html:13 templates/wei/weiclub_form.html:15 #: templates/wei/weiregistration_form.html:14 msgid "Submit" msgstr "" -#: apps/treasury/forms.py:90 +#: apps/treasury/forms.py:95 msgid "Close" msgstr "" -#: apps/treasury/forms.py:99 +#: apps/treasury/forms.py:104 msgid "Remittance is already closed." msgstr "" -#: apps/treasury/forms.py:104 +#: apps/treasury/forms.py:109 msgid "You can't change the type of the remittance." msgstr "" -#: apps/treasury/forms.py:124 apps/treasury/models.py:238 -#: apps/treasury/tables.py:77 apps/treasury/tables.py:85 +#: apps/treasury/forms.py:129 apps/treasury/models.py:251 +#: apps/treasury/tables.py:97 apps/treasury/tables.py:105 #: 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:125 +#: apps/treasury/forms.py:130 msgid "No attached remittance" msgstr "" -#: apps/treasury/forms.py:136 apps/treasury/tables.py:47 -#: apps/treasury/tables.py:115 templates/note/transaction_form.html:99 +#: apps/treasury/forms.py:141 apps/treasury/tables.py:67 +#: apps/treasury/tables.py:135 templates/note/transaction_form.html:99 #: templates/treasury/remittance_form.html:18 msgid "Amount" msgstr "" @@ -1263,7 +1266,7 @@ msgstr "" msgid "Address" msgstr "" -#: apps/treasury/models.py:59 apps/treasury/models.py:166 +#: apps/treasury/models.py:59 apps/treasury/models.py:179 msgid "Date" msgstr "" @@ -1272,122 +1275,134 @@ msgid "Acquitted" msgstr "" #: apps/treasury/models.py:68 +msgid "Locked" +msgstr "" + +#: apps/treasury/models.py:69 +msgid "An invoice can't be edited when it is locked." +msgstr "" + +#: apps/treasury/models.py:75 msgid "tex source" msgstr "" -#: apps/treasury/models.py:95 apps/treasury/models.py:108 +#: apps/treasury/models.py:88 templates/treasury/invoice_form.html:17 +msgid "This invoice is locked and can no longer be edited." +msgstr "" + +#: apps/treasury/models.py:108 apps/treasury/models.py:121 msgid "invoice" msgstr "" -#: apps/treasury/models.py:96 +#: apps/treasury/models.py:109 msgid "invoices" msgstr "" -#: apps/treasury/models.py:113 +#: apps/treasury/models.py:126 msgid "Designation" msgstr "" -#: apps/treasury/models.py:117 +#: apps/treasury/models.py:130 msgid "Quantity" msgstr "" -#: apps/treasury/models.py:121 +#: apps/treasury/models.py:134 msgid "Unit price" msgstr "" -#: apps/treasury/models.py:137 +#: apps/treasury/models.py:150 msgid "product" msgstr "" -#: apps/treasury/models.py:138 +#: apps/treasury/models.py:151 msgid "products" msgstr "" -#: apps/treasury/models.py:155 +#: apps/treasury/models.py:168 msgid "remittance type" msgstr "" -#: apps/treasury/models.py:156 +#: apps/treasury/models.py:169 msgid "remittance types" msgstr "" -#: apps/treasury/models.py:177 +#: apps/treasury/models.py:190 msgid "Comment" msgstr "" -#: apps/treasury/models.py:182 +#: apps/treasury/models.py:195 msgid "Closed" msgstr "" -#: apps/treasury/models.py:186 +#: apps/treasury/models.py:199 msgid "remittance" msgstr "" -#: apps/treasury/models.py:187 +#: apps/treasury/models.py:200 msgid "remittances" msgstr "" -#: apps/treasury/models.py:219 +#: apps/treasury/models.py:232 msgid "Remittance #{:d}: {}" msgstr "" -#: apps/treasury/models.py:242 +#: apps/treasury/models.py:255 msgid "special transaction proxy" msgstr "" -#: apps/treasury/models.py:243 +#: apps/treasury/models.py:256 msgid "special transaction proxies" msgstr "" -#: apps/treasury/models.py:265 +#: apps/treasury/models.py:278 msgid "credit transaction" msgstr "" -#: apps/treasury/models.py:328 +#: apps/treasury/models.py:341 msgid "" "This user doesn't have enough money to pay the memberships with its note. " "Please ask her/him to credit the note before invalidating this credit." msgstr "" -#: apps/treasury/models.py:340 templates/treasury/sogecredit_detail.html:10 +#: apps/treasury/models.py:353 templates/treasury/sogecredit_detail.html:10 msgid "Credit from the Société générale" msgstr "" -#: apps/treasury/models.py:341 +#: apps/treasury/models.py:354 msgid "Credits from the Société générale" msgstr "" -#: apps/treasury/tables.py:19 +#: apps/treasury/tables.py:20 msgid "Invoice #{:d}" msgstr "" -#: apps/treasury/tables.py:22 templates/treasury/invoice_list.html:10 +#: apps/treasury/tables.py:25 templates/treasury/invoice_list.html:10 #: templates/treasury/remittance_list.html:10 #: templates/treasury/sogecredit_list.html:10 msgid "Invoice" msgstr "" -#: apps/treasury/tables.py:45 +#: apps/treasury/tables.py:65 msgid "Transaction count" msgstr "" -#: apps/treasury/tables.py:50 apps/treasury/tables.py:52 +#: apps/treasury/tables.py:70 apps/treasury/tables.py:72 msgid "View" msgstr "" -#: apps/treasury/tables.py:79 +#: apps/treasury/tables.py:99 msgid "Add" msgstr "" -#: apps/treasury/tables.py:87 +#: apps/treasury/tables.py:107 msgid "Remove" msgstr "" -#: apps/treasury/tables.py:126 +#: apps/treasury/tables.py:146 msgid "Yes" msgstr "" -#: apps/treasury/tables.py:126 +#: apps/treasury/tables.py:146 msgid "No" msgstr "" @@ -1403,28 +1418,32 @@ msgstr "" msgid "Update an invoice" msgstr "" -#: apps/treasury/views.py:188 +#: apps/treasury/views.py:145 templates/treasury/invoice_confirm_delete.html:8 +msgid "Delete invoice" +msgstr "" + +#: apps/treasury/views.py:205 msgid "Create a new remittance" msgstr "" -#: apps/treasury/views.py:209 templates/treasury/remittance_form.html:9 +#: apps/treasury/views.py:226 templates/treasury/remittance_form.html:9 #: templates/treasury/specialtransactionproxy_form.html:7 msgid "Remittances list" msgstr "" -#: apps/treasury/views.py:259 +#: apps/treasury/views.py:276 msgid "Update a remittance" msgstr "" -#: apps/treasury/views.py:282 +#: apps/treasury/views.py:299 msgid "Attach a transaction to a remittance" msgstr "" -#: apps/treasury/views.py:326 +#: apps/treasury/views.py:343 msgid "List of credits from the Société générale" msgstr "" -#: apps/treasury/views.py:360 +#: apps/treasury/views.py:377 msgid "Manage credits from the Société générale" msgstr "" @@ -2365,17 +2384,30 @@ msgid "" "by following the link you received." msgstr "" +#: templates/treasury/invoice_confirm_delete.html:13 +msgid "This invoice is locked and can't be deleted." +msgstr "" + +#: templates/treasury/invoice_confirm_delete.html:19 +msgid "" +"Are you sure you want to delete this invoice? This action can't be undone." +msgstr "" + +#: templates/treasury/invoice_confirm_delete.html:26 +msgid "Return to invoices list" +msgstr "" + #: templates/treasury/invoice_form.html:10 msgid "" "Warning: the LaTeX template is saved with this object. Updating the invoice " "implies regenerate it. Be careful if you manipulate old invoices." msgstr "" -#: templates/treasury/invoice_form.html:51 +#: templates/treasury/invoice_form.html:58 msgid "Add product" msgstr "" -#: templates/treasury/invoice_form.html:52 +#: templates/treasury/invoice_form.html:59 msgid "Remove product" msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index e440843f..7d0dcd54 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-08-06 22:27+0200\n" +"POT-Creation-Date: 2020-08-07 11:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -97,7 +97,7 @@ msgid "type" msgstr "type" #: apps/activity/models.py:87 apps/logs/models.py:22 apps/member/models.py:280 -#: apps/note/models/notes.py:126 apps/treasury/models.py:253 +#: apps/note/models/notes.py:126 apps/treasury/models.py:266 #: apps/wei/models.py:160 templates/treasury/sogecredit_detail.html:14 #: templates/wei/survey.html:16 msgid "user" @@ -195,18 +195,18 @@ msgstr "Entré le " msgid "remove" msgstr "supprimer" -#: apps/activity/tables.py:79 apps/note/forms.py:76 apps/treasury/models.py:172 +#: apps/activity/tables.py:79 apps/note/forms.py:76 apps/treasury/models.py:185 msgid "Type" msgstr "Type" #: apps/activity/tables.py:81 apps/member/forms.py:106 -#: apps/registration/forms.py:70 apps/treasury/forms.py:130 +#: apps/registration/forms.py:70 apps/treasury/forms.py:135 #: apps/wei/forms/registration.py:94 msgid "Last name" msgstr "Nom de famille" #: apps/activity/tables.py:83 apps/member/forms.py:111 -#: apps/registration/forms.py:75 apps/treasury/forms.py:132 +#: apps/registration/forms.py:75 apps/treasury/forms.py:137 #: apps/wei/forms/registration.py:99 templates/note/transaction_form.html:131 msgid "First name" msgstr "Prénom" @@ -281,7 +281,8 @@ msgid "edit" msgstr "Modifier" #: apps/logs/models.py:63 apps/note/tables.py:137 apps/note/tables.py:165 -#: apps/permission/models.py:129 apps/wei/tables.py:73 +#: apps/permission/models.py:129 apps/treasury/tables.py:38 +#: apps/wei/tables.py:73 msgid "delete" msgstr "Supprimer" @@ -368,7 +369,7 @@ msgid "Credit amount" msgstr "Montant à créditer" #: apps/member/forms.py:116 apps/registration/forms.py:80 -#: apps/treasury/forms.py:134 apps/wei/forms/registration.py:104 +#: apps/treasury/forms.py:139 apps/wei/forms/registration.py:104 #: templates/note/transaction_form.html:137 msgid "Bank" msgstr "Banque" @@ -722,7 +723,7 @@ msgstr "Destination" msgid "Reason" msgstr "Raison" -#: apps/note/forms.py:87 apps/treasury/tables.py:119 +#: apps/note/forms.py:87 apps/treasury/tables.py:139 msgid "Valid" msgstr "Valide" @@ -974,7 +975,7 @@ msgstr "Transactions de crédit/retrait" msgid "membership transaction" msgstr "Transaction d'adhésion" -#: apps/note/models/transactions.py:344 apps/treasury/models.py:259 +#: apps/note/models/transactions.py:344 apps/treasury/models.py:272 msgid "membership transactions" msgstr "Transactions d'adhésion" @@ -990,8 +991,10 @@ msgstr "Cliquez pour valider" msgid "No reason specified" msgstr "Pas de motif spécifié" -#: apps/note/tables.py:139 apps/note/tables.py:167 apps/wei/tables.py:74 -#: apps/wei/tables.py:100 templates/treasury/sogecredit_detail.html:59 +#: apps/note/tables.py:139 apps/note/tables.py:167 apps/treasury/tables.py:39 +#: apps/wei/tables.py:74 apps/wei/tables.py:100 +#: templates/treasury/invoice_confirm_delete.html:28 +#: templates/treasury/sogecredit_detail.html:59 #: templates/wei/weiregistration_confirm_delete.html:32 msgid "Delete" msgstr "Supprimer" @@ -1226,44 +1229,44 @@ msgstr "Invalider l'inscription" msgid "Treasury" msgstr "Trésorerie" -#: apps/treasury/forms.py:88 apps/treasury/forms.py:142 +#: apps/treasury/forms.py:93 apps/treasury/forms.py:147 #: templates/activity/activity_form.html:9 #: templates/activity/activity_invite.html:8 #: templates/django_filters/rest_framework/form.html:5 #: templates/member/add_members.html:31 templates/member/club_form.html:9 #: templates/note/transactiontemplate_form.html:15 -#: templates/treasury/invoice_form.html:56 templates/wei/bus_form.html:13 +#: templates/treasury/invoice_form.html:64 templates/wei/bus_form.html:13 #: templates/wei/busteam_form.html:13 templates/wei/weiclub_form.html:15 #: templates/wei/weiregistration_form.html:14 msgid "Submit" msgstr "Envoyer" -#: apps/treasury/forms.py:90 +#: apps/treasury/forms.py:95 msgid "Close" msgstr "Fermer" -#: apps/treasury/forms.py:99 +#: apps/treasury/forms.py:104 msgid "Remittance is already closed." msgstr "La remise est déjà fermée." -#: apps/treasury/forms.py:104 +#: apps/treasury/forms.py:109 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:124 apps/treasury/models.py:238 -#: apps/treasury/tables.py:77 apps/treasury/tables.py:85 +#: apps/treasury/forms.py:129 apps/treasury/models.py:251 +#: apps/treasury/tables.py:97 apps/treasury/tables.py:105 #: 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:125 +#: apps/treasury/forms.py:130 msgid "No attached remittance" msgstr "Pas de remise associée" -#: apps/treasury/forms.py:136 apps/treasury/tables.py:47 -#: apps/treasury/tables.py:115 templates/note/transaction_form.html:99 +#: apps/treasury/forms.py:141 apps/treasury/tables.py:67 +#: apps/treasury/tables.py:135 templates/note/transaction_form.html:99 #: templates/treasury/remittance_form.html:18 msgid "Amount" msgstr "Montant" @@ -1292,7 +1295,7 @@ msgstr "Nom" msgid "Address" msgstr "Adresse" -#: apps/treasury/models.py:59 apps/treasury/models.py:166 +#: apps/treasury/models.py:59 apps/treasury/models.py:179 msgid "Date" msgstr "Date" @@ -1301,80 +1304,92 @@ msgid "Acquitted" msgstr "Acquittée" #: apps/treasury/models.py:68 +msgid "Locked" +msgstr "Verrouillée" + +#: apps/treasury/models.py:69 +msgid "An invoice can't be edited when it is locked." +msgstr "Une facture ne peut plus être modifiée si elle est verrouillée." + +#: apps/treasury/models.py:75 #, fuzzy #| msgid "source" msgid "tex source" msgstr "source" -#: apps/treasury/models.py:95 apps/treasury/models.py:108 +#: apps/treasury/models.py:88 templates/treasury/invoice_form.html:17 +msgid "This invoice is locked and can no longer be edited." +msgstr "Cette facture est verrouillée et ne peut plus être éditée." + +#: apps/treasury/models.py:108 apps/treasury/models.py:121 msgid "invoice" msgstr "facture" -#: apps/treasury/models.py:96 +#: apps/treasury/models.py:109 msgid "invoices" msgstr "factures" -#: apps/treasury/models.py:113 +#: apps/treasury/models.py:126 msgid "Designation" msgstr "Désignation" -#: apps/treasury/models.py:117 +#: apps/treasury/models.py:130 msgid "Quantity" msgstr "Quantité" -#: apps/treasury/models.py:121 +#: apps/treasury/models.py:134 msgid "Unit price" msgstr "Prix unitaire" -#: apps/treasury/models.py:137 +#: apps/treasury/models.py:150 msgid "product" msgstr "produit" -#: apps/treasury/models.py:138 +#: apps/treasury/models.py:151 msgid "products" msgstr "produits" -#: apps/treasury/models.py:155 +#: apps/treasury/models.py:168 msgid "remittance type" msgstr "type de remise" -#: apps/treasury/models.py:156 +#: apps/treasury/models.py:169 msgid "remittance types" msgstr "types de remises" -#: apps/treasury/models.py:177 +#: apps/treasury/models.py:190 msgid "Comment" msgstr "Commentaire" -#: apps/treasury/models.py:182 +#: apps/treasury/models.py:195 msgid "Closed" msgstr "Fermée" -#: apps/treasury/models.py:186 +#: apps/treasury/models.py:199 msgid "remittance" msgstr "remise" -#: apps/treasury/models.py:187 +#: apps/treasury/models.py:200 msgid "remittances" msgstr "remises" -#: apps/treasury/models.py:219 +#: apps/treasury/models.py:232 msgid "Remittance #{:d}: {}" msgstr "Remise n°{:d} : {}" -#: apps/treasury/models.py:242 +#: apps/treasury/models.py:255 msgid "special transaction proxy" msgstr "Proxy de transaction spéciale" -#: apps/treasury/models.py:243 +#: apps/treasury/models.py:256 msgid "special transaction proxies" msgstr "Proxys de transactions spéciales" -#: apps/treasury/models.py:265 +#: apps/treasury/models.py:278 msgid "credit transaction" msgstr "transaction de crédit" -#: apps/treasury/models.py:328 +#: apps/treasury/models.py:341 msgid "" "This user doesn't have enough money to pay the memberships with its note. " "Please ask her/him to credit the note before invalidating this credit." @@ -1382,45 +1397,45 @@ msgstr "" "Cet utilisateur n'a pas assez d'argent pour payer les adhésions avec sa " "note. Merci de lui demander de recharger sa note avant d'invalider ce crédit." -#: apps/treasury/models.py:340 templates/treasury/sogecredit_detail.html:10 +#: apps/treasury/models.py:353 templates/treasury/sogecredit_detail.html:10 msgid "Credit from the Société générale" msgstr "Crédit de la Société générale" -#: apps/treasury/models.py:341 +#: apps/treasury/models.py:354 msgid "Credits from the Société générale" msgstr "Crédits de la Société générale" -#: apps/treasury/tables.py:19 +#: apps/treasury/tables.py:20 msgid "Invoice #{:d}" msgstr "Facture n°{:d}" -#: apps/treasury/tables.py:22 templates/treasury/invoice_list.html:10 +#: apps/treasury/tables.py:25 templates/treasury/invoice_list.html:10 #: templates/treasury/remittance_list.html:10 #: templates/treasury/sogecredit_list.html:10 msgid "Invoice" msgstr "Facture" -#: apps/treasury/tables.py:45 +#: apps/treasury/tables.py:65 msgid "Transaction count" msgstr "Nombre de transactions" -#: apps/treasury/tables.py:50 apps/treasury/tables.py:52 +#: apps/treasury/tables.py:70 apps/treasury/tables.py:72 msgid "View" msgstr "Voir" -#: apps/treasury/tables.py:79 +#: apps/treasury/tables.py:99 msgid "Add" msgstr "Ajouter" -#: apps/treasury/tables.py:87 +#: apps/treasury/tables.py:107 msgid "Remove" msgstr "supprimer" -#: apps/treasury/tables.py:126 +#: apps/treasury/tables.py:146 msgid "Yes" msgstr "Oui" -#: apps/treasury/tables.py:126 +#: apps/treasury/tables.py:146 msgid "No" msgstr "Non" @@ -1436,28 +1451,34 @@ msgstr "Liste des factures" msgid "Update an invoice" msgstr "Modifier la facture" -#: apps/treasury/views.py:188 +#: apps/treasury/views.py:145 templates/treasury/invoice_confirm_delete.html:8 +#, fuzzy +#| msgid "New invoice" +msgid "Delete invoice" +msgstr "Nouvelle facture" + +#: apps/treasury/views.py:205 msgid "Create a new remittance" msgstr "Créer une nouvelle remise" -#: apps/treasury/views.py:209 templates/treasury/remittance_form.html:9 +#: apps/treasury/views.py:226 templates/treasury/remittance_form.html:9 #: templates/treasury/specialtransactionproxy_form.html:7 msgid "Remittances list" msgstr "Liste des remises" -#: apps/treasury/views.py:259 +#: apps/treasury/views.py:276 msgid "Update a remittance" msgstr "Modifier la remise" -#: apps/treasury/views.py:282 +#: apps/treasury/views.py:299 msgid "Attach a transaction to a remittance" msgstr "Joindre une transaction à une remise" -#: apps/treasury/views.py:326 +#: apps/treasury/views.py:343 msgid "List of credits from the Société générale" msgstr "Liste des crédits de la Société générale" -#: apps/treasury/views.py:360 +#: apps/treasury/views.py:377 msgid "Manage credits from the Société générale" msgstr "Gérer les crédits de la Société générale" @@ -2469,6 +2490,29 @@ msgstr "" "d'adhésion. Vous devez également valider votre adresse email en suivant le " "lien que vous avez reçu." +#: templates/treasury/invoice_confirm_delete.html:13 +#, fuzzy +#| msgid "This registration is already validated and can't be deleted." +msgid "This invoice is locked and can't be deleted." +msgstr "L'inscription a déjà été validée et ne peut pas être supprimée." + +#: templates/treasury/invoice_confirm_delete.html:19 +#, fuzzy +#| msgid "" +#| "Are you sure you want to delete the registration of %(user)s for the WEI " +#| "%(wei_name)s? This action can't be undone." +msgid "" +"Are you sure you want to delete this invoice? This action can't be undone." +msgstr "" +"Êtes-vous sûr de vouloir supprimer l'inscription de %(user)s pour le WEI " +"%(wei_name)s ? Cette action ne pourra pas être annulée." + +#: templates/treasury/invoice_confirm_delete.html:26 +#, fuzzy +#| msgid "Return to credit list" +msgid "Return to invoices list" +msgstr "Retour à la liste des crédits" + #: templates/treasury/invoice_form.html:10 msgid "" "Warning: the LaTeX template is saved with this object. Updating the invoice " @@ -2478,11 +2522,11 @@ msgstr "" "facture implique la regénérer. Faites attention si vous manipulez de " "vieilles factures." -#: templates/treasury/invoice_form.html:51 +#: templates/treasury/invoice_form.html:58 msgid "Add product" msgstr "Ajouter produit" -#: templates/treasury/invoice_form.html:52 +#: templates/treasury/invoice_form.html:59 msgid "Remove product" msgstr "Retirer produit" diff --git a/templates/treasury/invoice_confirm_delete.html b/templates/treasury/invoice_confirm_delete.html new file mode 100644 index 00000000..1de30e0f --- /dev/null +++ b/templates/treasury/invoice_confirm_delete.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block content %} +
+
+

{% trans "Delete invoice" %}

+
+ {% if object.locked %} +
+
+ {% blocktrans %}This invoice is locked and can't be deleted.{% endblocktrans %} +
+
+ {% else %} +
+
+ {% blocktrans %}Are you sure you want to delete this invoice? This action can't be undone.{% endblocktrans %} +
+
+ {% endif %} + +
+{% endblock %} diff --git a/templates/treasury/invoice_form.html b/templates/treasury/invoice_form.html index 5ad254ca..7ebcdb26 100644 --- a/templates/treasury/invoice_form.html +++ b/templates/treasury/invoice_form.html @@ -5,13 +5,19 @@ {% block content %}

{% trans "Invoices list" %}

- {% if not object.pk %} + {% if object.pk and not object.locked %}
{% blocktrans trimmed %} Warning: the LaTeX template is saved with this object. Updating the invoice implies regenerate it. Be careful if you manipulate old invoices. {% endblocktrans %}
+ {% elif object.locked %} +
+ {% blocktrans trimmed %} + This invoice is locked and can no longer be edited. + {% endblocktrans %} +
{% endif %}
@@ -47,10 +53,12 @@ {# Display buttons to add and remove products #} -
- - -
+ {% if not object.locked %} +
+ + +
+ {% endif %}
@@ -78,21 +86,21 @@ {# Script that handles add and remove lines #} IDS = {}; - $("#id_product_set-TOTAL_FORMS").val($(".row-formset").length - 1); + $("#id_products-TOTAL_FORMS").val($(".row-formset").length - 1); $('#add_more').click(function () { - var form_idx = $('#id_product_set-TOTAL_FORMS').val(); + let form_idx = $('#id_products-TOTAL_FORMS').val(); $('#form_body').append($('#for_real').html().replace(/__prefix__/g, form_idx)); - $('#id_product_set-TOTAL_FORMS').val(parseInt(form_idx) + 1); - $('#id_product_set-' + parseInt(form_idx) + '-id').val(IDS[parseInt(form_idx)]); + $('#id_products-TOTAL_FORMS').val(parseInt(form_idx) + 1); + $('#id_products-' + parseInt(form_idx) + '-id').val(IDS[parseInt(form_idx)]); }); $('#remove_one').click(function () { - let form_idx = $('#id_product_set-TOTAL_FORMS').val(); + let form_idx = $('#id_products-TOTAL_FORMS').val(); if (form_idx > 0) { - IDS[parseInt(form_idx) - 1] = $('#id_product_set-' + (parseInt(form_idx) - 1) + '-id').val(); + IDS[parseInt(form_idx) - 1] = $('#id_products-' + (parseInt(form_idx) - 1) + '-id').val(); $('#form_body tr:last-child').remove(); - $('#id_product_set-TOTAL_FORMS').val(parseInt(form_idx) - 1); + $('#id_products-TOTAL_FORMS').val(parseInt(form_idx) - 1); } });