mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-28 15:42:25 +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'].label = _("Member")
|
||||||
self.fields['user'].empty_label = \
|
self.fields['user'].empty_label = \
|
||||||
_("Select the proprietary member")
|
_("Select the proprietary member")
|
||||||
self.fields['valid'].label = _("Validated invoice")
|
self.fields['validity'].label = _("Validated invoice")
|
||||||
else:
|
else:
|
||||||
self.fields = {'paiement': self.fields['paiement']}
|
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)
|
user = models.ForeignKey('users.User', on_delete=models.PROTECT)
|
||||||
# TODO : change paiement to payment
|
# TODO : change paiement to payment
|
||||||
paiement = models.ForeignKey('Paiement', on_delete=models.PROTECT)
|
paiement = models.ForeignKey('Paiement', on_delete=models.PROTECT)
|
||||||
# TODO : change banque to bank
|
bank = models.ForeignKey(
|
||||||
banque = models.ForeignKey(
|
|
||||||
'Banque',
|
'Banque',
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
# TODO : maybe change to cheque nummber because not evident
|
cheque_number = models.CharField(
|
||||||
cheque = models.CharField(
|
|
||||||
verbose_name=_("cheque number"),
|
verbose_name=_("cheque number"),
|
||||||
max_length=255,
|
max_length=255,
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
# TODO : change name to validity for clarity
|
validity = models.BooleanField(
|
||||||
valid = models.BooleanField(
|
|
||||||
verbose_name=_("validated"),
|
verbose_name=_("validated"),
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
# TODO : changed name to controlled for clarity
|
controlled = models.BooleanField(
|
||||||
control = models.BooleanField(
|
|
||||||
verbose_name=_("controlled"),
|
verbose_name=_("controlled"),
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
@ -176,7 +172,7 @@ class Facture(BaseInvoice):
|
||||||
return False, _("You don't have the right to edit this user's "
|
return False, _("You don't have the right to edit this user's "
|
||||||
"invoices.")
|
"invoices.")
|
||||||
elif not user_request.has_perm('cotisations.change_all_facture') and \
|
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 "
|
return False, _("You don't have the right to edit an invoice "
|
||||||
"already controlled or invalidated.")
|
"already controlled or invalidated.")
|
||||||
else:
|
else:
|
||||||
|
@ -190,7 +186,7 @@ class Facture(BaseInvoice):
|
||||||
return False, _("You don't have the right to delete this user's "
|
return False, _("You don't have the right to delete this user's "
|
||||||
"invoices.")
|
"invoices.")
|
||||||
elif not user_request.has_perm('cotisations.change_all_facture') and \
|
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 "
|
return False, _("You don't have the right to delete an invoice "
|
||||||
"already controlled or invalidated.")
|
"already controlled or invalidated.")
|
||||||
else:
|
else:
|
||||||
|
@ -201,7 +197,7 @@ class Facture(BaseInvoice):
|
||||||
if self.user != user_request:
|
if self.user != user_request:
|
||||||
return False, _("You don't have the right to view someone else's "
|
return False, _("You don't have the right to view someone else's "
|
||||||
"invoices history.")
|
"invoices history.")
|
||||||
elif not self.valid:
|
elif not self.validity:
|
||||||
return False, _("The invoice has been invalidated.")
|
return False, _("The invoice has been invalidated.")
|
||||||
else:
|
else:
|
||||||
return True, None
|
return True, None
|
||||||
|
@ -238,8 +234,8 @@ class Facture(BaseInvoice):
|
||||||
self.field_permissions = {
|
self.field_permissions = {
|
||||||
'control': self.can_change_control,
|
'control': self.can_change_control,
|
||||||
}
|
}
|
||||||
self.__original_valid = self.valid
|
self.__original_valid = self.validity
|
||||||
self.__original_control = self.control
|
self.__original_control = self.controlled
|
||||||
|
|
||||||
def get_subscription(self):
|
def get_subscription(self):
|
||||||
"""Returns every subscription associated with this invoice."""
|
"""Returns every subscription associated with this invoice."""
|
||||||
|
@ -256,11 +252,11 @@ class Facture(BaseInvoice):
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
super(Facture, self).save(*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)
|
send_mail_invoice(self)
|
||||||
if self.is_subscription() \
|
if self.is_subscription() \
|
||||||
and not self.__original_control \
|
and not self.__original_control \
|
||||||
and self.control \
|
and self.controlled \
|
||||||
and CotisationsOption.get_cached_value('send_voucher_mail'):
|
and CotisationsOption.get_cached_value('send_voucher_mail'):
|
||||||
send_mail_voucher(self)
|
send_mail_voucher(self)
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,4 @@ class InvoiceForm(FormRevMixin, forms.ModelForm):
|
||||||
"""A simple form to get the bank a the cheque number."""
|
"""A simple form to get the bank a the cheque number."""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Invoice
|
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."""
|
"""This view validate an invoice with the data from a cheque."""
|
||||||
invoice = get_object_or_404(Invoice, pk=invoice_pk)
|
invoice = get_object_or_404(Invoice, pk=invoice_pk)
|
||||||
payment_method = find_payment_method(invoice.paiement)
|
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(
|
messages.error(
|
||||||
request,
|
request,
|
||||||
_("You can't pay this invoice with a cheque.")
|
_("You can't pay this invoice with a cheque.")
|
||||||
|
|
|
@ -47,7 +47,7 @@ def accept_payment(request, factureid):
|
||||||
accepted.
|
accepted.
|
||||||
"""
|
"""
|
||||||
invoice = get_object_or_404(Facture, id=factureid)
|
invoice = get_object_or_404(Facture, id=factureid)
|
||||||
if invoice.valid:
|
if invoice.validity:
|
||||||
messages.success(
|
messages.success(
|
||||||
request,
|
request,
|
||||||
_("The payment of %(amount)s € was accepted.") % {
|
_("The payment of %(amount)s € was accepted.") % {
|
||||||
|
@ -130,7 +130,7 @@ def ipn(request):
|
||||||
# received the failure information.
|
# received the failure information.
|
||||||
return HttpResponse("HTTP/1.1 200 OK")
|
return HttpResponse("HTTP/1.1 200 OK")
|
||||||
|
|
||||||
facture.valid = True
|
facture.validity = True
|
||||||
facture.save()
|
facture.save()
|
||||||
|
|
||||||
# Everything worked we send a reponse to Comnpay indicating that
|
# Everything worked we send a reponse to Comnpay indicating that
|
||||||
|
|
|
@ -865,7 +865,7 @@ def control(request):
|
||||||
)
|
)
|
||||||
control_invoices_formset = modelformset_factory(
|
control_invoices_formset = modelformset_factory(
|
||||||
Facture,
|
Facture,
|
||||||
fields=('control', 'valid'),
|
fields=('controlled', 'validity'),
|
||||||
extra=0
|
extra=0
|
||||||
)
|
)
|
||||||
invoice_list = re2o_paginator(request, invoice_list, pagination_number)
|
invoice_list = re2o_paginator(request, invoice_list, pagination_number)
|
||||||
|
|
Loading…
Reference in a new issue