]> git.parisson.com Git - teleforma.git/commitdiff
Initial working payment integration
authorGael Le Mignot <gael@pilotsystems.net>
Mon, 1 Mar 2021 10:07:41 +0000 (11:07 +0100)
committerGael Le Mignot <gael@pilotsystems.net>
Mon, 1 Mar 2021 10:07:41 +0000 (11:07 +0100)
teleforma/admin.py
teleforma/management/commands/teleforma-send-payment-emails.py
teleforma/templates/payment/email_initial.txt
teleforma/templates/payment/email_reminder.txt
teleforma/views/crfpa.py
teleforma/views/payment.py

index aa26ce323ace2e02d59b101c77e312f439cd5aa2..2e489b9ef84d46aa91063fddb8d2c0139f96fb4d 100644 (file)
@@ -423,7 +423,7 @@ admin.site.register(Training, TrainingAdmin)
 admin.site.register(CourseType)
 admin.site.register(StreamingServer)
 admin.site.register(LiveStream)
-admin.site.register(Student, StudentAdmin)
+admin.site.register(Student, StudentAdmin)
 # admin.site.register(Corrector, CorrectorAdmin)
 # admin.site.register(Professor, ProfessorAdmin)
 # admin.site.register(StudentGroup, StudentGroupAdmin)
index cc031e86240bf4910a5d5f5e8e25da0f9117a1af..b13c57ef12e49bb3ca5732b29d00c7b2f129f33a 100644 (file)
@@ -38,18 +38,16 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
         log_file = args[-1]
-        period_name = args[-2]
         logger = Logger(log_file)
         logger.logger.info('########### Processing #############')
 
-        period = Period.objects.get(name=period_name)
         students = Student.objects.all()
         translation.activate(self.language_code)
 
         today = datetime.date.today()
         
         for student in students:
-            if student.is_subscribed and student.user.email and student.period == period:
+            if student.is_subscribed and student.user.email:
                 for payment in student.payments.filter(type = 'online').exclude(online_paid = True).filter(scheduled__lte = today):
                     if payment.scheduled == today:
                         self.email(student, 'initial', payment)
index 2aa44539f6c4b020f9fb7ca70ef68432f6cab7fb..981ed99e9e4f96a5b464008f24dd45a3d80861f7 100644 (file)
@@ -1,7 +1,7 @@
 {% url teleforma-payment-start payment.pk as payment_url %}
 Bonjour,
 
-Suite à votre inscription à la formation {{ period }}, une échéance de
+Suite à votre inscription à la formation avocat étranger, une échéance de
 {{ payment.value }} € est arrivée.
 
 Pour effectuer votre paiement, veuillez cliquer sur l’URL suivante :
index 90a3ae12196710591c87e35d33d1d0201fe09b47..571c2d4cf95e28d2e34b81adaed18e88bd4ca948 100644 (file)
@@ -3,7 +3,7 @@ Bonjour,
 
 A ce jour, nous restons dans l’attente de votre échéance de paiement
 de {{ payment.value }} € relative à vos frais d’inscription à notre
-formation {{ period }}.
+formation avocat étranger.
 
 Merci de bien vouloir procéder à votre règlement dans les meilleurs
 délais en cliquant sur l'URL suivante :
index 6bb9c1add7b0b2c4cf577deac9aa052902c0d168..1beae3990b6507047859c3650d0834229b6aa50f 100644 (file)
@@ -645,12 +645,6 @@ class ReceiptPDFView(PDFTemplateResponseMixin, TemplateView):
         context['site'] = Site.objects.get_current()
         
         student = user.student.all()[0]
-
-        if not student.training and student.trainings.all():
-            student.training = student.trainings.all()[0]
-        training = student.training
-        period = training.period
-        student.save()            
         profile = user.profile.all()[0]
 
         context['student'] = student
@@ -666,44 +660,29 @@ class ReceiptPDFView(PDFTemplateResponseMixin, TemplateView):
             student.receipt_id = receipt_id
             student.save()
 
-        period_name = period.name.split()
-        period_name = period_name[0].upper()
+        period = student.period.all()[0]
+        date_begin = period.date_begin or datetime.date.today()
+        date_end = period.date_end or datetime.date.today()
+        period_name = period.name
+        if period_name.startswith('Session '):
+            period_name = period_name[8:]
+        period_name = 'AE_%s' % period_name
         context['receipt_id'] = "%s_%04d_%05d" % (period_name,
-                                                  period.date_begin.year,
+                                                  date_begin.year,
                                                   receipt_id)
         self.receipt_id = context['receipt_id']
 
         # Added items to pay
         items = []
-        if student.application_fees:
-            substract = student.default_application_fees
-            items.append({ 'label': "<b>Frais de dossier</b>",
-                           'unit_price': substract,
-                           'amount': 1,
-                           'discount': None, },)
-        else:
-            substract = 0
+        substract = 0
 
-        label = u"<b>Préparation à l'examen du CRFPA</b><br/>"
-        label += u"<b>%s &mdash; %s</b><br />" % (period, training.name)
-        label += u"<i>%d heures de formation du %s au %s</i>" % (training.duration,
-                                                                period.date_begin.strftime('%d/%m/%Y'),
-                                                                period.date_end.strftime('%d/%m/%Y'),)
+        label = u"<b>Préparation à l'examen d'équivalence au barreau<br/>français - article 100</b><br/>"
+        label += u"<i>130h d’enseignement – 28 simulations du %s<br /> au %s</i>" % (date_begin.strftime('%d/%m/%Y'), date_end.strftime('%d/%m/%Y'),)
 
-        oral_1 = student.oral_1 and student.oral_1.title != 'Aucune'
-        
-        if oral_1:
-            substract += ORAL_OPTION_PRICE            
-        
         items.append({ 'label': label,
                        'unit_price': student.total_fees - substract - student.total_discount,
                        'amount': 1,
                        'discount': student.total_discount, }, )
-        if oral_1:
-            items.append({ 'label': "<b>Option langue</b>",
-                           'unit_price': ORAL_OPTION_PRICE,
-                           'amount': 1,
-                           'discount': 0, }, )
         for item in items:
             item['total'] = item['unit_price'] * item['amount']
             if item['discount']:
@@ -711,7 +690,9 @@ class ReceiptPDFView(PDFTemplateResponseMixin, TemplateView):
 
         # Add payments
         payments = Payment.objects.filter(student = student)
-        receipt_last = receipt_date = student.date_subscribed.date()
+        start = student.date_subscribed
+        start = start and start.date() or datetime.date(1970, 1, 1)
+        receipt_last = receipt_date = start
         for payment in payments:
             date = payment.scheduled or payment.date_modified.date()
             receipt_last = max(date, receipt_last)
index 4559d869572828e10c74d9664ea22f1403ec660c..46ed25affaa19ed4a78bb58116724b52521c9b6e 100644 (file)
@@ -57,9 +57,10 @@ def process_payment(request, payment):
     Process a payment to Sherlocks
     """
     params = dict(settings.PAYMENT_PARAMETERS)
-    period = payment.student.period
-    period_short_name = period.name.split()[0]
-    params['merchant_id'] = params['merchant_id'][period_short_name]
+    if isinstance(params['merchant_id'], dict):
+        period = payment.student.period
+        period_short_name = period.name.split()[0]    
+        params['merchant_id'] = params['merchant_id'][period_short_name]
     merchant_id = params['merchant_id']
     params['amount'] = str(int(payment.value*100))
     params['order_id'] = str(payment.pk)