Changeset 17606 for main


Ignore:
Timestamp:
10 Oct 2023, 16:52:33 (15 months ago)
Author:
Henrik Bettermann
Message:

Define setCDLPaymentDetails.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r17603 r17606  
    274274        return False
    275275
     276    def setCDLPaymentDetails(self, category, student,
     277            previous_session, previous_level, combi):
     278        """Create Payment object and set the payment data of a CDL student for
     279        the payment category specified.
     280        """
     281        p_item = u''
     282        amount = 0.0
     283        if previous_session:
     284            if previous_session < student['studycourse'].entry_session:
     285                return _('The previous session must not fall below '
     286                         'your entry session.'), None
     287            if category == 'schoolfee':
     288                # School fee is always paid for the following session
     289                if previous_session > student['studycourse'].current_session:
     290                    return _('This is not a previous session.'), None
     291            else:
     292                if previous_session > student['studycourse'].current_session - 1:
     293                    return _('This is not a previous session.'), None
     294            p_session = previous_session
     295            p_level = previous_level
     296            p_current = False
     297        else:
     298            p_session = student['studycourse'].current_session
     299            p_level = student['studycourse'].current_level
     300            p_current = True
     301        academic_session = self._getSessionConfiguration(p_session)
     302        if academic_session == None:
     303            return _(u'Session configuration object is not available.'), None
     304        # Determine fee.
     305        if category == 'schoolfee':
     306            try:
     307                certificate = student['studycourse'].certificate
     308                p_item = certificate.code
     309            except (AttributeError, TypeError):
     310                return _('Study course data are incomplete.'), None
     311            if previous_session:
     312                # Students can pay for previous sessions in all
     313                # workflow states.  Fresh students are excluded by the
     314                # update method of the PreviousPaymentAddFormPage.
     315                if previous_level == 100:
     316                    amount = getattr(certificate, 'school_fee_1', 0.0)
     317                else:
     318                    amount = getattr(certificate, 'school_fee_2', 0.0)
     319            else:
     320                if student.state == CLEARED:
     321                    amount = getattr(certificate, 'school_fee_1', 0.0)
     322                elif student.state == RETURNING:
     323                    # In case of returning school fee payment the
     324                    # payment session and level contain the values of
     325                    # the session the student has paid for. Payment
     326                    # session is always next session.
     327                    p_session, p_level = self.getReturningData(student)
     328                    academic_session = self._getSessionConfiguration(p_session)
     329                    if academic_session == None:
     330                        return _(
     331                            u'Session configuration object is not available.'
     332                            ), None
     333                    amount = getattr(certificate, 'school_fee_2', 0.0)
     334                elif student.is_postgrad and student.state == PAID:
     335                    # Returning postgraduate students also pay for the
     336                    # next session but their level always remains the
     337                    # same.
     338                    p_session += 1
     339                    academic_session = self._getSessionConfiguration(p_session)
     340                    if academic_session == None:
     341                        return _(
     342                            u'Session configuration object is not available.'
     343                            ), None
     344                    amount = getattr(certificate, 'school_fee_2', 0.0)
     345        elif category == 'clearance':
     346            try:
     347                p_item = student['studycourse'].certificate.code
     348            except (AttributeError, TypeError):
     349                return _('Study course data are incomplete.'), None
     350            amount = academic_session.clearance_fee
     351        elif category == 'combi' and combi:
     352            categories = getUtility(IKofaUtils).COMBI_PAYMENT_CATEGORIES
     353            for cat in combi:
     354                fee_name = cat + '_fee'
     355                cat_amount = getattr(academic_session, fee_name, 0.0)
     356                if not cat_amount:
     357                    return _('%s undefined.' % categories[cat]), None
     358                amount += cat_amount
     359                p_item += u'%s + ' % categories[cat]
     360            p_item = p_item.strip(' + ')
     361        else:
     362            fee_name = category + '_fee'
     363            amount = getattr(academic_session, fee_name, 0.0)
     364        if amount in (0.0, None):
     365            return _('Amount could not be determined.'), None
     366        if self.samePaymentMade(student, category, p_item, p_session):
     367            return _('This type of payment has already been made.'), None
     368        if self._isPaymentDisabled(p_session, category, student):
     369            return _('This category of payments has been disabled.'), None
     370        payment = createObject(u'waeup.StudentOnlinePayment')
     371        timestamp = ("%d" % int(time()*10000))[1:]
     372        payment.p_id = "p%s" % timestamp
     373        payment.p_category = category
     374        payment.p_item = p_item
     375        payment.p_session = p_session
     376        payment.p_level = p_level
     377        payment.p_current = p_current
     378        payment.amount_auth = amount
     379        payment.p_combi = combi
     380        return None, payment
     381
     382
    276383    def setPaymentDetails(self, category, student,
    277384            previous_session, previous_level, combi):
     
    280387
    281388        """
     389        if grok.getSite().__name__ == 'uniben-cdl':
     390            return self.setCDLPaymentDetails(category, student,
     391                previous_session, previous_level, combi)
    282392        p_item = u''
    283393        amount = 0.0
     
    356466            if p_item is None:
    357467                return _('Study course data are incomplete.'), None
    358             if grok.getSite().__name__ == 'uniben-cdl':
    359                 amount = 65000.0
    360             elif student.is_jupeb:
     468            if student.is_jupeb:
    361469                amount = 50000.0
    362470            elif student.faccode.startswith('FCETA'):
Note: See TracChangeset for help on using the changeset viewer.