- Timestamp:
- 18 Jun 2012, 17:00:00 (13 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/interfaces.py
r8712 r8753 97 97 98 98 school_fee_base = schema.Float( 99 title = _(u'School Fee (ignored)'),99 title = _(u'School Fee Instalments'), 100 100 default = 0.0, 101 101 required = False, -
main/waeup.aaue/trunk/src/waeup/aaue/payments/interfaces.py
r8682 r8753 19 19 from zope import schema 20 20 from waeup.kofa.payments.interfaces import IPayment 21 from waeup.kofa.interfaces import SimpleKofaVocabulary 21 22 from waeup.kofa.interfaces import MessageFactory as _ 23 24 payment_categories = SimpleKofaVocabulary( 25 (_('School Fee 1st instalment'),'schoolfee_1'), 26 (_('School Fee 2nd instalment'),'schoolfee_2'), 27 (_('Clearance'),'clearance'), 28 (_('Bed Allocation'),'bed_allocation'), 29 (_('Hostel Maintenance'),'hostel_maintenance'), 30 (_('Transfer'),'transfer'), 31 (_('Gown'),'gown'), 32 (_('Application Fee'), 'application'), 33 ) 22 34 23 35 class ICustomOnlinePayment(IPayment): … … 25 37 26 38 """ 39 40 p_category = schema.Choice( 41 title = _(u'Payment Category'), 42 default = u'schoolfee_1', 43 vocabulary = payment_categories, 44 required = True, 45 ) 27 46 28 47 ac = schema.TextLine( … … 76 95 readonly = False, 77 96 ) 97 98 ICustomOnlinePayment['p_category'].order = ICustomOnlinePayment[ 99 'p_category'].order -
main/waeup.aaue/trunk/src/waeup/aaue/students/payments.py
r8746 r8753 27 27 from waeup.kofa.utils.helpers import attrs_to_fields 28 28 from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment 29 from waeup.aaue.payments.interfaces import payment_categories 29 30 30 31 class CustomStudentOnlinePayment(StudentOnlinePayment): … … 47 48 return self.__parent__.__parent__ 48 49 50 @property 51 def category(self): 52 return payment_categories.getTermByToken(self.p_category).title 53 49 54 CustomStudentOnlinePayment = attrs_to_fields(CustomStudentOnlinePayment) 50 55 -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r8723 r8753 194 194 self.browser.getControl("Add online payment ticket").click() 195 195 self.browser.getControl("Create ticket").click() 196 self.assertMatches('...Wrong state...', 197 self.browser.contents) 198 IWorkflowState(self.student).setState('cleared') 199 self.browser.open(self.payments_path + '/addop') 200 self.browser.getControl("Create ticket").click() 196 201 self.assertMatches('...Amount could not be determined...', 197 202 self.browser.contents) 198 IWorkflowState(self.student).setState('cleared') 199 self.browser.open(self.payments_path + '/addop') 203 204 self.app['configuration']['2004'].school_fee_base = 6666.0 205 206 self.browser.getControl("Add online payment ticket").click() 200 207 self.browser.getControl("Create ticket").click() 201 208 self.assertMatches('...ticket created...', … … 217 224 self.assertMatches('...This type of payment has already been made...', 218 225 self.browser.contents) 226 self.browser.open(self.payments_path + '/addop') 227 # Also the other payments can be made 228 self.browser.getControl(name="form.p_category").value = ['gown'] 229 self.browser.getControl("Create ticket").click() 230 self.assertMatches('...ticket created...', 231 self.browser.contents) 232 self.browser.open(self.payments_path + '/addop') 233 self.browser.getControl(name="form.p_category").value = ['transfer'] 234 self.browser.getControl("Create ticket").click() 235 self.assertMatches('...ticket created...', 236 self.browser.contents) 237 self.browser.open(self.payments_path + '/addop') 238 self.browser.getControl( 239 name="form.p_category").value = ['bed_allocation'] 240 self.browser.getControl("Create ticket").click() 241 self.assertMatches('...ticket created...', 242 self.browser.contents) 243 self.browser.open(self.payments_path + '/addop') 244 self.browser.getControl( 245 name="form.p_category").value = ['hostel_maintenance'] 246 self.browser.getControl("Create ticket").click() 247 self.assertMatches('...ticket created...', 248 self.browser.contents) 249 self.browser.open(self.payments_path + '/addop') 250 self.browser.getControl(name="form.p_category").value = ['clearance'] 251 self.browser.getControl("Create ticket").click() 252 self.assertMatches('...ticket created...', 253 self.browser.contents) 219 254 # Remove all payments so that we can add a school fee payment again 220 255 keys = [i for i in self.student['payments'].keys()] … … 222 257 del self.student['payments'][payment] 223 258 self.browser.open(self.payments_path + '/addop') 224 self.browser.getControl("Create ticket").click() 225 self.assertMatches('...ticket created...', 226 self.browser.contents) 227 self.browser.open(self.payments_path + '/addop') 228 self.browser.getControl(name="form.p_category").value = ['gown'] 229 self.browser.getControl("Create ticket").click() 230 self.assertMatches('...ticket created...', 231 self.browser.contents) 232 self.browser.open(self.payments_path + '/addop') 233 self.browser.getControl(name="form.p_category").value = ['transfer'] 234 self.browser.getControl("Create ticket").click() 235 self.assertMatches('...ticket created...', 236 self.browser.contents) 237 self.browser.open(self.payments_path + '/addop') 238 self.browser.getControl( 239 name="form.p_category").value = ['bed_allocation'] 240 self.browser.getControl("Create ticket").click() 241 self.assertMatches('...ticket created...', 242 self.browser.contents) 243 self.browser.open(self.payments_path + '/addop') 244 self.browser.getControl( 245 name="form.p_category").value = ['hostel_maintenance'] 246 self.browser.getControl("Create ticket").click() 247 self.assertMatches('...ticket created...', 248 self.browser.contents) 249 self.browser.open(self.payments_path + '/addop') 250 self.browser.getControl(name="form.p_category").value = ['clearance'] 251 self.browser.getControl("Create ticket").click() 252 self.assertMatches('...ticket created...', 253 self.browser.contents) 254 self.browser.open(self.payments_path + '/addop') 255 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 256 self.browser.getControl("Create ticket").click() 257 self.assertMatches('...ticket created...', 258 self.browser.contents) 259 # In state returning we can add a new school fee ticket since 260 # p_session and p_level is different 259 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] 260 self.browser.getControl("Create ticket").click() 261 self.assertMatches('...ticket created...', 262 self.browser.contents) 263 # In state returning we can't add a new school fee ticket 264 # for the next session because the second instalment is missing ... 261 265 IWorkflowState(self.student).setState('returning') 262 266 self.browser.open(self.payments_path + '/addop') 263 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 264 self.browser.getControl("Create ticket").click() 265 self.assertMatches('...ticket created...', 266 self.browser.contents) 267 # In state admitted school fee can't be determined 268 IWorkflowState(self.student).setState('admitted') 269 self.browser.open(self.payments_path + '/addop') 270 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 271 self.browser.getControl("Create ticket").click() 272 self.assertMatches('...Amount could not be determined...', 267 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] 268 self.browser.getControl("Create ticket").click() 269 self.assertMatches('...2nd school fee instalment has not yet been paid...', 270 self.browser.contents) 271 self.browser.open(self.payments_path + '/addop') 272 self.browser.getControl(name="form.p_category").value = ['schoolfee_2'] 273 # ... and the first one has not yet been approved. 274 self.browser.getControl("Create ticket").click() 275 self.assertMatches('...1st school fee instalment has not yet been paid...', 276 self.browser.contents) 277 # Ok, then we approve the first instalment ... 278 ctrl = self.browser.getControl(name='val_id') 279 p_id = ctrl.options[0] 280 self.browser.open(self.payments_path + '/' + p_id + '/approve') 281 # ... add the second instalment ... 282 self.browser.open(self.payments_path + '/addop') 283 self.browser.getControl(name="form.p_category").value = ['schoolfee_2'] 284 self.browser.getControl("Create ticket").click() 285 self.assertMatches('...ticket created...', 286 self.browser.contents) 287 # ... approve the second instalment ... 288 ctrl = self.browser.getControl(name='val_id') 289 p_id = ctrl.options[1] 290 self.browser.open(self.payments_path + '/' + p_id + '/approve') 291 # ... and finally add the 1st instalment for the next session. 292 self.browser.open(self.payments_path + '/addop') 293 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] 294 self.browser.getControl("Create ticket").click() 295 self.assertMatches('...ticket created...', 273 296 self.browser.contents) 274 297 … … 324 347 self.app['configuration']['2004'].booking_fee = 150.0 325 348 self.app['configuration']['2004'].maint_fee = 180.0 349 self.app['configuration']['2004'].clearance_fee = 1234.0 350 self.app['configuration']['2004'].school_fee_base = 6666.0 326 351 utils = getUtility(IStudentsUtils) 327 352 328 error, payment = utils.setPaymentDetails('schoolfee ',self.student)353 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 329 354 self.assertEqual(payment, None) 330 self.assertEqual(error, u' Amount could not be determined.')355 self.assertEqual(error, u'Wrong state.') 331 356 332 357 IWorkflowState(self.student).setState('cleared') 333 error, payment = utils.setPaymentDetails('schoolfee ',self.student)334 self.assertEqual(payment.p_level, 100) 335 self.assertEqual(payment.p_session, 2004) 336 self.assertEqual(payment.amount_auth, 40000.0)358 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 359 self.assertEqual(payment.p_level, 100) 360 self.assertEqual(payment.p_session, 2004) 361 self.assertEqual(payment.amount_auth, 6666.0) 337 362 self.assertEqual(payment.p_item, u'CERT1') 338 363 self.assertEqual(error, None) … … 340 365 # Add penalty fee. 341 366 self.app['configuration']['2004'].penalty_ug = 99.0 342 error, payment = utils.setPaymentDetails('schoolfee ',self.student)343 self.assertEqual(payment.amount_auth, 40099.0)367 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 368 self.assertEqual(payment.amount_auth, 6765.0) 344 369 345 370 IWorkflowState(self.student).setState('returning') 346 error, payment = utils.setPaymentDetails('schoolfee ',self.student)371 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 347 372 self.assertEqual(payment.p_level, 200) 348 373 self.assertEqual(payment.p_session, 2005) 349 self.assertEqual(payment.amount_auth, 20099.0)374 self.assertEqual(payment.amount_auth, 6765.0) 350 375 self.assertEqual(payment.p_item, u'CERT1') 351 376 self.assertEqual(error, None) … … 354 379 self.assertEqual(payment.p_level, 100) 355 380 self.assertEqual(payment.p_session, 2004) 356 self.assertEqual(payment.amount_auth, 34250.0)381 self.assertEqual(payment.amount_auth, 1234.0) 357 382 self.assertEqual(payment.p_item, u'CERT1') 358 383 self.assertEqual(error, None) -
main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
r8712 r8753 76 76 amount = academic_session.maint_fee 77 77 elif category == 'clearance': 78 try: 79 p_item = student['studycourse'].certificate.code 80 except (AttributeError, TypeError): 81 return _('Study course data are incomplete.'), None 82 if p_item in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET', 83 'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'): 84 amount = 17250.0 85 else: 86 amount = 34250.0 87 elif category == 'schoolfee': 78 amount = academic_session.clearance_fee 79 p_item = student['studycourse'].certificate.code 80 elif category == 'schoolfee_1': 88 81 try: 89 82 certificate = student['studycourse'].certificate … … 91 84 except (AttributeError, TypeError): 92 85 return _('Study course data are incomplete.'), None 86 payment_allowed = False 93 87 if student.state == CLEARED: 94 amount = getattr(certificate, 'school_fee_1', 0.0) 88 payment_allowed = True 89 amount = academic_session.school_fee_base 95 90 elif student.state == RETURNING: 96 # In case of returning school fee payment the payment session97 # and level contain the values of the session the student98 # has paid for.99 91 p_session, p_level = self.getReturningData(student) 100 amount = getattr(certificate, 'school_fee_2', 0.0) 101 elif student.is_postgrad and student.state == PAID: 102 # Returning postgraduate students also pay for the next session 103 # but their level always remains the same. 104 p_session += 1 105 amount = getattr(certificate, 'school_fee_2', 0.0) 92 initial_instalment_made = False 93 for key in student['payments'].keys(): 94 ticket = student['payments'][key] 95 if ticket.p_category == 'schoolfee_1': 96 initial_instalment_made = True 97 if ticket.p_state == 'paid' and\ 98 ticket.p_category == 'schoolfee_2' and \ 99 ticket.p_item == p_item and \ 100 ticket.p_session == p_session-1: # = current session 101 payment_allowed = True 102 if not initial_instalment_made: 103 payment_allowed = True 104 amount = academic_session.school_fee_base 105 else: 106 return _('Wrong state.'), None 107 if not payment_allowed: 108 return _('The previous 2nd school fee instalment ' 109 'has not yet been paid.'), None 110 elif category == 'schoolfee_2': 111 try: 112 certificate = student['studycourse'].certificate 113 p_item = certificate.code 114 except (AttributeError, TypeError): 115 return _('Study course data are incomplete.'), None 116 payment_allowed = False 117 for key in student['payments'].keys(): 118 ticket = student['payments'][key] 119 if ticket.p_state == 'paid' and\ 120 ticket.p_category == 'schoolfee_1' and \ 121 ticket.p_item == p_item and \ 122 ticket.p_session == p_session: 123 payment_allowed = True 124 if not payment_allowed: 125 return _('The 1st school fee instalment ' 126 'has not yet been paid.'), None 127 amount = academic_session.school_fee_base 106 128 if amount in (0.0, None): 107 129 return _(u'Amount could not be determined.'), None 108 130 # Add session specific penalty fee. 109 if category == 'schoolfee ' and student.is_postgrad:131 if category == 'schoolfee_1' and student.is_postgrad: 110 132 amount += academic_session.penalty_pg 111 elif category == 'schoolfee ':133 elif category == 'schoolfee_1': 112 134 amount += academic_session.penalty_ug 113 135 # Create ticket.
Note: See TracChangeset for help on using the changeset viewer.