|
@@ -8,11 +8,13 @@ import os
|
|
|
import re
|
|
|
from decimal import Decimal
|
|
|
|
|
|
+from django.conf import settings
|
|
|
from django.db import models, transaction
|
|
|
from django.db.models.signals import post_save
|
|
|
from django.dispatch import receiver
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
|
|
|
|
+
|
|
|
from coin.offers.models import OfferSubscription
|
|
|
from coin.members.models import Member
|
|
|
from coin.html2pdf import render_as_pdf
|
|
@@ -125,9 +127,9 @@ class Invoice(models.Model):
|
|
|
default=datetime.date.today, null=True, verbose_name='date',
|
|
|
help_text='Cette date sera définie à la date de validation dans la facture finale')
|
|
|
date_due = models.DateField(
|
|
|
- default=end_of_month,
|
|
|
- null=True,
|
|
|
- verbose_name="date d'échéance de paiement")
|
|
|
+ null=True, blank=True,
|
|
|
+ verbose_name="date d'échéance de paiement",
|
|
|
+ help_text='Le délai de paiement sera fixé à {} jours à la validation si laissé vide'.format(settings.PAYMENT_DELAY))
|
|
|
member = models.ForeignKey(Member, null=True, blank=True, default=None,
|
|
|
related_name='invoices',
|
|
|
verbose_name='membre',
|
|
@@ -203,10 +205,13 @@ class Invoice(models.Model):
|
|
|
and generate the pdf
|
|
|
"""
|
|
|
self.date = datetime.date.today()
|
|
|
+ if not self.date_due:
|
|
|
+ self.date_due = self.date + datetime.timedelta(days=settings.PAYMENT_DELAY)
|
|
|
self.number = Invoice.objects.get_next_invoice_number(self.date)
|
|
|
self.validated = True
|
|
|
self.save()
|
|
|
self.generate_pdf()
|
|
|
+
|
|
|
assert self.pdf_exists()
|
|
|
|
|
|
def pdf_exists(self):
|