Ignore:
Timestamp:
10 Mar 2025, 16:40:53 (8 hours ago)
Author:
Henrik Bettermann
Message:

Implement required combi split payments.

File:
1 edited

Legend:

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

    r17900 r18034  
    1919import hashlib
    2020import grok
     21from waeup.kofa.students.interfaces import IStudentsUtils
     22from zope.component import getUtility
    2123from kofacustom.nigeria.interswitch.browser import (
    2224    module_activated,
     
    5254HTTPS = True
    5355
     56BANK_ACCOUNTS = {
     57    'access':               ('1228744877', '117'),
     58    'parentsconsult':       ('1228747029', '117'),
     59    'health_insurance':     ('1228744884', '117'),
     60    'municipal_returning':  ('0040621193','31'),
     61    'clearance':            ('0040621193','31'),
     62    'develop':              ('0040621193','31'),
     63    'medical_screening':    ('1311220657','117'),
     64    'conv':                 ('0040621193','31'),
     65    'registration_fresh':   ('0040621193','31'),
     66    'science':              ('0040621193','31'),
     67    'id_card':              ('0040621193','31'),
     68    'alumni':               ('1311974981','117'),
     69    'lab_support':          ('0040621193','31'),
     70    'registration_return':  ('0040621193','31'),
     71    'book':                 ('1228744877','117'),
     72    'waecneco':             ('0040621193','31'),
     73    'jambver':              ('0040621193','31'),
     74    'pg_other':             ('0040621193','31'),
     75    'municipal_fresh':      ('0040621193','31'),
     76    'matric':               ('0040621193','31')
     77    }
     78
    5479class CustomInterswitchPageStudent(InterswitchPageStudent):
    5580    """ View which sends a POST request to the Interswitch
     
    6590
    6691    def update(self):
     92        student_utils = getUtility(IStudentsUtils)
    6793        if not module_activated(
    6894            self.context.student.current_session, self.context):
     
    97123            'schoolfee', 'schoolfee40', 'secondinstal'):
    98124            self.pay_item_id = '101'
    99         elif self.context.p_category == 'book':
    100             self.pay_item_id = '103'
    101         elif self.context.p_category == 'parentsconsult':
    102             self.pay_item_id = '104'
    103         elif self.context.p_category in (
    104             'municipal_fresh', 'municipal_returning',
    105             'transcript_local', 'transcript_overseas', 'transcript'):
    106             self.pay_item_id = '105'
    107125        else:
     126            # we use the same item_id for all sundry payments
    108127            self.pay_item_id = '102'
    109128        if self.context.p_category in (
     
    143162
    144163            # Overwrite above selection
    145             if self.context.p_category == 'book':
    146                 xmldict['institution_acct'] = '1228744877'
    147                 xmldict['institution_bank_id'] = '117'
    148             elif self.context.p_category == 'parentsconsult':
    149                 xmldict['institution_acct'] = '1228747029'
    150                 xmldict['institution_bank_id'] = '117'
    151             elif self.context.p_category == 'health_insurance':
    152                 xmldict['institution_acct'] = '1228744884'
    153                 xmldict['institution_bank_id'] = '117'
     164            sundry_acct = BANK_ACCOUNTS.get(self.context.p_category, None)
     165            if sundry_acct is True:
     166                xmldict['institution_acct'] = sundry_acct[0]
     167                xmldict['institution_bank_id'] = sundry_acct[0]
    154168
    155169        if provider_amt == 0:
     
    166180</item_details>
    167181</payment_item_detail>""" % xmldict
     182
     183        # Overwrite xmltext above because we have to split required combi
     184        if self.context.p_category == 'required_combi':
     185            rp = student_utils._collect_required_payment_items(self.context.student)
     186            academic_session = student_utils._getSessionConfiguration(self.context.p_session)
     187            xmltext = """<payment_item_detail>
     188<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     189<item_detail item_id="1" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />""" % xmldict
     190            item_id = 2
     191            for cat in rp:
     192                fee_name = cat + '_fee'
     193                item_name = cat
     194                item_amt = 100 * getattr(academic_session, fee_name, 0.0)
     195                if item_name.startswith('registration'):
     196                    item_amt -= 100 * provider_amt
     197                bank_id = BANK_ACCOUNTS[cat][1]
     198                acct_num = BANK_ACCOUNTS[cat][0]
     199                xmltext += """
     200<item_detail item_id="%s" item_name="%s" item_amt="%d" bank_id="%s" acct_num="%s" />""" % (item_id, item_name, item_amt, bank_id, acct_num)
     201                item_id += 1
     202            xmltext += """
     203</item_details>
     204</payment_item_detail>""" % xmldict
     205
    168206        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
    169207        self.amount_auth = int(100 * self.context.amount_auth)
Note: See TracChangeset for help on using the changeset viewer.