From bda58d3b2ecf3e2d2a724b77278d371e615e1cd9 Mon Sep 17 00:00:00 2001 From: Gael Le Mignot Date: Mon, 25 Oct 2021 14:08:04 +0200 Subject: [PATCH] Generating oral option payment even if paying in one time --- teleforma/models/crfpa.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index 5efb7938..3071e985 100755 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -320,7 +320,6 @@ class Student(models.Model): month -= 12 return datetime.date(year, month, 1) - oneday - oral_date = None payments = None # Full or partial ? if self.payment_schedule == 'split': @@ -333,7 +332,6 @@ class Student(models.Model): for i in range(3): date = endofmonth(tomorrow.year, tomorrow.month + 1 + i) payments += ((part, date),) - oral_date = endofmonth(tomorrow.year, 6) else: # Normal registration, so first three months of next year for month in (1, 2, 3): @@ -341,7 +339,6 @@ class Student(models.Model): # look at 01/m+1 and then remove one day date = endofmonth(tomorrow.year + 1, month) payments += ((part, date),) - oral_date = endofmonth(tomorrow.year + 1, 6) elif period.name == 'Estivale': part = int(total * 0.35) remaining = total - 2 * part @@ -353,7 +350,6 @@ class Student(models.Model): # look at 01/m+1 and then remove one day date = endofmonth(tomorrow.year, tomorrow.month + 1 + i) payments += ((part, date),) - oral_date = endofmonth(tomorrow.year, max(tomorrow.month, 8)) else: # Normal registration, so end of june and end of # july @@ -362,10 +358,26 @@ class Student(models.Model): # look at 01/m+1 and then remove one day date = endofmonth(tomorrow.year, month) payments += ((part, date),) - oral_date = endofmonth(tomorrow.year, 8) elif self.payment_schedule == 'once': payments = ((total, tomorrow), ) + # Handle oral date + oral_date = None + if period.name in ('Semestrielle', 'Annuelle'): + if tomorrow.month <= 6: + # Late registration + oral_date = endofmonth(tomorrow.year, 6) + else: + # Normal registration + oral_date = endofmonth(tomorrow.year + 1, 6) + elif period.name == 'Estivale': + if tomorrow.month >= 6: + # Late registration + oral_date = endofmonth(tomorrow.year, max(tomorrow.month, 8)) + else: + # Normal registration + oral_date = endofmonth(tomorrow.year, 8) + if not payments: return -- 2.39.5