Ignore:
Timestamp:
10 Nov 2020, 14:33:53 (4 years ago)
Author:
Henrik Bettermann
Message:

Implement GNS Pack payments. This is a good example how sophisticated such requirements are.

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

Legend:

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

    r15360 r16309  
    8888        self.assertEqual(payment.p_session, 2005)
    8989        self.assertEqual(payment.amount_auth, 3150.0)
    90         # Students can pay school fee if dep_sug has been paid first.
     90        # Students can pay school fee if dep_sug and gns dues have been paid first.
    9191        error, payment = utils.setPaymentDetails('schoolfee',self.student)
    92         self.assertEqual(error, u'You have to pay NADESU/SA/SUG Dues first.')
     92        self.assertEqual(error, u'You have to pay NADESU/SA/SUG and GNS Dues first.')
    9393        error, payment = utils.setPaymentDetails('dep_sug',self.student)
    9494        self.student['payments']['any_key'] = payment
    9595        error, payment = utils.setPaymentDetails('schoolfee',self.student)
    96         self.assertEqual(error, u'You have to pay NADESU/SA/SUG Dues first.')
     96        self.assertEqual(error, u'You have to pay NADESU/SA/SUG and GNS Dues first.')
     97
     98        configuration.gns_1_fee = 1150.0
     99        error, payment2 = utils.setPaymentDetails('gns_1',self.student)
     100        self.student['payments']['any_key2'] = payment2
     101        self.assertEqual(payment2.p_level, 200)
     102        self.assertEqual(payment2.p_session, 2005)
     103        self.assertEqual(payment2.amount_auth, 1150.0)
     104        error, payment = utils.setPaymentDetails('schoolfee',self.student)
     105
    97106        self.student['payments']['any_key'].p_state = 'paid'
     107        self.student['payments']['any_key2'].p_state = 'paid'
    98108        error, payment = utils.setPaymentDetails('schoolfee',self.student)
    99109        self.assertEqual(error, None)
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/utils.py

    r16155 r16309  
    3838    STUDENT_ID_PREFIX = u'P'
    3939
    40     def _dep_sug_paymentMade(self, student, session):
     40    def _dep_sug_gns_paymentMade(self, student, session):
    4141        if student.state == RETURNING:
    4242            session += 1
     43        dep_sug = False
     44        gns = False
    4345        if len(student['payments']):
    4446            for ticket in student['payments'].values():
     
    4648                    ticket.p_category == 'dep_sug' and \
    4749                    ticket.p_session == session:
     50                    dep_sug = True
     51                if ticket.p_state == 'paid' and \
     52                    ticket.p_category.startswith('gns') and \
     53                    ticket.p_session == session:
     54                    gns = True
     55                if dep_sug and gns:
    4856                    return True
    4957        return False
     
    163171            else:
    164172                # Students are only allowed to pay school fee
    165                 # if current session dep_sug payment has been made.
    166                 if student.faccode != 'SPAT' and not self._dep_sug_paymentMade(
     173                # if current session dep_sug_gns payment has been made.
     174                if student.faccode != 'SPAT' and not self._dep_sug_gns_paymentMade(
    167175                    student, student.current_session):
    168                     return _('You have to pay NADESU/SA/SUG Dues first.'), None
     176                    return _('You have to pay NADESU/SA/SUG and GNS Dues first.'), None
    169177                penalty = getattr(academic_session, 'lsfp_penalty_fee')
    170178                if  penalty and not self._lsfp_penalty_paymentMade(
     
    257265            if student.state == RETURNING and not previous_session:
    258266                p_session, p_level = self.getReturningData(student)
     267        elif category.startswith('gns'):
     268            if student.state == RETURNING and not previous_session:
     269                p_session, p_level = self.getReturningData(student)
     270                fee_name = category + '_fee'
     271                academic_session = self._getSessionConfiguration(p_session)
     272                amount = getattr(academic_session, fee_name, 0.0)
    259273        else:
    260274            fee_name = category + '_fee'
Note: See TracChangeset for help on using the changeset viewer.