Ignore:
Timestamp:
11 Mar 2015, 12:00:18 (10 years ago)
Author:
Henrik Bettermann
Message:

Configure complex split payment, see ticket #117.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/interswitch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py

    r12480 r12729  
    116116
    117117    def update(self):
    118 
    119         self.flash('Payment method not yet configured.', type='danger')
    120         self.redirect(self.url(self.context, '@@index'))
    121         return
    122 
    123 
    124         error = self.init_update()
    125         if error:
    126             self.flash(error, type='danger')
    127             self.redirect(self.url(self.context, '@@index'))
    128             return
     118        #self.flash('Payment method not yet configured.', type='danger')
     119        #self.redirect(self.url(self.context, '@@index'))
     120        #return
     121        super(CustomInterswitchPageStudent, self).update()
    129122        student = self.student
    130123        xmldict = self.xmldict
     124        xmltext = ""
    131125        # Provider data
    132126        xmldict['detail_ref'] = self.context.p_id
     
    134128        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
    135129        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
    136         # Institution data
    137         xmldict['institution_acct'] = '00000000'
    138         xmldict['institution_bank_id'] = '00'
    139         xmldict['institution_amt'] = '0.0'
    140         provider_amt = 0.0
    141         xmldict['provider_amt'] = 100 * provider_amt
    142130        xmldict['institution_item_name'] = self.category
    143131        xmldict['institution_name'] = INSTITUTION_NAME
    144         xmldict['institution_amt'] = 100 * (
    145             self.context.amount_auth - provider_amt - GATEWAY_AMT)
    146         # Interswitch amount is not part of the xml data
    147         if provider_amt == 0:
    148             xmltext = """<payment_item_detail>
    149 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
    150 <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
    151 </item_details>
    152 </payment_item_detail>""" % xmldict
    153         else:
     132
     133        if self.context.p_category == 'schoolfee':
     134            if student.faccode == 'FCETA':
     135                xmldict['institution_acct'] = '1190118227'
     136                xmldict['institution_bank_id'] = '123'
     137            else:
     138                xmldict['institution_bank_id'] = '7'
     139                xmldict['institution_acct'] = '1014847058'
     140            if student.current_mode == 'found':
     141                self.pay_item_id = '103'
     142            else:
     143                self.pay_item_id = '105'
     144            provider_amt = 1900.0
     145            joint_venture_amt = 1100.0
     146            aaue_share_amt = 1000.0
     147            student_union_due_amt = 1000.0
     148            student_welfare_assurance_amt = 500.0
     149            xmldict['provider_amt'] = 100 * provider_amt
     150            xmldict['joint_venture_amt'] = 100 * joint_venture_amt
     151            xmldict['aaue_share_amt'] = 100 * aaue_share_amt
     152            xmldict['student_union_due_amt'] = 100 * student_union_due_amt
     153            xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
     154            xmldict['institution_amt'] = 100 * (
     155                self.context.amount_auth
     156                - provider_amt
     157                - joint_venture_amt
     158                - aaue_share_amt
     159                - student_union_due_amt
     160                - student_welfare_assurance_amt
     161                - GATEWAY_AMT)
    154162            xmltext = """<payment_item_detail>
    155163<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
    156164<item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
    157165<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
     166<item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="51" acct_num="5060023759" />
     167<item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="51" acct_num="5060020947" />
     168<item_detail item_id="5" item_name="Student Union" item_amt="%(student_union_due_amt)d" bank_id="123" acct_num="1006360118" />
     169<item_detail item_id="6" item_name="Student Welfare Assurance" item_amt="%(student_welfare_assurance_amt)d" bank_id="31" acct_num="1006407792" />
    158170</item_details>
    159171</payment_item_detail>""" % xmldict
     172        elif self.context.p_category == 'clearance':
     173            if student.current_mode == 'found':
     174                self.pay_item_id = '102'
     175            else:
     176                self.pay_item_id = '104'
     177            xmldict['institution_acct'] = '1014066976'
     178            xmldict['institution_bank_id'] = '117'
     179            provider_amt = 0.0
     180            gown_fee_amt = 2000.0
     181            aaue_fl_fee_amt = 800.0
     182            xmldict['gown_fee_amt'] = 100 * gown_fee_amt
     183            xmldict['aaue_fl_fee_amt'] = 100 * aaue_fl_fee_amt
     184            xmldict['institution_amt'] = 100 * (
     185                self.context.amount_auth
     186                - gown_fee_amt
     187                - aaue_fl_fee_amt
     188                - GATEWAY_AMT)
     189            xmltext = """<payment_item_detail>
     190<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     191<item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
     192<item_detail item_id="2" item_name="Matriculation Gown Fee" item_amt="%(gown_fee_amt)d" bank_id="51" acct_num="5060020947" />
     193<item_detail item_id="3" item_name="AAU File-Lapel Fee" item_amt="%(aaue_fl_fee_amt)d" bank_id="51" acct_num="4010660109" />
     194</item_details>
     195</payment_item_detail>""" % xmldict
     196
     197
    160198        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
    161199        self.context.provider_amt = provider_amt
    162200        self.context.gateway_amt = GATEWAY_AMT
    163 
    164201        hashargs = (
    165202            self.context.p_id +
     
    170207            self.mac)
    171208        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
    172 
    173209        return
    174210
  • main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py

    r12480 r12729  
    106106        super(InterswitchTestsStudents, self).setUp()
    107107
    108     def disabled_test_interswitch_form(self):
    109         self.app['configuration']['2004'].school_fee_1 = 6666.0
     108    def test_interswitch_form_school_fees(self):
     109        self.app['configuration']['2004'].school_fee_1 = 51750.0
    110110        # Manager can access InterswitchForm
    111111        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    124124                           self.browser.contents)
    125125        self.assertMatches(
    126             '...<span>6666.0</span>...',
     126            '...<span>51750.0</span>...',
    127127            self.browser.contents)
    128128        self.payment_url = self.browser.url
    129129        self.browser.getLink("CollegePAY", index=0).click()
    130         self.assertMatches('...<input type="hidden" name="pay_item_id" value="101" />...',
     130        self.assertMatches('...<input type="hidden" name="pay_item_id" value="105" />...',
    131131                           self.browser.contents)
    132132        self.assertMatches('...Total Amount Authorized:...',
     
    134134        self.assertEqual(self.student.current_mode, 'ug_ft')
    135135        self.assertMatches(
    136             '...<input type="hidden" name="amount" value="666600" />...',
    137             self.browser.contents)
    138         self.assertMatches(
    139             '...item_name="School Fee" item_amt="641600" bank_id="00" acct_num="00000000"...',
     136            '...<input type="hidden" name="amount" value="5175000" />...',
     137            self.browser.contents)
     138        self.assertMatches(
     139            '...item_name="School Fee" item_amt="4600000" bank_id="7" acct_num="1014847058"...',
     140            self.browser.contents)
     141
     142    def test_interswitch_form_acceptance_fees(self):
     143        self.app['configuration']['2004'].clearance_fee = 43050.0
     144        # Manager can access InterswitchForm
     145        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     146        self.browser.open(self.payments_path)
     147        IWorkflowState(self.student).setState('admitted')
     148        self.student.nationality = u'NG'
     149        self.browser.open(self.payments_path + '/addop')
     150        self.browser.getControl(name="form.p_category").value = ['clearance']
     151        self.browser.getControl("Create ticket").click()
     152        self.assertMatches('...ticket created...',
     153                           self.browser.contents)
     154        ctrl = self.browser.getControl(name='val_id')
     155        self.value = ctrl.options[0]
     156        self.browser.getLink(self.value).click()
     157        self.assertMatches('...Amount Authorized...',
     158                           self.browser.contents)
     159        self.assertMatches(
     160            '...<span>43050.0</span>...',
     161            self.browser.contents)
     162        self.payment_url = self.browser.url
     163        self.browser.getLink("CollegePAY", index=0).click()
     164        self.assertMatches('...<input type="hidden" name="pay_item_id" value="104" />...',
     165                           self.browser.contents)
     166        self.assertMatches('...Total Amount Authorized:...',
     167                           self.browser.contents)
     168        self.assertMatches(
     169            '...<input type="hidden" name="amount" value="5175000" />...',
     170            self.browser.contents)
     171        self.assertMatches(
     172            '...item_name="Acceptance Fee" item_amt="4280000" bank_id="117" acct_num="1014066976"...',
    140173            self.browser.contents)
    141174
Note: See TracChangeset for help on using the changeset viewer.