Index: /main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
===================================================================
--- /main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 17605)
+++ /main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 17606)
@@ -274,4 +274,111 @@
         return False
 
+    def setCDLPaymentDetails(self, category, student,
+            previous_session, previous_level, combi):
+        """Create Payment object and set the payment data of a CDL student for
+        the payment category specified.
+        """
+        p_item = u''
+        amount = 0.0
+        if previous_session:
+            if previous_session < student['studycourse'].entry_session:
+                return _('The previous session must not fall below '
+                         'your entry session.'), None
+            if category == 'schoolfee':
+                # School fee is always paid for the following session
+                if previous_session > student['studycourse'].current_session:
+                    return _('This is not a previous session.'), None
+            else:
+                if previous_session > student['studycourse'].current_session - 1:
+                    return _('This is not a previous session.'), None
+            p_session = previous_session
+            p_level = previous_level
+            p_current = False
+        else:
+            p_session = student['studycourse'].current_session
+            p_level = student['studycourse'].current_level
+            p_current = True
+        academic_session = self._getSessionConfiguration(p_session)
+        if academic_session == None:
+            return _(u'Session configuration object is not available.'), None
+        # Determine fee.
+        if category == 'schoolfee':
+            try:
+                certificate = student['studycourse'].certificate
+                p_item = certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
+            if previous_session:
+                # Students can pay for previous sessions in all
+                # workflow states.  Fresh students are excluded by the
+                # update method of the PreviousPaymentAddFormPage.
+                if previous_level == 100:
+                    amount = getattr(certificate, 'school_fee_1', 0.0)
+                else:
+                    amount = getattr(certificate, 'school_fee_2', 0.0)
+            else:
+                if student.state == CLEARED:
+                    amount = getattr(certificate, 'school_fee_1', 0.0)
+                elif student.state == RETURNING:
+                    # In case of returning school fee payment the
+                    # payment session and level contain the values of
+                    # the session the student has paid for. Payment
+                    # session is always next session.
+                    p_session, p_level = self.getReturningData(student)
+                    academic_session = self._getSessionConfiguration(p_session)
+                    if academic_session == None:
+                        return _(
+                            u'Session configuration object is not available.'
+                            ), None
+                    amount = getattr(certificate, 'school_fee_2', 0.0)
+                elif student.is_postgrad and student.state == PAID:
+                    # Returning postgraduate students also pay for the
+                    # next session but their level always remains the
+                    # same.
+                    p_session += 1
+                    academic_session = self._getSessionConfiguration(p_session)
+                    if academic_session == None:
+                        return _(
+                            u'Session configuration object is not available.'
+                            ), None
+                    amount = getattr(certificate, 'school_fee_2', 0.0)
+        elif category == 'clearance':
+            try:
+                p_item = student['studycourse'].certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
+            amount = academic_session.clearance_fee
+        elif category == 'combi' and combi:
+            categories = getUtility(IKofaUtils).COMBI_PAYMENT_CATEGORIES
+            for cat in combi:
+                fee_name = cat + '_fee'
+                cat_amount = getattr(academic_session, fee_name, 0.0)
+                if not cat_amount:
+                    return _('%s undefined.' % categories[cat]), None
+                amount += cat_amount
+                p_item += u'%s + ' % categories[cat]
+            p_item = p_item.strip(' + ')
+        else:
+            fee_name = category + '_fee'
+            amount = getattr(academic_session, fee_name, 0.0)
+        if amount in (0.0, None):
+            return _('Amount could not be determined.'), None
+        if self.samePaymentMade(student, category, p_item, p_session):
+            return _('This type of payment has already been made.'), None
+        if self._isPaymentDisabled(p_session, category, student):
+            return _('This category of payments has been disabled.'), None
+        payment = createObject(u'waeup.StudentOnlinePayment')
+        timestamp = ("%d" % int(time()*10000))[1:]
+        payment.p_id = "p%s" % timestamp
+        payment.p_category = category
+        payment.p_item = p_item
+        payment.p_session = p_session
+        payment.p_level = p_level
+        payment.p_current = p_current
+        payment.amount_auth = amount
+        payment.p_combi = combi
+        return None, payment
+
+
     def setPaymentDetails(self, category, student,
             previous_session, previous_level, combi):
@@ -280,4 +387,7 @@
 
         """
+        if grok.getSite().__name__ == 'uniben-cdl':
+            return self.setCDLPaymentDetails(category, student,
+                previous_session, previous_level, combi)
         p_item = u''
         amount = 0.0
@@ -356,7 +466,5 @@
             if p_item is None:
                 return _('Study course data are incomplete.'), None
-            if grok.getSite().__name__ == 'uniben-cdl':
-                amount = 65000.0
-            elif student.is_jupeb:
+            if student.is_jupeb:
                 amount = 50000.0
             elif student.faccode.startswith('FCETA'):
