Ignore:
Timestamp:
16 Jan 2018, 15:06:52 (7 years ago)
Author:
Henrik Bettermann
Message:

Configure dep_sug payments which are required for schoolfee payments.

Location:
main/kofacustom.dspg/trunk/src/kofacustom/dspg
Files:
3 edited

Legend:

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

    r14921 r14938  
    202202            # amount_auth is being ignored. However, the sum of all split payments
    203203            # must coincide with the amount_auth configured in students/utils.py
    204             xmldict['amt1'] = 100 * (1000 - GATEWAY_AMT)
     204            xmldict['amt1'] = 100 * 1000
    205205            xmldict['amt2'] = 100 * 500
    206206            xmldict['amt3'] = 100 * 900
    207207            xmldict['amt4'] = 100 * 500
    208             xmltext = """<payment_item_detail>
     208
     209            if student.faccode == 'SPAT':
     210                xmltext = """<payment_item_detail>
     211<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     212<item_detail item_id="1" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" />
     213<item_detail item_id="2" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" />
     214</item_details>
     215</payment_item_detail>""" % xmldict
     216            else:
     217                xmltext = """<payment_item_detail>
    209218<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
    210219<item_detail item_id="1" item_name="SUG" item_amt="%(amt1)d" bank_id="11" acct_num="0038079930" />
    211220<item_detail item_id="2" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" />
    212221<item_detail item_id="3" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" />
    213 <item_detail item_id="4" item_name="NADESSTU " item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
    214 </item_details>
    215 </payment_item_detail>""" % xmldict
    216 
     222<item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
     223</item_details>
     224</payment_item_detail>""" % xmldict
    217225        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
    218226        self.context.provider_amt = provider_amt
    219227        self.context.gateway_amt = GATEWAY_AMT
    220 
    221228        hashargs = (
    222229            self.context.p_id +
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/tests.py

    r14921 r14938  
    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'
     70            in self.browser.contents)
     71        payment = createObject('waeup.StudentOnlinePayment')
     72        payment.p_category = u'dep_sug'
     73        payment.p_session = self.student.current_session
     74        payment.p_id = u'anyid'
     75        payment.p_state = u'paid'
     76        self.student['payments']['anykey'] = payment
     77        self.browser.open(self.payments_path + '/addop')
     78        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     79        self.browser.getControl("Create ticket").click()
    6980        self.assertMatches('...ticket created...',
    7081                           self.browser.contents)
    7182        ctrl = self.browser.getControl(name='val_id')
    72         self.value = ctrl.options[0]
     83        self.value = ctrl.options[1]
    7384        self.browser.getLink(self.value).click()
    7485        self.assertTrue('<span>30000.0</span>'  in self.browser.contents)
     
    8899        self.browser.getControl(name="form.p_category").value = ['clearance']
    89100        self.browser.getControl("Create ticket").click()
    90         self.assertMatches('...ticket created...',
    91                            self.browser.contents)
    92         ctrl = self.browser.getControl(name='val_id')
    93         self.value = ctrl.options[1]
    94         self.browser.getLink(self.value).click()
    95         self.assertMatches('...Amount Authorized...',
    96                            self.browser.contents)
    97         self.assertMatches(
    98             '...<span>12345.0</span>...',
    99             self.browser.contents)
    100         self.payment_url = self.browser.url
    101         self.browser.getLink("CollegePAY", index=0).click()
    102         self.assertTrue('<input type="hidden" name="pay_item_id" value="103" />' in
    103                            self.browser.contents)
     101        self.assertTrue('ticket created' in self.browser.contents)
     102        ctrl = self.browser.getControl(name='val_id')
     103        self.value = ctrl.options[2]
     104        self.browser.getLink(self.value).click()
     105        self.assertTrue('Amount Authorized' in self.browser.contents)
     106        self.assertTrue('<span>12345.0</span>' in self.browser.contents)
     107        self.payment_url = self.browser.url
     108        self.browser.getLink("CollegePAY", index=0).click()
     109        self.assertTrue('<input type="hidden" name="pay_item_id" value="103" />'
     110                           in self.browser.contents)
    104111        self.assertTrue(
    105112            '<input type="hidden" name="amount" value="1234500" />' in
     
    142149                           self.browser.contents)
    143150
    144     def test_interswitch_form_pt_payments(self):
     151    def test_pt_payments(self):
    145152        # Add SPAT certificate
    146153        certificate = createObject('waeup.Certificate')
     
    165172        self.certificate.study_mode = 'nd_ft'
    166173        self.certificate.school_fee_3 = 30000.0
     174        # Add dep_sug ticket
     175        self.browser.open(self.payments_path + '/addop')
     176        self.browser.getControl(name="form.p_category").value = ['dep_sug']
     177        self.browser.getControl("Create ticket").click()
     178        self.assertMatches('...ticket created...', self.browser.contents)
     179        ctrl = self.browser.getControl(name='val_id')
     180        dep_sug_pid = ctrl.options[0]
     181        self.assertTrue(self.student['payments'][dep_sug_pid].amount_auth == 1650)
     182       
     183        self.browser.getLink(dep_sug_pid).click()
     184        self.browser.getLink("CollegePAY", index=0).click()
     185        self.student['payments'][dep_sug_pid].p_state = 'paid'
     186        self.assertTrue(
     187            '<item_detail item_id="1" item_name="Students Welfare" '
     188            'item_amt="50000" bank_id="11" acct_num="0037892949" />'
     189            in self.browser.contents)
     190        # Add school fee ticket
    167191        self.browser.open(self.payments_path + '/addop')
    168192        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    170194        self.assertMatches('...ticket created...', self.browser.contents)
    171195        ctrl = self.browser.getControl(name='val_id')
    172         self.value = ctrl.options[0]
     196        self.value = ctrl.options[1]
    173197        self.browser.getLink(self.value).click()
    174198        self.assertTrue('<span>30000.0</span>'  in self.browser.contents)
     
    194218        self.value = ctrl.options[0]
    195219        self.browser.getLink(self.value).click()
    196         self.assertTrue('<span>2900.0</span>'  in self.browser.contents)
    197         self.payment_url = self.browser.url
    198         self.browser.getLink("CollegePAY", index=0).click()
    199         self.assertTrue('<item_detail item_id="1" item_name="SUG" item_amt="75000" bank_id="11" acct_num="0038079930" />'
     220        self.assertTrue('<span>3150.0</span>'  in self.browser.contents)
     221        self.payment_url = self.browser.url
     222        self.browser.getLink("CollegePAY", index=0).click()
     223        self.assertTrue('<item_detail item_id="1" item_name="SUG" item_amt="100000" bank_id="11" acct_num="0038079930" />'
    200224            in self.browser.contents)
    201225        self.assertTrue('<item_detail item_id="2" item_name="Students Welfare" item_amt="50000" bank_id="11" acct_num="0037892949" />'
     
    203227        self.assertTrue('<item_detail item_id="3" item_name="Anti-Cult Book" item_amt="90000" bank_id="11" acct_num="0037892949" />'
    204228            in self.browser.contents)
    205         self.assertTrue('<item_detail item_id="4" item_name="NADESSTU " item_amt="50000" bank_id="11" acct_num="0036375968" />'
     229        self.assertTrue('<item_detail item_id="4" item_name="NADESSTU" item_amt="50000" bank_id="11" acct_num="0036375968" />'
    206230            in self.browser.contents)
    207231
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/utils.py

    r14921 r14938  
    3636    # prefix
    3737    STUDENT_ID_PREFIX = u'P'
     38
     39    def _dep_sug_paymentMade(self, student, session):
     40        if len(student['payments']):
     41            for ticket in student['payments'].values():
     42                if ticket.p_state == 'paid' and \
     43                    ticket.p_category == 'dep_sug' and \
     44                    ticket.p_session == session:
     45                    return True
     46        return False
    3847
    3948    def setPaymentDetails(self, category, student,
     
    8796                        amount = getattr(certificate, 'school_fee_4', 0.0)
    8897            else:
     98                # Students are only allowed to pay school fee
     99                # if current session dep_sug payment has been made.
     100                if not self._dep_sug_paymentMade(student,
     101                    student.current_session):
     102                    return _('You have to pay NADESU/SA/SUG Dues first.'), None
    89103                if student.state == CLEARED:
    90104                    if local(student):
     
    164178            amount = 13000.0
    165179        elif category == 'dep_sug':
    166             amount = 2900.0
     180            amount = 3150.0 # includes GATEWAY_AMT
     181            if student.faccode == 'SPAT':
     182                amount = 1650.0 # includes GATEWAY_AMT
    167183        else:
    168184            fee_name = category + '_fee'
Note: See TracChangeset for help on using the changeset viewer.