Changeset 16309 for main


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
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/interfaces.py

    r15571 r16309  
    406406        )
    407407
     408    gns_1_fee = schema.Float(
     409        title = _(u'GNS Pack I'),
     410        default = 0.0,
     411        required = True,
     412        )
     413
     414    gns_2_fee = schema.Float(
     415        title = _(u'GNS Pack II'),
     416        default = 0.0,
     417        required = True,
     418        )
     419
    408420    bfn_fee = schema.Float(
    409421        title = _(u'BFN Pack'),
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/browser.py

    r16026 r16309  
    186186            xmldict['institution_acct'] = '2015327204'
    187187            xmldict['institution_bank_id'] = '8'
     188        elif self.context.p_category == 'gns_1':
     189            self.pay_item_id = '154'
     190            xmldict['institution_acct'] = '2017447652'
     191            xmldict['institution_bank_id'] = '8'
     192        elif self.context.p_category == 'gns_2':
     193            self.pay_item_id = '155'
     194            xmldict['institution_acct'] = '2017447652'
     195            xmldict['institution_bank_id'] = '8'
    188196        elif self.context.p_category == 'hostel_maintenance':
    189197            if self.context.p_item != 'Balance':
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/tests.py

    r16308 r16309  
    6767        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    6868        self.browser.getControl("Create ticket").click()
    69         self.assertTrue('You have to pay NADESU/SA/SUG Dues first'
     69        self.assertTrue('You have to pay NADESU/SA/SUG and GNS Dues first'
    7070            in self.browser.contents)
    7171        payment = createObject('waeup.StudentOnlinePayment')
     
    7575        payment.p_state = u'paid'
    7676        self.student['payments']['anykey'] = payment
     77        payment2 = createObject('waeup.StudentOnlinePayment')
     78        payment2.p_category = u'gns_1'
     79        payment2.p_session = self.student.current_session
     80        payment2.p_id = u'anyid2'
     81        payment2.p_state = u'paid'
     82        self.student['payments']['anykey2'] = payment2
    7783        self.browser.open(self.payments_path + '/addop')
    7884        self.browser.getControl(name="form.p_category").value = ['schoolfee']
  • 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'
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/utils/utils.py

    r15691 r16309  
    116116        'sbs_1':'SBS Pack I',
    117117        'sbs_2':'SBS Pack II',
     118        'gns_1':'GNS Pack I',
     119        'gns_2':'GNS Pack II',
    118120        'bfn':'BFN Pack',
    119121        'mkt':'MKT Pack',
     
    184186        'sbs_1':'SBS Pack I',
    185187        'sbs_2':'SBS Pack II',
     188        'gns_1':'GNS Pack I',
     189        'gns_2':'GNS Pack II',
    186190        'bfn':'BFN Pack',
    187191        'mkt':'MKT Pack',
Note: See TracChangeset for help on using the changeset viewer.