Changeset 8600 for main/waeup.aaue/trunk/src/waeup/aaue/students
- Timestamp:
- 2 Jun 2012, 08:12:18 (13 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r8444 r8600 178 178 form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( 179 179 'p_category') 180 factory = u'waeup.CustomStudentOnlinePayment'181 182 def _fillCustomFields(self, payment, pay_details):183 # No custom fields at the moment184 return payment185 180 186 181 class CustomOnlinePaymentFakeApprovePage(OnlinePaymentFakeApprovePage): -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r8505 r8600 30 30 from waeup.aaue.students.batching import CustomStudentProcessor 31 31 from waeup.aaue.testing import FunctionalLayer 32 from waeup.aaue.students.utils import get_school_fee33 32 from waeup.aaue.students.interfaces import ( 34 33 ICustomStudentStudyCourse, ICustomStudent, … … 303 302 return 304 303 305 def test_get_schoolfee(self): 306 self.assertEqual(get_school_fee(self.student),0.0) 307 IWorkflowState(self.student).setState('cleared') 308 self.assertEqual(get_school_fee(self.student),40000.0) 309 IWorkflowState(self.student).setState('returning') 310 self.assertEqual(get_school_fee(self.student),20000.0) 311 return 312 313 def test_get_payment_details(self): 304 def test_set_payment_details(self): 314 305 self.app['configuration']['2004'].gown_fee = 150.0 315 306 self.app['configuration']['2004'].transfer_fee = 90.0 316 307 self.app['configuration']['2004'].booking_fee = 150.0 317 308 self.app['configuration']['2004'].maint_fee = 180.0 318 self.app['configuration']['2004'].clearance_fee = 360.0319 309 utils = getUtility(IStudentsUtils) 320 self.assertEqual(utils.getPaymentDetails('schoolfee',self.student), 321 {'p_level': 100, 'p_session': 2004, 'amount': 0.0, 322 'p_item': u'CERT1', 'error': u'Amount could not be determined.'} 323 ) 324 self.assertEqual(utils.getPaymentDetails('clearance',self.student), 325 {'p_level': 100, 'p_session': 2004, 'amount': 360.0, 326 'p_item': u'CERT1', 'error': u''} 327 ) 328 self.assertEqual(utils.getPaymentDetails('gown',self.student), 329 {'p_level': 100, 'p_session': 2004, 'amount': 150.0, 330 'p_item': u'', 'error': u''} 331 ) 332 self.assertEqual(utils.getPaymentDetails('hostel_maintenance',self.student), 333 {'p_level': 100, 'p_session': 2004, 'amount': 180.0, 334 'p_item': u'', 'error': u''} 335 ) 336 self.assertEqual(utils.getPaymentDetails('bed_allocation',self.student), 337 {'p_level': 100, 'p_session': 2004, 'amount': 150.0, 338 'p_item': u'', 'error': u''} 339 ) 340 self.assertEqual(utils.getPaymentDetails('transfer',self.student), 341 {'p_level': 100, 'p_session': 2004, 'amount': 90.0, 342 'p_item': u'', 'error': u''} 343 ) 310 311 error, payment = utils.setPaymentDetails('schoolfee',self.student) 312 self.assertEqual(payment, None) 313 self.assertEqual(error, u'Amount could not be determined.') 314 315 IWorkflowState(self.student).setState('cleared') 316 error, payment = utils.setPaymentDetails('schoolfee',self.student) 317 self.assertEqual(payment.p_level, 100) 318 self.assertEqual(payment.p_session, 2004) 319 self.assertEqual(payment.amount_auth, 40000.0) 320 self.assertEqual(payment.p_item, u'CERT1') 321 self.assertEqual(error, None) 322 323 IWorkflowState(self.student).setState('returning') 324 error, payment = utils.setPaymentDetails('schoolfee',self.student) 325 self.assertEqual(payment.p_level, 200) 326 self.assertEqual(payment.p_session, 2005) 327 self.assertEqual(payment.amount_auth, 20000.0) 328 self.assertEqual(payment.p_item, u'CERT1') 329 self.assertEqual(error, None) 330 331 error, payment = utils.setPaymentDetails('clearance',self.student) 332 self.assertEqual(payment.p_level, 100) 333 self.assertEqual(payment.p_session, 2004) 334 self.assertEqual(payment.amount_auth, 34250.0) 335 self.assertEqual(payment.p_item, u'CERT1') 336 self.assertEqual(error, None) 337 338 error, payment = utils.setPaymentDetails('gown',self.student) 339 self.assertEqual(payment.p_level, 100) 340 self.assertEqual(payment.p_session, 2004) 341 self.assertEqual(payment.amount_auth, 150.0) 342 self.assertEqual(payment.p_item, u'') 343 self.assertEqual(error, None) 344 345 error, payment = utils.setPaymentDetails('hostel_maintenance',self.student) 346 self.assertEqual(payment.p_level, 100) 347 self.assertEqual(payment.p_session, 2004) 348 self.assertEqual(payment.amount_auth, 180.0) 349 self.assertEqual(payment.p_item, u'') 350 self.assertEqual(error, None) 351 352 error, payment = utils.setPaymentDetails('bed_allocation',self.student) 353 self.assertEqual(payment.p_level, 100) 354 self.assertEqual(payment.p_session, 2004) 355 self.assertEqual(payment.amount_auth, 150.0) 356 self.assertEqual(payment.p_item, u'') 357 self.assertEqual(error, None) 358 359 error, payment = utils.setPaymentDetails('transfer',self.student) 360 self.assertEqual(payment.p_level, 100) 361 self.assertEqual(payment.p_session, 2004) 362 self.assertEqual(payment.amount_auth, 90.0) 363 self.assertEqual(payment.p_item, u'') 364 self.assertEqual(error, None) 344 365 return -
main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
r8505 r8600 17 17 ## 18 18 import grok 19 from time import time 20 from zope.component import createObject 19 21 from waeup.kofa.interfaces import CLEARED, RETURNING, PAID 20 22 from waeup.kofa.students.utils import StudentsUtils … … 23 25 from waeup.aaue.interfaces import MessageFactory as _ 24 26 25 def get_school_fee(student):26 state = student.state27 fee = None28 if state == CLEARED:29 fee = getattr(student['studycourse'].certificate,'school_fee_1')30 elif state == RETURNING:31 fee = getattr(student['studycourse'].certificate,'school_fee_2')32 if fee is not None:33 return fee34 return 0.035 36 27 class CustomStudentsUtils(StudentsUtils): 37 28 """A collection of customized methods. … … 39 30 """ 40 31 grok.implements(IStudentsUtils) 32 33 paymentfactory = u'waeup.CustomStudentOnlinePayment' 41 34 42 35 def getReturningData(self, student): … … 59 52 return new_session, new_level 60 53 61 def getPaymentDetails(self, category, student): 54 def setPaymentDetails(self, category, student): 55 """Create Payment object and set the payment data of a student for 56 the payment category specified. 57 58 """ 62 59 details = {} 63 details['p_item']= u''64 details['amount']= 0.065 details['error']= u''66 details['p_session']= student['studycourse'].current_session67 session = str(details['p_session'])68 details['p_level'] = student['studycourse'].current_level60 p_item = u'' 61 amount = 0.0 62 error = u'' 63 p_session = student['studycourse'].current_session 64 p_level = student['studycourse'].current_level 65 session = str(p_session) 69 66 try: 70 67 academic_session = grok.getSite()['configuration'][session] 71 68 except KeyError: 72 details['error'] = _(u'Session configuration object is not available.') 73 return details 69 return _(u'Session configuration object is not available.'), None 74 70 if category == 'transfer': 75 details['amount']= academic_session.transfer_fee71 amount = academic_session.transfer_fee 76 72 elif category == 'gown': 77 details['amount']= academic_session.gown_fee73 amount = academic_session.gown_fee 78 74 elif category == 'bed_allocation': 79 details['amount']= academic_session.booking_fee75 amount = academic_session.booking_fee 80 76 elif category == 'hostel_maintenance': 81 details['amount']= academic_session.maint_fee77 amount = academic_session.maint_fee 82 78 elif category == 'clearance': 83 details['p_item'] = student['studycourse'].certificate.code 84 details['amount'] = academic_session.clearance_fee 79 try: 80 p_item = student['studycourse'].certificate.code 81 except (AttributeError, TypeError): 82 return _('Study course data are incomplete.'), None 83 if p_item in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET', 84 'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'): 85 amount = 17250.0 86 else: 87 amount = 34250.0 85 88 elif category == 'schoolfee': 86 details['amount'] = get_school_fee(student) 87 code = student['studycourse'].certificate.code 88 details['p_item'] = code 89 if student.state == RETURNING: 89 try: 90 certificate = student['studycourse'].certificate 91 p_item = certificate.code 92 except (AttributeError, TypeError): 93 return _('Study course data are incomplete.'), None 94 if student.state == CLEARED: 95 amount = getattr(certificate, 'school_fee_1', 0.0) 96 elif student.state == RETURNING: 90 97 # In case of returning school fee payment the payment session 91 98 # and level contain the values of the session the student 92 99 # has paid for. 93 details['p_session'], details['p_level'] = self.getReturningData(student) 94 elif student.current_mode.startswith('pg') and student.state == PAID: 100 p_session, p_level = self.getReturningData(student) 101 amount = getattr(certificate, 'school_fee_2', 0.0) 102 elif student.is_postgrad and student.state == PAID: 95 103 # Returning postgraduate students also pay for the next session 96 104 # but their level always remains the same. 97 details['p_session'] += 1 98 details['amount'] = getattr( 99 student['studycourse'].certificate,'school_fee_2') 100 if details['amount'] in (0.0, None): 101 details['error'] = _(u'Amount could not be determined.') 102 return details 105 p_session += 1 106 amount = getattr(certificate, 'school_fee_2', 0.0) 107 if amount in (0.0, None): 108 return _(u'Amount could not be determined.'), None 109 for key in student['payments'].keys(): 110 ticket = student['payments'][key] 111 if ticket.p_state == 'paid' and\ 112 ticket.p_category == category and \ 113 ticket.p_item == p_item and \ 114 ticket.p_session == p_session: 115 return _('This type of payment has already been made.'), None 116 payment = createObject(self.paymentfactory) 117 timestamp = "%d" % int(time()*1000) 118 payment.p_id = "p%s" % timestamp 119 payment.p_category = category 120 payment.p_item = p_item 121 payment.p_session = p_session 122 payment.p_level = p_level 123 payment.amount_auth = amount 124 return None, payment 103 125 104 126 VERDICTS_DICT = {
Note: See TracChangeset for help on using the changeset viewer.