Changeset 10675 for main/waeup.kwarapoly/trunk/src/waeup
- Timestamp:
- 30 Oct 2013, 19:43:48 (11 years ago)
- Location:
- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py
r10672 r10675 28 28 from waeup.kofa.configuration import SessionConfiguration 29 29 from waeup.kwarapoly.testing import FunctionalLayer 30 from waeup.kwarapoly.students.payments import CustomStudentOnlinePayment 30 31 31 32 # Also run tests that send requests to external servers? … … 76 77 notify(grok.ObjectModifiedEvent(self.student)) 77 78 79 80 def test_schoolfee_ticket_creation(self): 78 81 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 79 82 self.browser.open(self.payments_path) … … 82 85 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 83 86 self.browser.getControl("Create ticket").click() 87 self.assertMatches('...Book and pay for accommodation first...', 88 self.browser.contents) 89 # We add a fake maint. payment ticket to meet the condition 90 maint_payment = CustomStudentOnlinePayment() 91 self.student['payments']['any_key'] = maint_payment 92 maint_payment.p_category = 'hostel_maintenance' 93 maint_payment.p_state = 'unpaid' 94 maint_payment.p_session = 2004 95 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 96 self.browser.getControl("Create ticket").click() 97 self.assertMatches('...Book and pay for accommodation first...', 98 self.browser.contents) 99 # Ticket must be paid 100 maint_payment.p_state = 'paid' 101 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 102 self.browser.getControl("Create ticket").click() 84 103 self.assertMatches('...ticket created...', 85 104 self.browser.contents) 86 105 ctrl = self.browser.getControl(name='val_id') 87 self.value = ctrl.options[ 0]106 self.value = ctrl.options[1] 88 107 self.browser.getLink(self.value).click() 89 108 self.assertMatches('...Amount Authorized...', … … 107 126 108 127 def test_interswitch_form(self): 128 129 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 130 self.browser.open(self.payments_path) 131 # In KwaraPoly only returning students can create school fee payment 132 # without haveing paid accommodation fee 133 IWorkflowState(self.student).setState('returning') 134 configuration = createObject('waeup.SessionConfiguration') 135 configuration.academic_session = 2005 136 self.app['configuration'].addSessionConfiguration(configuration) 137 self.browser.open(self.payments_path + '/addop') 138 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 139 self.browser.getControl("Create ticket").click() 140 self.assertMatches('...ticket created...', self.browser.contents) 141 ctrl = self.browser.getControl(name='val_id') 142 self.value = ctrl.options[0] 143 self.browser.getLink(self.value).click() 144 self.assertMatches('...Amount Authorized...', self.browser.contents) 145 self.assertMatches( 146 '...<span>29500.0</span>...', 147 self.browser.contents) 148 self.payment_url = self.browser.url 149 109 150 # Manager can access InterswitchForm 110 151 self.assertEqual(self.student['payments'][self.value].provider_amt, 0.0) … … 119 160 self.browser.contents) 120 161 self.assertTrue( 121 '<input type="hidden" name="amount" value=" 3940000.0" />' in122 self.browser.contents) 123 self.assertTrue( 124 'item_name="School Fee" item_amt=" 3610000" bank_id="120" acct_num="1771180233"' in162 '<input type="hidden" name="amount" value="2950000.0" />' in 163 self.browser.contents) 164 self.assertTrue( 165 'item_name="School Fee" item_amt="2620000" bank_id="120" acct_num="1771180233"' in 125 166 self.browser.contents) 126 167 self.assertTrue( -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py
r10672 r10675 104 104 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 105 105 self.browser.getControl("Create ticket").click() 106 107 self.assertMatches('...Book and pay for accommodation first...', 108 self.browser.contents) 109 110 # In KwaraPoly only returning students can create school fee payment 111 # without haveing paid accommodation fee 112 IWorkflowState(self.student).setState('returning') 113 configuration = createObject('waeup.SessionConfiguration') 114 configuration.academic_session = 2005 115 self.app['configuration'].addSessionConfiguration(configuration) 116 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 117 self.browser.getControl("Create ticket").click() 106 118 self.assertMatches('...ticket created...', 107 119 self.browser.contents) … … 155 167 self.browser.open(self.payments_path + '/addop') 156 168 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 157 self.browser.getControl("Create ticket").click()158 self.assertMatches('...ticket created...',159 self.browser.contents)160 # In state returning we can add a new school fee ticket since161 # p_session and p_level is different162 IWorkflowState(self.student).setState('returning')163 self.browser.open(self.payments_path + '/addop')164 self.browser.getControl(name="form.p_category").value = ['schoolfee']165 self.browser.getControl("Create ticket").click()166 # Uups, we forgot to add a session configuration for next session167 self.assertTrue('Session configuration object is not available.'168 in self.browser.contents)169 configuration = createObject('waeup.SessionConfiguration')170 configuration.academic_session = 2005171 self.app['configuration'].addSessionConfiguration(configuration)172 169 self.browser.getControl("Create ticket").click() 173 170 self.assertMatches('...ticket created...', … … 222 219 self.assertEqual(pt_ft(self.student), 'ft') 223 220 221 error, payment = utils.setPaymentDetails('schoolfee',self.student) 222 self.assertEqual(error, 223 'Book and pay for accommodation first before making' 224 ' school fee payments.') 225 # We add a fake maint. payment ticket to meet the condition 226 maint_payment = createObject('waeup.StudentOnlinePayment') 227 self.student['payments']['any_key'] = maint_payment 228 maint_payment.p_category = 'hostel_maintenance' 229 maint_payment.p_state = 'paid' 230 maint_payment.p_session = 2004 224 231 error, payment = utils.setPaymentDetails('schoolfee',self.student) 225 232 self.assertEqual(payment.p_level, 100) -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/utils.py
r10672 r10675 20 20 from time import time 21 21 from zope.component import createObject, getUtility 22 from zope.catalog.interfaces import ICatalog 22 23 from waeup.kofa.interfaces import CLEARED, RETURNING, PAID 23 24 from kofacustom.nigeria.students.utils import NigeriaStudentsUtils … … 25 26 from waeup.kofa.interfaces import CLEARED, RETURNING, IKofaUtils 26 27 from waeup.kofa.fees import FeeTable 28 from waeup.kofa.hostels.hostel import NOT_OCCUPIED 27 29 from waeup.kwarapoly.interfaces import MessageFactory as _ 28 30 … … 124 126 new_session = student['studycourse'].current_session + 1 125 127 return new_session, new_level 128 129 def _maintPaymentMade(self, student, session): 130 if len(student['payments']): 131 for ticket in student['payments'].values(): 132 if ticket.p_category == 'hostel_maintenance' and \ 133 ticket.p_session == session and ticket.p_state == 'paid': 134 return True 135 return False 136 137 def _bedAvailable(self, student): 138 acc_details = self.getAccommodationDetails(student) 139 cat = getUtility(ICatalog, name='beds_catalog') 140 entries = cat.searchResults( 141 owner=(student.student_id,student.student_id)) 142 if len(entries): 143 # Bed has already been booked. 144 return True 145 entries = cat.searchResults( 146 bed_type=(acc_details['bt'],acc_details['bt'])) 147 available_beds = [ 148 entry for entry in entries if entry.owner == NOT_OCCUPIED] 149 if available_beds: 150 # Bed has not yet been booked but beds are available. 151 return True 152 return False 126 153 127 154 def setPaymentDetails(self, category, student, … … 170 197 if academic_session == None: 171 198 return _(u'Session configuration object is not available.'), None 199 if student.state == CLEARED: 200 # Fresh students must have booked and paid for accommodation. 201 if self._bedAvailable(student): 202 if not self._maintPaymentMade(student, p_session): 203 return _('Book and pay for accommodation first ' 204 'before making school fee payments.'), None 172 205 if student.state in (RETURNING, CLEARED): 173 206 if p_level in PAYMENT_LEVELS:
Note: See TracChangeset for help on using the changeset viewer.