Ignore:
Timestamp:
19 Mar 2016, 12:51:01 (9 years ago)
Author:
Henrik Bettermann
Message:

Improve and reorganize webservice.

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

Legend:

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

    r13783 r13784  
    8585                self.output = ERROR_PART1 + 'Wrong IP address' + ERROR_PART2
    8686                return
    87         if PAYMENT_TYPE not in (
    88             'SCHOOL-FEE-NEW',
    89             'SCHOOL-FEE-RETURNING',
    90             'SCHOOL-FEE-PLUS-NEW',
    91             'SCHOOL-FEE-PLUS-RETURNING',
    92             'SCHOOL-FEE-PG-NEW',
    93             'SCHOOL-FEE-PG-RETURNING',
    94             'SCHOOL-FEE-FIRST-INSTALMENT-PLUS',
    95             'SCHOOL-FEE-SECOND-INSTALMENT',
    96             'SCHOOL-FEE-BALANCE',
    97             'ACCEPTANCE-FEE',
    98             'ACCEPTANCE-FEE-PLUS',
    99             'ACCEPTANCE-FEE-PG',
    100             'APPLICATION-FEE',
    101             'LATE-REGISTRATION',
    102             'AAU-STUDENT-WELFARE-ASSURANCE',
    103             'HOSTEL-ACCOMMODATION-FEE',
    104             'AAU-LAPEL-FILE-FEE',
    105             'MATRICULATION-GOWN-FEE',
    106             'CONCESSIONAL-FEE',
    107             'STUDENTS-UNION-DUES',
    108             'MEDICAL-STUDENT-ASSURANCE-FEE'):
     87        category_mapping = {
     88            'SCHOOL-FEE-NEW': ('schoolfee',),
     89            'SCHOOL-FEE-RETURNING': ('schoolfee',),
     90            'SCHOOL-FEE-PLUS-NEW': ('schoolfee_incl',),
     91            'SCHOOL-FEE-PLUS-RETURNING': ('schoolfee_incl',),
     92            'SCHOOL-FEE-PG-NEW': ('schoolfee',),
     93            'SCHOOL-FEE-PG-RETURNING': ('schoolfee',),
     94            'SCHOOL-FEE-FIRST-INSTALMENT-PLUS': ('schoolfee_1',),
     95            'SCHOOL-FEE-SECOND-INSTALMENT': ('schoolfee_2',),
     96            'SCHOOL-FEE-BALANCE': ('schoolfee','schoolfee_incl',
     97                                   'schoolfee_1','schoolfee_2'),
     98            'ACCEPTANCE-FEE': ('clearance',),
     99            'ACCEPTANCE-FEE-PLUS': ('clearance_incl',),
     100            'ACCEPTANCE-FEE-PG': ('clearance',),
     101            'APPLICATION-FEE': ('application',),
     102            'LATE-REGISTRATION': ('late_registration',),
     103            'AAU-STUDENT-WELFARE-ASSURANCE': ('welfare',),
     104            'HOSTEL-ACCOMMODATION-FEE': ('hostel_maintenance',),
     105            'AAU-LAPEL-FILE-FEE': ('lapel',),
     106            'MATRICULATION-GOWN-FEE': ('matric_gown',),
     107            'CONCESSIONAL-FEE': ('concessional',),
     108            'STUDENTS-UNION-DUES': ('union',),
     109            }
     110
     111        if PAYMENT_TYPE not in category_mapping.keys():
    109112            self.output = ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2
    110113            return
     
    130133        amount = results[0].amount_auth
    131134        payment_type = results[0].category
     135        p_category = results[0].p_category
    132136        programme_type = results[0].p_item
    133137        if not programme_type:
     
    136140            results[0].p_session).title
    137141        status = results[0].p_state
     142
    138143        if status == 'paid':
    139144            self.output = ERROR_PART1 + 'PAYEE_ID already used' + ERROR_PART2
    140145            return
    141         if PAYMENT_TYPE.startswith('SCHOOL-FEE') \
    142             and not results[0].p_category.startswith('schoolfee'):
    143             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    144             return
    145         if '-FIRST' in PAYMENT_TYPE and not '_1' in results[0].p_category:
    146             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    147             return
    148         if '-SECOND' in PAYMENT_TYPE and not '_2' in results[0].p_category:
     146        if p_category not in category_mapping[PAYMENT_TYPE]:
    149147            self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    150148            return
    151149        if student and PAYMENT_TYPE.endswith('-RETURNING') \
    152150            and student.state == CLEARED:
    153             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
     151            self.output = ERROR_PART1 + 'Not a returning student' + ERROR_PART2
    154152            return
    155153        if student and PAYMENT_TYPE.endswith('-NEW') \
    156154            and student.state != CLEARED:
    157             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
     155            self.output = ERROR_PART1 + 'Not a new student' + ERROR_PART2
    158156            return
    159157        if student and '-PG' in PAYMENT_TYPE and not student.is_postgrad:
    160             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
     158            self.output = ERROR_PART1 + 'Not a postgrad student' + ERROR_PART2
     159            return
     160        if student and '-PG' not in PAYMENT_TYPE and student.is_postgrad:
     161            self.output = ERROR_PART1 + 'Postgrad student' + ERROR_PART2
    161162            return
    162163        if '-BALANCE' in PAYMENT_TYPE and results[0].p_item != 'Balance':
    163             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    164             return
    165         if '-PLUS' in PAYMENT_TYPE and not 'incl' in results[0].p_category:
    166             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    167             return
    168         if PAYMENT_TYPE.startswith('ACCEPTANCE-FEE') \
    169             and not results[0].p_category.startswith('clearance'):
    170             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    171             return
    172         if PAYMENT_TYPE == 'LATE-ADMISSION-PROCESSING' \
    173             and not results[0].p_category == 'late_registration':
    174             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    175             return
    176         if PAYMENT_TYPE == 'AAU-STUDENT-WELFARE-ASSURANCE' \
    177             and not results[0].p_category == 'welfare':
    178             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    179             return
    180         if PAYMENT_TYPE == 'HOSTEL-ACCOMMODATION-FEE' \
    181             and not results[0].p_category == 'hostel_maintenance':
    182             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    183             return
    184         if PAYMENT_TYPE == 'AAU-LAPEL-FILE-FEE' \
    185             and not results[0].p_category == 'lapel':
    186             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    187             return
    188         if PAYMENT_TYPE == 'MATRICULATION-GOWN-FEE' \
    189             and not results[0].p_category == 'matric_gown':
    190             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    191             return
    192         if PAYMENT_TYPE == 'CONCESSIONAL-FEE' \
    193             and not results[0].p_category == 'concessional':
    194             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    195             return
    196         if PAYMENT_TYPE == 'STUDENTS-UNION-DUES' \
    197             and not results[0].p_category == 'union':
    198             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    199             return
    200         if PAYMENT_TYPE == 'MEDICAL-STUDENT-ASSURANCE-FEE' \
    201             and not results[0].p_category == 'medical':
    202             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    203             return
    204         if PAYMENT_TYPE == 'APPLICATION-FEE' \
    205             and not results[0].p_category == 'application':
    206             self.output = ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2
    207             return
     164            self.output = ERROR_PART1 + 'Not a balance payment' + ERROR_PART2
     165            return
     166        if not '-BALANCE' in PAYMENT_TYPE and results[0].p_item == 'Balance':
     167            self.output = ERROR_PART1 + 'Balance payment' + ERROR_PART2
     168            return
     169
    208170        try:
    209171            owner = IPayer(results[0])
  • main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py

    r13421 r13784  
    7272        value2 = ctrl.options[1]
    7373        self.p_id = value2
     74        self.payment = self.student['payments'][value2]
    7475        self.browser.getLink(value2).click()
    7576        self.assertMatches('...Amount Authorized...',
     
    9495    def test_webservice(self):
    9596        self.browser.open(
    96             'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-NEW'
     97            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-PLUS-NEW'
    9798            % self.p_id)
    9899        self.assertEqual(self.browser.contents,
     
    115116        self.browser.open('http://localhost/app/feerequest')
    116117        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Missing PAYEE_ID' + ERROR_PART2)
     118
    117119        self.browser.open('http://localhost/app/feerequest?NONSENSE=nonsense')
    118120        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Missing PAYEE_ID' + ERROR_PART2)
     121
    119122        self.browser.open(
    120123            'http://localhost/app/feerequest?PAYEE_ID=nonsense&PAYMENT_TYPE=SCHOOL-FEE-NEW')
    121124        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYEE_ID' + ERROR_PART2)
     125
    122126        self.browser.open(
    123127            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=NONSENSE'
    124128            % self.p_id)
    125129        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2)
     130
    126131        self.browser.open(
    127132            'http://localhost/app/feerequest?PAYEE_ID=%s'
    128133            % self.p_id)
    129134        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Invalid PAYMENT_TYPE' + ERROR_PART2)
     135
    130136        self.browser.open(
    131137            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=ACCEPTANCE-FEE'
    132138            % self.p_id)
    133139        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
     140
    134141        self.browser.open(
    135142            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=APPLICATION-FEE'
    136143            % self.p_id)
    137144        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
     145
    138146        self.student['payments'][self.p_id].p_state = 'paid'
    139147        self.browser.open(
     
    148156            % self.p_id)
    149157        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Wrong PAYMENT_TYPE' + ERROR_PART2)
     158
     159        self.browser.open(
     160            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-BALANCE'
     161            % self.p_id)
     162        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Not a balance payment' + ERROR_PART2)
     163        self.payment.p_item = u'Balance'
     164        self.browser.open(
     165            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-PLUS-RETURNING'
     166            % self.p_id)
     167        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Balance payment' + ERROR_PART2)
     168        self.payment.p_item = u'CERT1'
     169
     170        self.payment.p_category = 'schoolfee'
     171        self.certificate.study_mode = 'special_pg_ft'
    150172        self.browser.open(
    151173            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-RETURNING'
    152174            % self.p_id)
    153 
     175        self.assertEqual(self.browser.contents, ERROR_PART1 + 'Postgrad student' + ERROR_PART2)
     176
     177        self.certificate.study_mode = 'ug_ft'
     178        self.browser.open(
     179            'http://localhost/app/feerequest?PAYEE_ID=%s&PAYMENT_TYPE=SCHOOL-FEE-RETURNING'
     180            % self.p_id)
    154181        self.assertEqual(self.browser.contents,
    155182            'PayeeName=Anna Tester~'
     
    164191            'FeeStatus=unpaid~'
    165192            'Semester=N/A~'
    166             'PaymentType=School Fee Plus~'
     193            'PaymentType=School Fee~'
    167194            'MatricNumber=E1000000~'
    168195            'Email=aa@aa.ng~'
Note: See TracChangeset for help on using the changeset viewer.