Ignore:
Timestamp:
22 Mar 2019, 11:07:57 (6 years ago)
Author:
Henrik Bettermann
Message:

Student must pay school fee only in states cleared and returning.

Location:
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/tests/test_utils.py

    r15344 r15361  
    5858        self.assertEqual(msg, None)
    5959        return
     60
     61    def test_set_payment_details(self):
     62        self.student['studycourse'].certificate.school_fee_1 = 6666.0
     63        self.student['studycourse'].certificate.study_mode = 'nd_pt'
     64        IWorkflowState(self.student).setState('returning')
     65        #self.student.nationality = u'NG'
     66        #self.student.lga = 'ebonyi_ukaba'
     67        utils = getUtility(IStudentsUtils)
     68        configuration = createObject('waeup.SessionConfiguration')
     69        configuration.academic_session = 2005
     70        self.app['configuration'].addSessionConfiguration(configuration)
     71        self.app['configuration']['2004'].ict_entre_fee = 170.0
     72        self.app['configuration']['2005'].ict_entre_fee = 180.0
     73        error, payment = utils.setPaymentDetails('schoolfee',self.student)
     74        self.assertEqual(error, u'Pay ICT fee(s) first.')
     75        error, payment = utils.setPaymentDetails('ict_entre',self.student)
     76        self.assertEqual(error, None)
     77        self.assertEqual(payment.p_level, 200)
     78        self.assertEqual(payment.p_session, 2005)
     79        self.assertEqual(payment.amount_auth, 180.0)
     80        payment.p_state = 'paid'
     81        self.student['payments']['any_key'] = payment
     82        error, payment = utils.setPaymentDetails('schoolfee',self.student)
     83        self.assertEqual(error, None)
     84        self.assertEqual(payment.p_level, 200)
     85        self.assertEqual(payment.p_session, 2005)
     86        self.assertEqual(payment.amount_auth, 6666.0)
     87
     88        IWorkflowState(self.student).setState('cleared')
     89        error, payment = utils.setPaymentDetails('ict_entre',self.student)
     90        self.assertEqual(error, None)
     91        self.assertEqual(payment.p_level, 100)
     92        self.assertEqual(payment.p_session, 2004)
     93        self.assertEqual(payment.amount_auth, 170.0)
     94        payment.p_state = 'paid'
     95        self.student['payments']['any_key_2'] = payment
     96        error, payment = utils.setPaymentDetails('schoolfee',self.student)
     97        self.assertEqual(error, None)
     98        self.assertEqual(payment.p_level, 100)
     99        self.assertEqual(payment.p_session, 2004)
     100        self.assertEqual(payment.amount_auth, 6666.0)
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/utils.py

    r15344 r15361  
    9292        req_payments = ('ict_entre', 'logbook_combo')
    9393        req_payments_titles = 'ICT and Logbook'
     94        # All ND and HND part time do not pay for LOGBOOK
     95        if student.current_mode.endswith('_pt'):
     96            req_payments = ('ict_entre',)
     97            req_payments_titles = 'ICT'
     98        # HND1 and HND2 full time do not pay for LOGBOOK
     99        elif student.current_mode == 'hnd_ft' and student.state in (
     100            CLEARED, RETURNING):
     101            req_payments = ('ict_entre',)
     102            req_payments_titles = 'ICT'
     103        # ND2 FULL TIME do not pay LOGBOOK
     104        elif student.current_mode == 'nd_ft' and student.state == RETURNING:
     105            req_payments = ('ict_entre',)
     106            req_payments_titles = 'ICT'
     107        num = 0
    94108        if len(student['payments']):
    95             # All ND and HND part time do not pay for LOGBOOK
    96             if student.current_mode.endswith('_pt'):
    97                 req_payments = ('ict_entre',)
    98                 req_payments_titles = 'ICT'
    99             # HND1 and HND2 full time do not pay for LOGBOOK
    100             elif student.current_mode == 'hnd_ft' and student.state in (
    101                 CLEARED, RETURNING):
    102                 req_payments = ('ict_entre',)
    103                 req_payments_titles = 'ICT'
    104             # ND2 FULL TIME do not pay LOGBOOK
    105             elif student.current_mode == 'nd_ft' and student.state == RETURNING:
    106                 req_payments = ('ict_entre',)
    107                 req_payments_titles = 'ICT'
    108             num = 0
    109109            for ticket in student['payments'].values():
    110110                if ticket.p_state == 'paid' and \
     
    117117
    118118    def setPaymentDetails(self, category, student,
    119             previous_session, previous_level):
     119            previous_session=None, previous_level=None):
    120120        """Create a payment ticket and set the payment data of a
    121121        student for the payment category specified.
     
    141141            p_level = student['studycourse'].current_level
    142142            p_current = True
     143        # The following three fees are part of the school fee which must be
     144        # paid before tuition fee. They are paid for next session.
     145        if category in ('ict_entre', 'logbook_combo', 'siwess_combo') and \
     146            student.state == RETURNING and not previous_session:
     147            p_session, p_level = self.getReturningData(student)
    143148        academic_session = self._getSessionConfiguration(p_session)
    144149        if academic_session == None:
    145150            return _(u'Session configuration object is not available.'), None
    146151        # Determine fee.
    147         # The following three fees are part of the school fee which must be
    148         # paid before tuition fee.
    149         if category in ('ict_entre', 'logbook_combo', 'siwess_combo') and \
    150             student.state == RETURNING and not previous_session:
    151             p_session, p_level = self.getReturningData(student)
    152152        if category == 'schoolfee':
    153153            try:
     
    159159                amount = getattr(certificate, 'school_fee_1', 0.0)
    160160            else:
    161                 amount = getattr(certificate, 'school_fee_1', 0.0)
    162                 if student.state == RETURNING:
     161                if student.state == CLEARED:
     162                    amount = getattr(certificate, 'school_fee_1', 0.0)
     163                elif student.state == RETURNING:
     164                    amount = getattr(certificate, 'school_fee_1', 0.0)
    163165                    # In case of returning school fee payment the
    164166                    # payment session and level contain the values of
     
    171173                            u'Session configuration object is not available.'
    172174                            ), None
    173                    
    174175                elif student.is_postgrad and student.state == PAID:
    175176                    # Returning postgraduate students also pay for the
    176177                    # next session but their level always remains the
    177178                    # same.
     179                    amount = getattr(certificate, 'school_fee_1', 0.0)
    178180                    p_session += 1
    179181                    academic_session = self._getSessionConfiguration(p_session)
Note: See TracChangeset for help on using the changeset viewer.