Browse Source

Merge branch 'payment_delay' of dam35/coin into master

jocelyn 7 years ago
parent
commit
b746cf1059

+ 1 - 0
README.md

@@ -335,6 +335,7 @@ List of available settings in your `settings_local.py` file.
 - `LDAP_ACTIVATE`: See *LDAP*
 - `MEMBER_MEMBERSHIP_INFO_URL`: Link to a page with information on how to become a member or pay the membership fee
 - `SUBSCRIPTION_REFERENCE`: Pattern used to display a unique reference for any subscription. Helpful for bank wire transfer identification
+- `PAYMENT_DELAY`: Payment delay in days for issued invoices ( default is 30 days which is the default in french law)
 
 More information
 ================

+ 20 - 0
coin/billing/migrations/0005_auto_20170608_2213.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import coin.utils
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('billing', '0004_auto_20161230_1803'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='invoice',
+            name='date_due',
+            field=models.DateField(default=coin.utils.end_of_month, help_text='Le d\xe9lai de paiement sera fix\xe9 \xe0 30 jours \xe0 la validation si laiss\xe9 vide', null=True, verbose_name="date d'\xe9ch\xe9ance de paiement", blank=True),
+        ),
+    ]

+ 19 - 0
coin/billing/migrations/0006_auto_20170608_2305.py

@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('billing', '0005_auto_20170608_2213'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='invoice',
+            name='date_due',
+            field=models.DateField(help_text='Le d\xe9lai de paiement sera fix\xe9 \xe0 20 jours \xe0 la validation si laiss\xe9 vide', null=True, verbose_name="date d'\xe9ch\xe9ance de paiement", blank=True),
+        ),
+    ]

+ 8 - 3
coin/billing/models.py

@@ -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):

+ 3 - 0
coin/settings_base.py

@@ -250,6 +250,9 @@ MEMBER_MEMBERSHIP_INFO_URL = ''
 # Helpful for bank wire transfer identification
 SUBSCRIPTION_REFERENCE = 'REF-{subscription.offer.reference}-{subscription.pk}'
 
+# Payment delay in days
+PAYMENT_DELAY = 30
+
 # Reset session if cookie older than 2h.
 SESSION_COOKIE_AGE = 7200