mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +00:00
Rename fields of cotisation.Facture
This commit is contained in:
parent
c4d6c6abdd
commit
26a5c6cfb3
7 changed files with 52 additions and 21 deletions
|
@ -68,7 +68,7 @@ class FactureForm(FieldPermissionFormMixin, FormRevMixin, ModelForm):
|
|||
self.fields['user'].label = _("Member")
|
||||
self.fields['user'].empty_label = \
|
||||
_("Select the proprietary member")
|
||||
self.fields['valid'].label = _("Validated invoice")
|
||||
self.fields['validity'].label = _("Validated invoice")
|
||||
else:
|
||||
self.fields = {'paiement': self.fields['paiement']}
|
||||
|
||||
|
|
35
cotisations/migrations/0040_auto_20190325_0832.py
Normal file
35
cotisations/migrations/0040_auto_20190325_0832.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2019-03-25 07:32
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cotisations', '0039_auto_20190321_1626'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='facture',
|
||||
old_name='banque',
|
||||
new_name='bank',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='facture',
|
||||
old_name='cheque',
|
||||
new_name='cheque_number',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='facture',
|
||||
old_name='control',
|
||||
new_name='controlled',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='facture',
|
||||
old_name='valid',
|
||||
new_name='validity',
|
||||
),
|
||||
]
|
|
@ -125,26 +125,22 @@ class Facture(BaseInvoice):
|
|||
user = models.ForeignKey('users.User', on_delete=models.PROTECT)
|
||||
# TODO : change paiement to payment
|
||||
paiement = models.ForeignKey('Paiement', on_delete=models.PROTECT)
|
||||
# TODO : change banque to bank
|
||||
banque = models.ForeignKey(
|
||||
bank = models.ForeignKey(
|
||||
'Banque',
|
||||
on_delete=models.PROTECT,
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
# TODO : maybe change to cheque nummber because not evident
|
||||
cheque = models.CharField(
|
||||
cheque_number = models.CharField(
|
||||
verbose_name=_("cheque number"),
|
||||
max_length=255,
|
||||
blank=True,
|
||||
)
|
||||
# TODO : change name to validity for clarity
|
||||
valid = models.BooleanField(
|
||||
validity = models.BooleanField(
|
||||
verbose_name=_("validated"),
|
||||
default=False,
|
||||
)
|
||||
# TODO : changed name to controlled for clarity
|
||||
control = models.BooleanField(
|
||||
controlled = models.BooleanField(
|
||||
verbose_name=_("controlled"),
|
||||
default=False,
|
||||
)
|
||||
|
@ -176,7 +172,7 @@ class Facture(BaseInvoice):
|
|||
return False, _("You don't have the right to edit this user's "
|
||||
"invoices.")
|
||||
elif not user_request.has_perm('cotisations.change_all_facture') and \
|
||||
(self.control or not self.valid):
|
||||
(self.controlled or not self.validity):
|
||||
return False, _("You don't have the right to edit an invoice "
|
||||
"already controlled or invalidated.")
|
||||
else:
|
||||
|
@ -190,7 +186,7 @@ class Facture(BaseInvoice):
|
|||
return False, _("You don't have the right to delete this user's "
|
||||
"invoices.")
|
||||
elif not user_request.has_perm('cotisations.change_all_facture') and \
|
||||
(self.control or not self.valid):
|
||||
(self.controlled or not self.validity):
|
||||
return False, _("You don't have the right to delete an invoice "
|
||||
"already controlled or invalidated.")
|
||||
else:
|
||||
|
@ -201,7 +197,7 @@ class Facture(BaseInvoice):
|
|||
if self.user != user_request:
|
||||
return False, _("You don't have the right to view someone else's "
|
||||
"invoices history.")
|
||||
elif not self.valid:
|
||||
elif not self.validity:
|
||||
return False, _("The invoice has been invalidated.")
|
||||
else:
|
||||
return True, None
|
||||
|
@ -238,8 +234,8 @@ class Facture(BaseInvoice):
|
|||
self.field_permissions = {
|
||||
'control': self.can_change_control,
|
||||
}
|
||||
self.__original_valid = self.valid
|
||||
self.__original_control = self.control
|
||||
self.__original_valid = self.validity
|
||||
self.__original_control = self.controlled
|
||||
|
||||
def get_subscription(self):
|
||||
"""Returns every subscription associated with this invoice."""
|
||||
|
@ -256,11 +252,11 @@ class Facture(BaseInvoice):
|
|||
|
||||
def save(self, *args, **kwargs):
|
||||
super(Facture, self).save(*args, **kwargs)
|
||||
if not self.__original_valid and self.valid:
|
||||
if not self.__original_valid and self.validity:
|
||||
send_mail_invoice(self)
|
||||
if self.is_subscription() \
|
||||
and not self.__original_control \
|
||||
and self.control \
|
||||
and self.controlled \
|
||||
and CotisationsOption.get_cached_value('send_voucher_mail'):
|
||||
send_mail_voucher(self)
|
||||
|
||||
|
|
|
@ -28,4 +28,4 @@ class InvoiceForm(FormRevMixin, forms.ModelForm):
|
|||
"""A simple form to get the bank a the cheque number."""
|
||||
class Meta:
|
||||
model = Invoice
|
||||
fields = ['banque', 'cheque']
|
||||
fields = ['bank', 'cheque_number']
|
||||
|
|
|
@ -41,7 +41,7 @@ def cheque(request, invoice_pk):
|
|||
"""This view validate an invoice with the data from a cheque."""
|
||||
invoice = get_object_or_404(Invoice, pk=invoice_pk)
|
||||
payment_method = find_payment_method(invoice.paiement)
|
||||
if invoice.valid or not isinstance(payment_method, ChequePayment):
|
||||
if invoice.validity or not isinstance(payment_method, ChequePayment):
|
||||
messages.error(
|
||||
request,
|
||||
_("You can't pay this invoice with a cheque.")
|
||||
|
|
|
@ -47,7 +47,7 @@ def accept_payment(request, factureid):
|
|||
accepted.
|
||||
"""
|
||||
invoice = get_object_or_404(Facture, id=factureid)
|
||||
if invoice.valid:
|
||||
if invoice.validity:
|
||||
messages.success(
|
||||
request,
|
||||
_("The payment of %(amount)s € was accepted.") % {
|
||||
|
@ -130,7 +130,7 @@ def ipn(request):
|
|||
# received the failure information.
|
||||
return HttpResponse("HTTP/1.1 200 OK")
|
||||
|
||||
facture.valid = True
|
||||
facture.validity = True
|
||||
facture.save()
|
||||
|
||||
# Everything worked we send a reponse to Comnpay indicating that
|
||||
|
|
|
@ -865,7 +865,7 @@ def control(request):
|
|||
)
|
||||
control_invoices_formset = modelformset_factory(
|
||||
Facture,
|
||||
fields=('control', 'valid'),
|
||||
fields=('controlled', 'validity'),
|
||||
extra=0
|
||||
)
|
||||
invoice_list = re2o_paginator(request, invoice_list, pagination_number)
|
||||
|
|
Loading…
Reference in a new issue