- Timestamp:
- 8 Jan 2024, 17:02:40 (10 months ago)
- Location:
- main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/utils.py
r16583 r17661 31 31 """ 32 32 33 # prefix 34 STUDENT_ID_PREFIX = u'I' 33 @property 34 def STUDENT_ID_PREFIX(self): 35 if grok.getSite().__name__ == 'iuokada-cdl': 36 return u'F' 37 return u'I' 38 35 39 36 40 SKIP_UPLOAD_VIEWLETS = ( … … 125 129 student for the payment category specified. 126 130 """ 131 if grok.getSite().__name__ == 'iuokada-cdl': 132 return self.setCDLPaymentDetails(category, student, 133 previous_session, previous_level, combi) 127 134 p_item = u'' 128 135 amount = 0.0 … … 282 289 return None, payment 283 290 291 def setCDLPaymentDetails(self, category, student, 292 previous_session=None, previous_level=None, combi=[]): 293 """Create a payment ticket and set the payment data of a 294 student for the payment category specified. 295 """ 296 p_item = u'' 297 amount = 0.0 298 if previous_session: 299 if previous_session < student['studycourse'].entry_session: 300 return _('The previous session must not fall below ' 301 'your entry session.'), None 302 if category == 'schoolfee': 303 # School fee is always paid for the following session 304 if previous_session > student['studycourse'].current_session: 305 return _('This is not a previous session.'), None 306 else: 307 if previous_session > student['studycourse'].current_session - 1: 308 return _('This is not a previous session.'), None 309 p_session = previous_session 310 p_level = previous_level 311 p_current = False 312 else: 313 p_session = student['studycourse'].current_session 314 p_level = student['studycourse'].current_level 315 p_current = True 316 if category in self.REQUIRED_PAYMENTS_FRESH.keys() \ 317 + self.REQUIRED_PAYMENTS_RETURNING.keys() \ 318 + ['schoolfee','schoolfee40','secondinstal'] \ 319 and student.state == RETURNING: 320 # In case of school fee or required sundry fee payments the 321 # payment session is always next session if students are in 322 # state returning. 323 p_session, p_level = self.getReturningData(student) 324 academic_session = self._getSessionConfiguration(p_session) 325 if academic_session == None: 326 return _(u'Session configuration object is not available.'), None 327 # Determine fee. 328 if category in ('schoolfee', 'schoolfee40', 'secondinstal'): 329 rpm = self._requiredPaymentsMissing(student, p_session) 330 if rpm: 331 return rpm, None 332 try: 333 certificate = student['studycourse'].certificate 334 p_item = certificate.code 335 except (AttributeError, TypeError): 336 return _('Study course data are incomplete.'), None 337 if previous_session: 338 # Students can pay for previous sessions in all 339 # workflow states. Fresh students are excluded by the 340 # update method of the PreviousPaymentAddFormPage. 341 if previous_level == 100: 342 amount = getattr(certificate, 'school_fee_1', 0.0) 343 else: 344 amount = getattr(certificate, 'school_fee_2', 0.0) 345 if category == 'schoolfee40': 346 amount = 0.4*amount 347 elif category == 'secondinstal': 348 amount = 0.6*amount 349 else: 350 if category == 'secondinstal': 351 if student.is_fresh: 352 amount = 0.6 * getattr(certificate, 'school_fee_1', 0.0) 353 else: 354 amount = 0.6 * getattr(certificate, 'school_fee_2', 0.0) 355 else: 356 if student.state in (CLEARANCE, REQUESTED, CLEARED): 357 amount = getattr(certificate, 'school_fee_1', 0.0) 358 elif student.state == RETURNING: 359 amount = getattr(certificate, 'school_fee_2', 0.0) 360 elif student.is_postgrad and student.state == PAID: 361 # Returning postgraduate students also pay for the 362 # next session but their level always remains the 363 # same. 364 p_session += 1 365 academic_session = self._getSessionConfiguration(p_session) 366 if academic_session == None: 367 return _( 368 u'Session configuration object is not available.' 369 ), None 370 amount = getattr(certificate, 'school_fee_2', 0.0) 371 if amount and category == 'schoolfee40': 372 amount = 0.4*amount 373 elif category == 'clearance': 374 try: 375 p_item = student['studycourse'].certificate.code 376 except (AttributeError, TypeError): 377 return _('Study course data are incomplete.'), None 378 amount = academic_session.clearance_fee 379 elif category.startswith('cdlcourse'): 380 amount = academic_session.course_fee 381 number = int(category.strip('cdlcourse')) 382 amount *= number 383 elif category == 'combi' and combi: 384 categories = getUtility(IKofaUtils).CDLPORTAL_PAYMENT_CATEGORIES 385 for cat in combi: 386 fee_name = cat + '_fee' 387 cat_amount = getattr(academic_session, fee_name, 0.0) 388 if not cat_amount: 389 return _('%s undefined.' % categories[cat]), None 390 amount += cat_amount 391 p_item += u'%s + ' % categories[cat] 392 p_item = p_item.strip(' + ') 393 else: 394 fee_name = category + '_fee' 395 amount = getattr(academic_session, fee_name, 0.0) 396 if amount in (0.0, None): 397 return _('Amount could not be determined.'), None 398 if self.samePaymentMade(student, category, p_item, p_session): 399 return _('This type of payment has already been made.'), None 400 if self._isPaymentDisabled(p_session, category, student): 401 return _('This category of payments has been disabled.'), None 402 payment = createObject(u'waeup.StudentOnlinePayment') 403 timestamp = ("%d" % int(time()*10000))[1:] 404 if category in ( 405 'registration', 'required_combi', 'pg_other', 'jupeb_reg'): 406 payment.provider_amt = 5000.0 407 if category in ( 408 'schoolfee', 'schoolfee40') and student.is_jupeb: 409 payment.provider_amt = 5000.0 410 payment.p_id = "p%s" % timestamp 411 payment.p_category = category 412 payment.p_item = p_item 413 payment.p_session = p_session 414 payment.p_level = p_level 415 payment.p_current = p_current 416 payment.amount_auth = amount 417 payment.p_combi = combi 418 return None, payment 419 284 420 def setBalanceDetails(self, category, student, 285 421 balance_session, balance_level, balance_amount): -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/viewlets.py
r17573 r17661 37 37 from kofacustom.nigeria.interfaces import MessageFactory as _ 38 38 39 class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton): 40 41 @property 42 def target(self): 43 if grok.getSite().__name__ == 'iuokada-cdl': 44 return 45 return 'addpp' 46 39 47 class StudentPersonalEditActionButton(StudentPersonalEditActionButton): 40 48 text = _('Edit registration bio data') … … 110 118 #if self.context.student.depcode == 'BMS': 111 119 # return '' 120 if grok.getSite().__name__ == 'iuokada-cdl': 121 return 122 return self.view.url(self.view.context, self.target) 123 124 class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton): 125 126 @property 127 def target_url(self): 128 if grok.getSite().__name__ == 'iuokada-cdl': 129 return 130 student = self.view.context.student 131 if student.before_payment or not self.target: 132 return '' 112 133 return self.view.url(self.view.context, self.target) 113 134
Note: See TracChangeset for help on using the changeset viewer.