]> git.parisson.com Git - teleforma.git/commitdiff
update conditions
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 1 Dec 2021 09:43:52 +0000 (10:43 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 1 Dec 2021 09:43:52 +0000 (10:43 +0100)
lib/pdfannotator
teleforma/management/commands/teleforma-copy-students.py

index ce69eca18a6f5b8774215725fd6b42534f13412f..c6b953270e4e8a7d97853d7a784f8e6df9ed9c53 160000 (submodule)
@@ -1 +1 @@
-Subproject commit ce69eca18a6f5b8774215725fd6b42534f13412f
+Subproject commit c6b953270e4e8a7d97853d7a784f8e6df9ed9c53
index 44f2fd0e5ddfd2ee889e50f9471a548f06b6812e..2016fd39e0d26910b3b35f9ca07979e982405826 100644 (file)
@@ -88,23 +88,26 @@ class Command(BaseCommand):
                 date_paid = deepcopy(payment.date_paid)
                 month = deepcopy(payment.month)
                 payments_to = Payment.objects.using(self.db_to).filter(student=student, month=month)
-                if payments_to:
-                    payment_to = payments_to[0]
-                    payment_to.value = payment.value
-                    payment_to.type = payment.type
-                    payment_to.scheduled = payment.scheduled
-                    payment_to.online_paid = payment.online_paid
-                    payement_to.date_paid = payment.date_paid
-                elif date_paid:
+                if date_paid:
                     if date_paid >= self.date_limit:
-                        payment.pk = None
-                        payment.save(using=self.db_to)
-                        payment.student = student
-                        payment.save(using=self.db_to)
-                        self.logger.logger.info('payment added: ' + student.user.username + \
-                         ', date created:' + str(date_created) + \
-                         ', date paid:' + str(date_paid) + \
-                         ', value: ' + str(payment.value))
+                        if payments_to:
+                            payment_to = payments_to[0]
+                            if not payment_to.date_paid:
+                                payment_to.value = payment.value
+                                payment_to.type = payment.type
+                                payment_to.scheduled = payment.scheduled
+                                payment_to.online_paid = payment.online_paid
+                                payement_to.date_paid = payment.date_paid
+                        else:
+                            if date_paid >= self.date_limit:
+                                payment.pk = None
+                                payment.save(using=self.db_to)
+                                payment.student = student
+                                payment.save(using=self.db_to)
+                                self.logger.logger.info('payment added: ' + student.user.username + \
+                                 ', date created:' + str(date_created) + \
+                                 ', date paid:' + str(date_paid) + \
+                                 ', value: ' + str(payment.value))
 
             if new:
                 for discount in discounts: