Changeset 9148
- Timestamp:
- 3 Sep 2012, 14:47:24 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9141 r9148 55 55 IStudentAccommodation, IStudentStudyLevel, 56 56 ICourseTicket, ICourseTicketAdd, IStudentPaymentsContainer, 57 IStudentOnlinePayment, IBedTicket, IStudentsUtils, IStudentRequestPW 57 IStudentOnlinePayment, IStudentPreviousPayment, 58 IBedTicket, IStudentsUtils, IStudentRequestPW 58 59 ) 59 60 from waeup.kofa.students.catalog import search … … 1213 1214 def createTicket(self, **data): 1214 1215 p_category = data['p_category'] 1216 previous_session = data.get('p_session', None) 1217 previous_level = data.get('p_level', None) 1215 1218 student = self.context.__parent__ 1216 1219 if p_category == 'bed_allocation' and student[ … … 1223 1226 return 1224 1227 students_utils = getUtility(IStudentsUtils) 1225 error, payment = students_utils.setPaymentDetails(p_category, student) 1228 error, payment = students_utils.setPaymentDetails( 1229 p_category, student, previous_session, previous_level) 1226 1230 if error is not None: 1227 1231 self.flash(error) 1232 if 'Would you like' in error: 1233 self.redirect(self.url(self.context) + '/@@addpp') 1234 return 1228 1235 self.redirect(self.url(self.context)) 1229 1236 return … … 1232 1239 self.redirect(self.url(self.context)) 1233 1240 return 1241 1242 class PreviousPaymentAddFormPage(OnlinePaymentAddFormPage): 1243 """ Page to add an online payment ticket for previous sessions 1244 """ 1245 grok.context(IStudentPaymentsContainer) 1246 grok.name('addpp') 1247 grok.require('waeup.payStudent') 1248 form_fields = grok.AutoFields(IStudentPreviousPayment).select( 1249 'p_category', 'p_session', 'p_level') 1250 label = _('Add previous session online payment') 1251 pnav = 4 1234 1252 1235 1253 class OnlinePaymentDisplayFormPage(KofaDisplayFormPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r9142 r9148 66 66 """ 67 67 68 def setPaymentDetails(category, student): 68 def setPaymentDetails(category, student, previous_session=None, 69 previous_level=None,): 69 70 """Create Payment object and set the payment data of a student for 70 71 the payment category specified. … … 560 561 """ 561 562 563 p_current = schema.Bool( 564 title = _(u'Current Session Payment'), 565 default = True, 566 required = False, 567 readonly = True, 568 ) 569 562 570 p_level = schema.Int( 563 571 title = _(u'Payment Level'), … … 583 591 IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[ 584 592 'p_session'].order 593 594 class IStudentPreviousPayment(IOnlinePayment): 595 """An interface for adding previous session payments. 596 597 """ 598 599 p_session = schema.Choice( 600 title = _(u'Payment Session'), 601 source = academic_sessions_vocab, 602 required = True, 603 ) 604 605 p_level = schema.Choice( 606 title = _(u'Payment Level'), 607 source = StudyLevelSource(), 608 required = True, 609 ) 585 610 586 611 class ICSVStudentExporter(ICSVExporter): -
main/waeup.kofa/trunk/src/waeup/kofa/students/payments.py
r8736 r9148 97 97 """Process student after payment was made. 98 98 """ 99 error = self._createActivationCodes() 100 if error is not None: 101 return False, error, error 99 if self.p_current: 100 error = self._createActivationCodes() 101 if error is not None: 102 return False, error, error 102 103 log = 'successful payment: %s' % self.p_id 103 104 msg = _('Successful payment') … … 107 108 """Process student after payment was approved. 108 109 """ 109 error = self._createActivationCodes() 110 if error is not None: 111 return False, error, error 110 if self.p_current: 111 error = self._createActivationCodes() 112 if error is not None: 113 return False, error, error 112 114 log = 'payment approved: %s' % self.p_id 113 115 msg = _('Payment approved') -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9139 r9148 1575 1575 return 1576 1576 1577 def test_postgraduate_payments(self): 1577 def test_student_previous_payments(self): 1578 # Login 1579 self.browser.open(self.login_path) 1580 self.browser.getControl(name="form.login").value = self.student_id 1581 self.browser.getControl(name="form.password").value = 'spwd' 1582 self.browser.getControl("Login").click() 1583 1584 # Students can add previous school fee payment tickets in any state. 1585 IWorkflowState(self.student).setState('courses registered') 1586 self.browser.open(self.payments_path) 1587 self.browser.getControl("Add online payment ticket").click() 1588 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 1589 self.browser.getControl("Create ticket").click() 1590 1591 # Amount cannot be determined since the state is not 1592 # 'cleared' or 'returning' 1593 self.assertMatches('...Amount could not be determined...', 1594 self.browser.contents) 1595 self.assertMatches('...Would you like to pay for a previous session?...', 1596 self.browser.contents) 1597 1598 # Previous session payment form is provided 1599 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 1600 self.browser.getControl(name="form.p_session").value = ['2004'] 1601 self.browser.getControl(name="form.p_level").value = ['300'] 1602 self.browser.getControl("Create ticket").click() 1603 self.assertMatches('...ticket created...', 1604 self.browser.contents) 1605 ctrl = self.browser.getControl(name='val_id') 1606 value = ctrl.options[0] 1607 self.browser.getLink(value).click() 1608 self.assertMatches('...Amount Authorized...', 1609 self.browser.contents) 1610 self.assertEqual(self.student['payments'][value].amount_auth, 20000.0) 1611 1612 # Payment session is properly set 1613 self.assertEqual(self.student['payments'][value].p_session, 2004) 1614 self.assertEqual(self.student['payments'][value].p_level, 300) 1615 1616 # We simulate the approval 1617 self.browser.open(self.browser.url + '/fake_approve') 1618 self.assertMatches('...Payment approved...', 1619 self.browser.contents) 1620 1621 # No AC has been created 1622 self.assertEqual(len(self.app['accesscodes']['SFE-0'].keys()), 0) 1623 self.assertTrue(self.student['payments'][value].ac is None) 1624 1625 # Current payment flag is set False 1626 self.assertFalse(self.student['payments'][value].p_current) 1627 return 1628 1629 def test_student_postgraduate_payments(self): 1578 1630 self.certificate.study_mode = 'pg_ft' 1579 1631 self.certificate.start_level = 999 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r9028 r9148 371 371 self.assertEqual( 372 372 result, 373 'ac,amount_auth,creation_date,p_category,p_ id,'373 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 374 374 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 375 375 'r_code,r_desc,student_id\r\n' 376 376 377 ',0.0,2012-04-01 13:12:01,schoolfee, ,,,,unpaid,,0.0,,,\r\n'377 ',0.0,2012-04-01 13:12:01,schoolfee,1,,,,,unpaid,,0.0,,,\r\n' 378 378 ) 379 379 return … … 389 389 self.assertEqual( 390 390 result, 391 'ac,amount_auth,creation_date,p_category,p_ id,'391 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 392 392 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 393 393 'r_code,r_desc,student_id\r\n' 394 394 395 '666,0.0,2012-04-01 13:12:01,schoolfee, my-id,'395 '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' 396 396 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' 397 397 'r-code,,A111111\r\n' … … 408 408 self.assertEqual( 409 409 result, 410 'ac,amount_auth,creation_date,p_category,p_ id,'410 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 411 411 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 412 412 'r_code,r_desc,student_id\r\n' 413 413 414 '666,0.0,2012-04-01 13:12:01,schoolfee, my-id,'414 '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' 415 415 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' 416 416 'r-code,,A111111\r\n' … … 427 427 self.assertEqual( 428 428 result, 429 'ac,amount_auth,creation_date,p_category,p_ id,'429 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 430 430 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 431 431 'r_code,r_desc,student_id\r\n' 432 432 433 '666,0.0,2012-04-01 13:12:01,schoolfee, my-id,'433 '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' 434 434 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' 435 435 'r-code,,A111111\r\n' -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r9141 r9148 281 281 return 282 282 283 def setPaymentDetails(self, category, student): 283 def setPaymentDetails(self, category, student, 284 previous_session=None, previous_level=None): 284 285 """Create Payment object and set the payment data of a student for 285 286 the payment category specified. … … 288 289 p_item = u'' 289 290 amount = 0.0 290 p_session = student['studycourse'].current_session 291 p_level = student['studycourse'].current_level 291 if previous_session: 292 p_session = previous_session 293 p_level = previous_level 294 p_current = False 295 else: 296 p_session = student['studycourse'].current_session 297 p_level = student['studycourse'].current_level 298 p_current = True 292 299 session = str(p_session) 293 300 try: … … 301 308 except (AttributeError, TypeError): 302 309 return _('Study course data are incomplete.'), None 303 if student.state == CLEARED: 304 amount = getattr(certificate, 'school_fee_1', 0.0) 305 elif student.state == RETURNING: 306 # In case of returning school fee payment the payment session 307 # and level contain the values of the session the student 308 # has paid for. 309 p_session, p_level = self.getReturningData(student) 310 amount = getattr(certificate, 'school_fee_2', 0.0) 311 elif student.is_postgrad and student.state == PAID: 312 # Returning postgraduate students also pay for the next session 313 # but their level always remains the same. 314 p_session += 1 315 amount = getattr(certificate, 'school_fee_2', 0.0) 310 if previous_session: 311 if previous_level == 100: 312 amount = getattr(certificate, 'school_fee_1', 0.0) 313 else: 314 amount = getattr(certificate, 'school_fee_2', 0.0) 315 else: 316 if student.state == CLEARED: 317 amount = getattr(certificate, 'school_fee_1', 0.0) 318 elif student.state == RETURNING: 319 # In case of returning school fee payment the payment session 320 # and level contain the values of the session the student 321 # has paid for. 322 p_session, p_level = self.getReturningData(student) 323 amount = getattr(certificate, 'school_fee_2', 0.0) 324 elif student.is_postgrad and student.state == PAID: 325 # Returning postgraduate students also pay for the next session 326 # but their level always remains the same. 327 p_session += 1 328 amount = getattr(certificate, 'school_fee_2', 0.0) 316 329 elif category == 'clearance': 317 330 p_item = student['studycourse'].certificate.code … … 321 334 amount = academic_session.booking_fee 322 335 if amount in (0.0, None): 323 return _(u'Amount could not be determined.'), None 336 return _('Amount could not be determined.' + 337 ' Would you like to pay for a previous session?'), None 324 338 for key in student['payments'].keys(): 325 339 ticket = student['payments'][key] … … 328 342 ticket.p_item == p_item and \ 329 343 ticket.p_session == p_session: 330 return _('This type of payment has already been made.'), None 344 return _('This type of payment has already been made.' + 345 ' Would you like to pay for a previous session?'), None 331 346 payment = createObject(u'waeup.StudentOnlinePayment') 332 347 timestamp = ("%d" % int(time()*10000))[1:] … … 336 351 payment.p_session = p_session 337 352 payment.p_level = p_level 353 payment.p_current = p_current 338 354 payment.amount_auth = amount 339 355 return None, payment … … 358 374 return 359 375 end_level = certificate.end_level 360 if entry_session == grok.getSite()['hostels'].accommodation_session: 376 if current_level == 10: 377 bt = 'pr' 378 elif entry_session == grok.getSite()['hostels'].accommodation_session: 361 379 bt = 'fr' 362 380 elif current_level >= end_level:
Note: See TracChangeset for help on using the changeset viewer.