]> git.parisson.com Git - teleforma.git/commitdiff
add conditions
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Wed, 1 Dec 2021 09:39:59 +0000 (10:39 +0100)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Wed, 1 Dec 2021 09:39:59 +0000 (10:39 +0100)
teleforma/management/commands/teleforma-copy-students.py

index 2b9fa9c2ae30849301524927cb8c06455fcf63df..44f2fd0e5ddfd2ee889e50f9471a548f06b6812e 100644 (file)
@@ -86,7 +86,16 @@ class Command(BaseCommand):
             for payment in payments:
                 date_created = deepcopy(payment.date_modified)
                 date_paid = deepcopy(payment.date_paid)
-                if 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 >= self.date_limit:
                         payment.pk = None
                         payment.save(using=self.db_to)