- Timestamp:
- 4 Nov 2012, 07:48:11 (12 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py
r9515 r9520 97 97 self.browser.contents) 98 98 99 # Create school fee ticket for returning students 99 # Create school fee ticket for returning students. Payment is made 100 # for next session. 101 current_payment_key = self.student['payments'].keys()[0] 100 102 self.certificate.study_mode = u'ug_pt' 101 103 IWorkflowState(self.student).setState('returning') … … 103 105 configuration.academic_session = 2005 104 106 self.app['configuration'].addSessionConfiguration(configuration) 107 self.browser.open(self.payments_path + '/addop') 108 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 109 self.browser.getControl("Create ticket").click() 110 # Next session payment can't be made ... 111 self.assertMatches( 112 '...You have not yet paid your current/active session...', 113 self.browser.contents) 114 # current session payment must be approved first. 115 self.student['payments'][current_payment_key].approve() 105 116 self.browser.open(self.payments_path + '/addop') 106 117 self.browser.getControl(name="form.p_category").value = ['schoolfee'] -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r9513 r9520 214 214 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 215 215 self.browser.open(self.payments_path) 216 self.browser.get Control("Add onlinepayment ticket").click()216 self.browser.getLink("Add current session payment ticket").click() 217 217 self.browser.getControl("Create ticket").click() 218 218 self.assertMatches('...Amount could not be determined...', … … 248 248 self.assertMatches('...ticket created...', 249 249 self.browser.contents) 250 schoolfee_ticket = self.student['payments'].values()[0] 250 251 self.browser.open(self.payments_path + '/addop') 251 252 self.browser.getControl(name="form.p_category").value = ['gown'] … … 286 287 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 287 288 self.browser.getControl("Create ticket").click() 289 # Uups, we forgot to add a session configuration for next session 288 290 self.assertMatches('...Session configuration object is not...', 289 291 self.browser.contents) 290 # Uups, we forgot to add a session configuration for next session291 292 configuration = createObject('waeup.SessionConfiguration') 292 293 configuration.academic_session = 2005 293 294 self.app['configuration'].addSessionConfiguration(configuration) 295 self.browser.open(self.payments_path + '/addop') 296 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 297 self.browser.getControl("Create ticket").click() 298 self.assertMatches('...You have not yet paid your current/active session...', 299 self.browser.contents) 300 # Ok, let's pay the first schoolfee ticket. 301 schoolfee_ticket.approve() 294 302 self.browser.open(self.payments_path + '/addop') 295 303 self.browser.getControl(name="form.p_category").value = ['schoolfee'] … … 309 317 del self.app['configuration']['2004'] 310 318 self.browser.open(self.payments_path) 311 self.browser.get Control("Add onlinepayment ticket").click()319 self.browser.getLink("Add current session payment ticket").click() 312 320 self.browser.getControl("Create ticket").click() 313 321 self.assertMatches('...Session configuration object is not...', … … 375 383 self.student, None, None) 376 384 self.assertEqual(payment, None) 385 # Student is in state 'created' and can thus not pay. 377 386 self.assertTrue(u'Amount could not be determined.' in error) 378 387 … … 383 392 self.assertTrue(u'The previous session must not fall below' in error) 384 393 error, payment = utils.setPaymentDetails('schoolfee', 385 self.student, 200 4, 300)394 self.student, 2005, 300) 386 395 self.assertEqual(payment, None) 387 396 self.assertTrue(u'This is not a previous session' in error) 388 397 389 # Previous session payment; fresh and returning398 # Previous session schoolfee payment; fresh and returning 390 399 # are distinguished by their entry_level 391 400 error, payment = utils.setPaymentDetails('schoolfee', … … 402 411 self.assertFalse(payment.p_current) 403 412 404 # Current payment; fresh and returning413 # Current schoolfee payment; fresh and returning 405 414 # are distinguished by their state 406 415 IWorkflowState(self.student).setState('cleared') … … 426 435 error, payment = utils.setPaymentDetails('schoolfee', 427 436 self.student, None, None) 437 self.assertTrue( 438 u'You have not yet paid your current/active session.' in error) 439 # Ok, that means we have to add paid payment ticket first. 440 payment = createObject('waeup.StudentOnlinePayment') 441 payment.p_category = u'schoolfee' 442 payment.p_session = self.student.current_session 443 payment.p_item = u'My Certificate' 444 payment.p_id = u'anyid' 445 payment.p_state = u'paid' 446 self.student['payments']['anykey'] = payment 447 error, payment = utils.setPaymentDetails('schoolfee', 448 self.student, None, None) 428 449 self.assertEqual(payment.p_level, 200) 429 450 self.assertEqual(payment.p_session, 2005) … … 431 452 self.assertEqual(payment.p_item, u'CERT1') 432 453 self.assertEqual(error, None) 454 455 # Staff members pay less. 433 456 self.student.is_staff = True 434 457 error, payment = utils.setPaymentDetails('schoolfee', … … 440 463 self.assertEqual(error, None) 441 464 465 # Foreigners pay more. 442 466 IWorkflowState(self.student).setState('cleared') 443 467 self.student.is_staff = False … … 451 475 self.assertEqual(payment.p_item, u'CERT1') 452 476 self.assertEqual(error, None) 453 454 477 IWorkflowState(self.student).setState('returning') 455 478 self.student.is_staff = False 456 self.student.nationality = u'DE'457 479 self.certificate.school_fee_4 = 20000.0 458 480 error, payment = utils.setPaymentDetails( … … 467 489 # if they are ug or pg students. 468 490 IWorkflowState(self.student).setState('school fee paid') 469 self.certificate.study_mode = 'special_pg_pt'470 491 self.student.is_staff = False 471 492 self.student.nationality = u'NG' 472 493 self.certificate.school_fee_2 = 10000.0 473 494 error, payment = utils.setPaymentDetails( 495 'schoolfee', self.student, None, None) 496 self.assertEqual(payment.p_level, None) 497 self.assertEqual(payment.p_session, 2005) 498 self.assertEqual(payment.amount_auth, 10088.0) 499 self.assertEqual(payment.p_item, u'CERT1') 500 self.assertEqual(error, None) 501 IWorkflowState(self.student).setState('courses registered') 502 self.certificate.study_mode = 'special_pg_pt' 474 503 error, payment = utils.setPaymentDetails( 475 504 'schoolfee', self.student, None, None) … … 479 508 self.assertEqual(payment.p_item, u'CERT1') 480 509 self.assertEqual(error, None) 481 482 IWorkflowState(self.student).setState('courses registered')483 error, payment = utils.setPaymentDetails(484 'schoolfee', self.student, None, None)485 self.assertEqual(payment.p_level, None)486 self.assertEqual(payment.p_session, 2005)487 self.assertEqual(payment.amount_auth, 10000.0)488 self.assertEqual(payment.p_item, u'CERT1')489 self.assertEqual(error, None)490 491 510 IWorkflowState(self.student).setState('courses validated') 492 511 error, payment = utils.setPaymentDetails( -
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r9513 r9520 53 53 return new_session, new_level 54 54 55 def _paymentMade(self, student, session): 56 if len(student['payments']): 57 for ticket in student['payments'].values(): 58 if ticket.p_state == 'paid' and \ 59 ticket.p_category == 'schoolfee' and \ 60 ticket.p_session == session: 61 return True 62 return False 63 55 64 def setPaymentDetails(self, category, student, 56 65 previous_session, previous_level): … … 59 68 60 69 """ 61 details = {}62 70 p_item = u'' 63 71 amount = 0.0 64 error = u''65 72 if previous_session: 73 if previous_session < student['studycourse'].entry_session: 74 return _('The previous session must not fall below ' 75 'your entry session.'), None 76 if category == 'schoolfee': 77 # School fee is always paid for the following session 78 if previous_session > student['studycourse'].current_session: 79 return _('This is not a previous session.'), None 80 else: 81 if previous_session > student['studycourse'].current_session - 1: 82 return _('This is not a previous session.'), None 66 83 p_session = previous_session 67 84 p_level = previous_level … … 71 88 p_level = student['studycourse'].current_level 72 89 p_current = True 73 session = str(p_session) 74 try: 75 academic_session = grok.getSite()['configuration'][session] 76 except KeyError: 90 academic_session = self._getSessionConfiguration(p_session) 91 if academic_session == None: 77 92 return _(u'Session configuration object is not available.'), None 78 93 # Determine fee. … … 105 120 return _('Study course data are incomplete.'), None 106 121 if previous_session: 107 if previous_session < student['studycourse'].entry_session: 108 return _('The previous session must not fall below ' 109 'your entry session.'), None 110 if previous_session > student['studycourse'].current_session - 1: 111 return _('This is not a previous session.'), None 122 # Students can pay for previous sessions in all workflow states. 123 # Fresh students are excluded by the update method of the 124 # PreviousPaymentAddFormPage. 112 125 if previous_session == student['studycourse'].entry_session: 113 126 if student.is_foreigner: … … 127 140 amount = getattr(certificate, 'school_fee_1', 0.0) 128 141 elif student.state in (PAID, REGISTERED, VALIDATED): 129 # Students are either postgraduate or are paying in advance.130 # Both are paying for next session.131 142 p_session += 1 132 143 # We don't know which level the student is paying for. 133 144 p_level = None 134 try: 135 academic_session = grok.getSite()[ 136 'configuration'][str(p_session)] 137 except KeyError: 145 academic_session = self._getSessionConfiguration(p_session) 146 if academic_session == None: 138 147 return _(u'Session configuration object is not available.'), None 148 # Students are only allowed to pay for the next session 149 # if current session payment 150 # has really been made, i.e. payment object exists. 151 if not self._paymentMade( 152 student, student.current_session): 153 return _('You have not yet paid your current/active' + 154 ' session. Please use the previous session' + 155 ' payment form first.'), None 139 156 if student.is_foreigner: 140 157 amount = getattr(certificate, 'school_fee_4', 0.0) … … 146 163 # has paid for. 147 164 p_session, p_level = self.getReturningData(student) 148 try: 149 academic_session = grok.getSite()[ 150 'configuration'][str(p_session)] 151 except KeyError: 165 academic_session = self._getSessionConfiguration(p_session) 166 if academic_session == None: 152 167 return _(u'Session configuration object is not available.'), None 168 # Students are only allowed to pay for the next session 169 # if current session payment has really been made, 170 # i.e. payment object exists and is paid. 171 if not self._paymentMade( 172 student, student.current_session): 173 return _('You have not yet paid your current/active' + 174 ' session. Please use the previous session' + 175 ' payment form first.'), None 153 176 if student.is_foreigner: 154 177 amount = getattr(certificate, 'school_fee_4', 0.0) … … 159 182 amount /= 2 160 183 if amount in (0.0, None): 161 return _('Amount could not be determined.' + 162 ' Would you like to pay for a previous session?'), None 184 return _('Amount could not be determined.'), None 163 185 # Add session specific penalty fee. 164 186 if category == 'schoolfee' and student.is_postgrad: … … 173 195 ticket.p_item == p_item and \ 174 196 ticket.p_session == p_session: 175 return _('This type of payment has already been made.' + 176 ' Would you like to pay for a previous session?'), None 197 return _('This type of payment has already been made.'), None 177 198 payment = createObject(u'waeup.StudentOnlinePayment') 178 199 timestamp = ("%d" % int(time()*10000))[1:]
Note: See TracChangeset for help on using the changeset viewer.