Ignore:
Timestamp:
14 Dec 2016, 16:57:13 (8 years ago)
Author:
Henrik Bettermann
Message:

Implement payment by instalments.

Location:
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri
Files:
7 edited

Legend:

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

    r14342 r14344  
    3838CURRENCY = '566'
    3939GATEWAY_AMT = 300.0
     40MAC = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
    4041
    4142POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
     
    5859    currency = CURRENCY
    5960    product_id = PRODUCT_ID
    60     mac = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
     61    mac = MAC
    6162
    6263    def update(self):
     
    128129    pay_item_id = '101'
    129130    product_id = PRODUCT_ID
    130     mac = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
     131    mac = MAC
    131132
    132133    def update(self):
     
    177178    gateway_host = HOST
    178179    gateway_url = URL
    179     mac = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
     180    mac = MAC
    180181
    181182class CustomInterswitchPaymentVerifyWebservicePageStudent(
     
    187188    gateway_host = HOST
    188189    gateway_url = URL
    189     mac = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
     190    mac = MAC
    190191
    191192class CustomInterswitchPaymentRequestWebservicePageApplicant(
     
    197198    gateway_host = HOST
    198199    gateway_url = URL
    199     mac = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
     200    mac = MAC
    200201
    201202class CustomInterswitchPaymentVerifyWebservicePageApplicant(
     
    207208    gateway_host = HOST
    208209    gateway_url = URL
    209     mac = '9309B5CBF1BFB09693C6F5F578046E3FCAB0A2538C3FE4221A6E63AFD348DE888E655F9C7E9F112151A702B6B09E6A7ACC5B3BF3C701F0C1B0D8EA6C1872AE94'
     210    mac = MAC
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/interswitch/tests.py

    r14336 r14344  
    8181            self.browser.contents)
    8282        self.assertMatches(
    83             '...item_name="School Fee" item_amt="7950000" bank_id="7" acct_num="1019684470"...',
     83            '...item_name="School Fee (total)" item_amt="7950000" bank_id="7" acct_num="1019684470"...',
    8484            self.browser.contents)
    8585
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/payments.py

    r14340 r14344  
    2121import grok
    2222from zope.component.interfaces import IFactory
     23from zope.schema.interfaces import ConstraintNotSatisfied
    2324from zope.interface import implementedBy
     25from hurry.workflow.interfaces import IWorkflowInfo
    2426from waeup.kofa.students.interfaces import IStudentNavigation
     27from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID
    2528from waeup.kofa.utils.helpers import attrs_to_fields
    2629from kofacustom.nigeria.students.payments import (
     
    5962                return error
    6063            self.ac = pin
    61         elif self.p_category.startswith('schoolfee'):
     64        elif self.p_category in ('schoolfee', 'schoolfee_1') :
    6265            # Bypass activation code creation if next session
    6366            # can be started directly.
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/tests/test_browser.py

    r14035 r14344  
    4242    layer = FunctionalLayer
    4343
    44     def test_dummytest(self):
     44    def test_for_instalment_payments(self):
     45
     46        #configuration_1 = createObject('waeup.SessionConfiguration')
     47        #configuration_1.academic_session = 2015
     48        #self.app['configuration'].addSessionConfiguration(configuration_1)
     49        self.student['studycourse'].certificate.study_mode = 'ug_ft'
     50        self.student.nationality = u'NG'
     51        # Fresh student
     52        IWorkflowState(self.student).setState('cleared')
     53        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     54        self.browser.open(self.payments_path + '/addop')
     55        self.browser.open(self.payments_path + '/addop')
     56        # Add first instalment
     57        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
     58        self.browser.getControl("Create ticket").click()
     59        self.assertTrue('ticket created' in self.browser.contents)
     60        self.browser.open(self.payments_path)
     61        ctrl = self.browser.getControl(name='val_id')
     62        p_id = ctrl.options[0]
     63        self.browser.open(self.payments_path + '/' + p_id + '/approve')
     64        # Add the second instalment ...
     65        self.browser.open(self.payments_path + '/addop')
     66        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
     67        self.browser.getControl("Create ticket").click()
     68        self.assertTrue('ticket created' in self.browser.contents)
     69        # ... approve the second instalment ...
     70        ctrl = self.browser.getControl(name='val_id')
     71        p_id = ctrl.options[1]
     72        self.browser.open(self.payments_path + '/' + p_id + '/approve')
     73        self.assertEqual(self.student['payments'].values()[0].p_category, 'schoolfee_1')
     74        self.assertEqual(self.student['payments'].values()[1].p_category, 'schoolfee_2')
     75        # 79200 / 2 + 300
     76        self.assertEqual(self.student['payments'].values()[0].amount_auth, 39900.0)
     77        self.assertEqual(self.student['payments'].values()[1].amount_auth, 39900.0)
     78        # The  two payments belong to the same session and level.
     79        self.assertEqual(self.student['payments'].values()[0].p_session, 2004)
     80        self.assertEqual(self.student['payments'].values()[0].p_level, 100)
     81        self.assertEqual(self.student['payments'].values()[1].p_session, 2004)
     82        self.assertEqual(self.student['payments'].values()[1].p_level, 100)
     83
     84        # Returning student
     85        configuration_2 = createObject('waeup.SessionConfiguration')
     86        configuration_2.academic_session = 2005
     87        self.app['configuration'].addSessionConfiguration(configuration_2)
     88        IWorkflowState(self.student).setState('returning')
     89        self.browser.open(self.payments_path + '/addop')
     90        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
     91        self.browser.getControl("Create ticket").click()
     92        self.browser.open(self.payments_path + '/addop')
     93        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
     94        self.browser.getControl("Create ticket").click()
     95        self.browser.open(self.payments_path)
     96        ctrl = self.browser.getControl(name='val_id')
     97        # Nothing happens if we approve the 2nd instalment for session 2005
     98        self.browser.open(self.payments_path + '/' + ctrl.options[3] + '/approve')
     99        self.assertEqual(self.student.state, 'returning')
     100        # Workflow transition is trigered if we approve the 1st indtalment
     101        self.browser.open(self.payments_path + '/' + ctrl.options[2] + '/approve')
     102        self.assertEqual(self.student.state, 'school fee paid')
     103        self.assertEqual(self.student.current_level, 200)
     104        self.assertEqual(self.student.current_session, 2005)
     105        # 63100 / 2 + 300
     106        self.assertEqual(self.student['payments'].values()[2].amount_auth, 31850.0)
     107        self.assertEqual(self.student['payments'].values()[3].amount_auth, 31850.0)
     108        # The last two payments belong to the same session and level.
     109        self.assertEqual(self.student['payments'].values()[2].p_session, 2005)
     110        self.assertEqual(self.student['payments'].values()[2].p_level, 200)
     111        self.assertEqual(self.student['payments'].values()[3].p_session, 2005)
     112        self.assertEqual(self.student['payments'].values()[3].p_level, 200)
    45113        return
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/tests/test_utils.py

    r14336 r14344  
    2727        self.app['configuration']['2016'].clearance_fee = 10234.0
    2828
    29         error, payment = utils.setPaymentDetails('schoolfee', self.student)
    30         self.assertEqual(payment, None)
    31         self.assertEqual(error, u'Amount could not be determined.')
    32         IWorkflowState(self.student).setState('cleared')
    3329        error, payment = utils.setPaymentDetails('schoolfee',self.student)
    3430        self.assertEqual(payment.p_level, 100)
    3531        self.assertEqual(payment.p_session, 2016)
    3632        self.assertEqual(payment.amount_auth, 79500.0)
     33        self.assertEqual(payment.p_item, u'CERT1')
     34        self.assertEqual(error, None)
     35
     36        error, payment = utils.setPaymentDetails('schoolfee_1',self.student)
     37        self.assertEqual(payment.p_level, 100)
     38        self.assertEqual(payment.p_session, 2016)
     39        self.assertEqual(payment.amount_auth, 39900.0)
     40        self.assertEqual(payment.p_item, u'CERT1')
     41        self.assertEqual(error, None)
     42
     43        error, payment = utils.setPaymentDetails('schoolfee_2',self.student)
     44        self.assertEqual(payment.p_level, 100)
     45        self.assertEqual(payment.p_session, 2016)
     46        self.assertEqual(payment.amount_auth, 39900.0)
    3747        self.assertEqual(payment.p_item, u'CERT1')
    3848        self.assertEqual(error, None)
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/utils.py

    r14336 r14344  
    7575            return _(u'Session configuration object is not available.'), None
    7676        # Determine fee.
    77         if category == 'schoolfee':
     77        if category.startswith('schoolfee'):
    7878            try:
    7979                certificate = student['studycourse'].certificate
     
    8888                    return _(u'Session configuration object '
    8989                              'is not available.'), None
    90             if student.state in (RETURNING, CLEARED):
    91                 if p_level in PAYMENT_LEVELS:
    92                     amount = SCHOOL_FEES.get_fee(
    93                         (
    94                          local_nonlocal(student),
    95                          student.current_mode,
    96                          p_level)
    97                         )
    98                     amount += GATEWAY_AMT
     90            if p_level in PAYMENT_LEVELS:
     91                amount = SCHOOL_FEES.get_fee(
     92                    (
     93                     local_nonlocal(student),
     94                     student.current_mode,
     95                     p_level)
     96                    )
     97            if amount and category in ('schoolfee_1', 'schoolfee_2'):
     98                amount /= 2
     99            if amount:
     100                amount += GATEWAY_AMT
    99101        elif category == 'clearance':
    100102            try:
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/utils/utils.py

    r14336 r14344  
    1818"""Customize general helper utilities for Kofa.
    1919"""
     20from copy import deepcopy
    2021from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
    2122
     
    4344        'no': 'no application',
    4445        }
     46
     47    PAYMENT_CATEGORIES = {
     48        'schoolfee': 'School Fee (total)',
     49        'schoolfee_1': 'School Fee (1st instalment)',
     50        'schoolfee_2': 'School Fee (2nd instalment)',
     51        'clearance': 'Acceptance Fee',
     52        #'bed_allocation': 'Bed Allocation Fee',
     53        #'hostel_maintenance': 'Hostel Maintenance Fee',
     54        #'transfer': 'Transfer Fee',
     55        #'gown': 'Gown Hire Fee',
     56        'application': 'Application Fee',
     57        #'transcript': 'Transcript Fee',
     58        #'late_registration': 'Late Course Registration Fee'
     59        }
     60
     61    SELECTABLE_PAYMENT_CATEGORIES = deepcopy(PAYMENT_CATEGORIES)
Note: See TracChangeset for help on using the changeset viewer.