Changeset 9152 for main/waeup.uniben/trunk/src/waeup
- Timestamp:
- 4 Sep 2012, 07:06:20 (12 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py
r8866 r9152 71 71 """ 72 72 73 p_current = schema.Bool( 74 title = _(u'Current Session Payment'), 75 default = True, 76 required = False, 77 ) 78 73 79 p_level = schema.Int( 74 80 title = _(u'Payment Level'), -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r9006 r9152 221 221 utils = getUtility(IStudentsUtils) 222 222 223 self.student.nationality = u'NG' 224 223 225 configuration = createObject('waeup.SessionConfiguration') 224 226 configuration.academic_session = 2005 225 227 self.app['configuration'].addSessionConfiguration(configuration) 226 228 227 error, payment = utils.setPaymentDetails('schoolfee',self.student) 229 error, payment = utils.setPaymentDetails('schoolfee', 230 self.student, None, None) 228 231 self.assertEqual(payment, None) 229 self.assertEqual(error, u'Amount could not be determined.') 230 232 self.assertTrue(u'Amount could not be determined.' in error) 233 234 # Previous session payment, fresh and returning 235 # are being distinguished by their entry_level 236 error, payment = utils.setPaymentDetails('schoolfee', 237 self.student, 2004, 300) 238 self.assertEqual(payment.amount_auth, 40000.0) 239 self.assertEqual(payment.p_session, 2004) 240 self.assertEqual(payment.p_level, 300) 241 self.assertFalse(payment.p_current) 242 self.student['studycourse'].entry_session = 2003 243 error, payment = utils.setPaymentDetails('schoolfee', 244 self.student, 2004, 300) 245 self.assertEqual(payment.amount_auth, 20000.0) 246 self.assertEqual(payment.p_session, 2004) 247 self.assertEqual(payment.p_level, 300) 248 self.assertFalse(payment.p_current) 249 250 # Current payment, fresh and returning 251 # are being distinguished by their state 231 252 IWorkflowState(self.student).setState('cleared') 232 self.student.nationality = u'NG'233 error, payment = utils.setPaymentDetails('schoolfee',self.student)253 error, payment = utils.setPaymentDetails('schoolfee', 254 self.student, None, None) 234 255 self.assertEqual(payment.p_level, 100) 235 256 self.assertEqual(payment.p_session, 2004) … … 237 258 self.assertEqual(payment.p_item, u'CERT1') 238 259 self.assertEqual(error, None) 260 self.assertTrue(payment.p_current) 239 261 240 262 # Add penalty fee ... … … 243 265 # ... for returning 244 266 self.app['configuration']['2005'].penalty_ug = 88.0 245 error, payment = utils.setPaymentDetails('schoolfee',self.student) 267 error, payment = utils.setPaymentDetails('schoolfee', 268 self.student, None, None) 246 269 self.assertEqual(payment.amount_auth, 40099.0) 247 270 248 271 IWorkflowState(self.student).setState('returning') 249 error, payment = utils.setPaymentDetails('schoolfee',self.student) 272 error, payment = utils.setPaymentDetails('schoolfee', 273 self.student, None, None) 250 274 self.assertEqual(payment.p_level, 200) 251 275 self.assertEqual(payment.p_session, 2005) … … 255 279 256 280 self.student.is_staff = True 257 error, payment = utils.setPaymentDetails('schoolfee',self.student) 281 error, payment = utils.setPaymentDetails('schoolfee', 282 self.student, None, None) 258 283 self.assertEqual(payment.p_level, 200) 259 284 self.assertEqual(payment.p_session, 2005) … … 266 291 self.student.nationality = u'DE' 267 292 self.certificate.school_fee_3 = 60000.0 268 error, payment = utils.setPaymentDetails('schoolfee',self.student) 293 error, payment = utils.setPaymentDetails( 294 'schoolfee', self.student, None, None) 269 295 self.assertEqual(payment.p_level, 100) 270 296 self.assertEqual(payment.p_session, 2004) … … 277 303 self.student.nationality = u'DE' 278 304 self.certificate.school_fee_4 = 20000.0 279 error, payment = utils.setPaymentDetails('schoolfee',self.student) 305 error, payment = utils.setPaymentDetails( 306 'schoolfee', self.student, None, None) 280 307 self.assertEqual(payment.p_level, 200) 281 308 self.assertEqual(payment.p_session, 2005) … … 284 311 self.assertEqual(error, None) 285 312 286 error, payment = utils.setPaymentDetails('clearance',self.student) 313 error, payment = utils.setPaymentDetails('clearance', 314 self.student, None, None) 287 315 self.assertEqual(payment.p_level, 100) 288 316 self.assertEqual(payment.p_session, 2004) … … 291 319 self.assertEqual(error, None) 292 320 293 error, payment = utils.setPaymentDetails('gown',self.student) 321 error, payment = utils.setPaymentDetails('gown', 322 self.student, None, None) 294 323 self.assertEqual(payment.p_level, 100) 295 324 self.assertEqual(payment.p_session, 2004) … … 298 327 self.assertEqual(error, None) 299 328 300 error, payment = utils.setPaymentDetails('hostel_maintenance',self.student) 329 error, payment = utils.setPaymentDetails('hostel_maintenance', 330 self.student, None, None) 301 331 self.assertEqual(payment.p_level, 100) 302 332 self.assertEqual(payment.p_session, 2004) … … 305 335 self.assertEqual(error, None) 306 336 307 error, payment = utils.setPaymentDetails('bed_allocation',self.student) 337 error, payment = utils.setPaymentDetails('bed_allocation', 338 self.student, None, None) 308 339 self.assertEqual(payment.p_level, 100) 309 340 self.assertEqual(payment.p_session, 2004) … … 312 343 self.assertEqual(error, None) 313 344 314 error, payment = utils.setPaymentDetails('transfer',self.student) 345 error, payment = utils.setPaymentDetails('transfer', 346 self.student, None, None) 315 347 self.assertEqual(payment.p_level, 100) 316 348 self.assertEqual(payment.p_session, 2004) -
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r9006 r9152 48 48 return new_session, new_level 49 49 50 def setPaymentDetails(self, category, student): 50 def setPaymentDetails(self, category, student, 51 previous_session, previous_level): 51 52 """Create Payment object and set the payment data of a student for 52 53 the payment category specified. … … 57 58 amount = 0.0 58 59 error = u'' 59 p_session = student['studycourse'].current_session 60 p_level = student['studycourse'].current_level 60 if previous_session: 61 p_session = previous_session 62 p_level = previous_level 63 p_current = False 64 else: 65 p_session = student['studycourse'].current_session 66 p_level = student['studycourse'].current_level 67 p_current = True 61 68 session = str(p_session) 62 69 try: … … 89 96 except (AttributeError, TypeError): 90 97 return _('Study course data are incomplete.'), None 91 if student.state == CLEARED: 92 if student.is_foreigner: 93 amount = getattr(certificate, 'school_fee_3', 0.0) 98 if previous_session: 99 if student.current_session == student['studycourse'].entry_session: 100 if student.is_foreigner: 101 amount = getattr(certificate, 'school_fee_3', 0.0) 102 else: 103 amount = getattr(certificate, 'school_fee_1', 0.0) 94 104 else: 95 amount = getattr(certificate, 'school_fee_1', 0.0) 96 elif student.state == RETURNING: 97 # In case of returning school fee payment the payment session 98 # and level contain the values of the session the student 99 # has paid for. 100 p_session, p_level = self.getReturningData(student) 101 if student.is_foreigner: 102 amount = getattr(certificate, 'school_fee_4', 0.0) 103 else: 104 amount = getattr(certificate, 'school_fee_2', 0.0) 105 try: 106 academic_session = grok.getSite()[ 107 'configuration'][str(p_session)] 108 except KeyError: 109 return _(u'Session configuration object is not available.'), None 110 elif student.is_postgrad and student.state == PAID: 111 # Returning postgraduate students also pay for the next session 112 # but their level always remains the same. 113 p_session += 1 114 if student.is_foreigner: 115 amount = getattr(certificate, 'school_fee_4', 0.0) 116 else: 117 amount = getattr(certificate, 'school_fee_2', 0.0) 118 try: 119 academic_session = grok.getSite()[ 120 'configuration'][str(p_session)] 121 except KeyError: 122 return _(u'Session configuration object is not available.'), None 105 if student.is_foreigner: 106 amount = getattr(certificate, 'school_fee_4', 0.0) 107 else: 108 amount = getattr(certificate, 'school_fee_2', 0.0) 109 else: 110 if student.state == CLEARED: 111 if student.is_foreigner: 112 amount = getattr(certificate, 'school_fee_3', 0.0) 113 else: 114 amount = getattr(certificate, 'school_fee_1', 0.0) 115 elif student.state == RETURNING: 116 # In case of returning school fee payment the payment session 117 # and level contain the values of the session the student 118 # has paid for. 119 p_session, p_level = self.getReturningData(student) 120 if student.is_foreigner: 121 amount = getattr(certificate, 'school_fee_4', 0.0) 122 else: 123 amount = getattr(certificate, 'school_fee_2', 0.0) 124 try: 125 academic_session = grok.getSite()[ 126 'configuration'][str(p_session)] 127 except KeyError: 128 return _(u'Session configuration object is not available.'), None 129 elif student.is_postgrad and student.state == PAID: 130 # Returning postgraduate students also pay for the next session 131 # but their level always remains the same. 132 p_session += 1 133 if student.is_foreigner: 134 amount = getattr(certificate, 'school_fee_4', 0.0) 135 else: 136 amount = getattr(certificate, 'school_fee_2', 0.0) 137 try: 138 academic_session = grok.getSite()[ 139 'configuration'][str(p_session)] 140 except KeyError: 141 return _(u'Session configuration object is not available.'), None 123 142 # Give 50% school fee discount to staff members. 124 143 if student.is_staff: 125 144 amount /= 2 126 145 if amount in (0.0, None): 127 return _(u'Amount could not be determined.'), None 146 return _('Amount could not be determined.' + 147 ' Would you like to pay for a previous session?'), None 128 148 # Add session specific penalty fee. 129 149 if category == 'schoolfee' and student.is_postgrad: … … 138 158 ticket.p_item == p_item and \ 139 159 ticket.p_session == p_session: 140 return _('This type of payment has already been made.'), None 160 return _('This type of payment has already been made.' + 161 ' Would you like to pay for a previous session?'), None 141 162 payment = createObject(u'waeup.StudentOnlinePayment') 142 163 timestamp = ("%d" % int(time()*10000))[1:] … … 146 167 payment.p_session = p_session 147 168 payment.p_level = p_level 169 payment.p_current = p_current 148 170 payment.amount_auth = amount 149 171 return None, payment
Note: See TracChangeset for help on using the changeset viewer.