- Timestamp:
- 26 Jun 2023, 21:30:00 (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r17396 r17457 17 17 ## 18 18 import grok 19 import os 20 import csv 19 21 from time import time 20 22 from reportlab.platypus import Paragraph, Table … … 30 32 from kofacustom.nigeria.students.utils import NigeriaStudentsUtils 31 33 from waeup.uniben.interfaces import MessageFactory as _ 34 35 SCHOOLFEES = dict() 36 37 schoolfees_path = os.path.join( 38 os.path.dirname(__file__), 'schoolfees_22.csv') 39 reader = csv.DictReader(open(schoolfees_path, 'rb')) 40 SCHOOLFEES[22] = {line['code']: {item[0]:item[1] for item in line.items()} 41 for line in reader} 42 43 44 schoolfees_path = os.path.join( 45 os.path.dirname(__file__), 'schoolfees_20.csv') 46 reader = csv.DictReader(open(schoolfees_path, 'rb')) 47 SCHOOLFEES[20] = {line['code']: {item[0]:item[1] for item in line.items()} 48 for line in reader} 49 50 51 schoolfees_path = os.path.join( 52 os.path.dirname(__file__), 'schoolfees_17.csv') 53 reader = csv.DictReader(open(schoolfees_path, 'rb')) 54 SCHOOLFEES[17] = {line['code']: {item[0]:item[1] for item in line.items()} 55 for line in reader} 56 57 schoolfees_path = os.path.join( 58 os.path.dirname(__file__), 'schoolfees_12.csv') 59 reader = csv.DictReader(open(schoolfees_path, 'rb')) 60 SCHOOLFEES[12] = {line['code']: {item[0]:item[1] for item in line.items()} 61 for line in reader} 32 62 33 63 class CustomStudentsUtils(NigeriaStudentsUtils): … … 346 376 except (AttributeError, TypeError): 347 377 return _('Study course data are incomplete.'), None 348 discount_year = 2017 349 if student.is_postgrad: 350 discount_year = 2020 378 try: 379 if student.entry_session < 2017: 380 schoolfees_dict = SCHOOLFEES[12][p_item] 381 elif student.entry_session < 2020: 382 schoolfees_dict = SCHOOLFEES[17][p_item] 383 elif student.entry_session < 2022: 384 schoolfees_dict = SCHOOLFEES[20][p_item] 385 else: 386 schoolfees_dict = SCHOOLFEES[22][p_item] 387 except KeyError: 388 return _('School fee not yet fixed: p_item = %s' % p_item), None 351 389 if previous_session: 352 390 # Students can pay for previous sessions in all workflow states. … … 355 393 if previous_session == student['studycourse'].entry_session: 356 394 if student.is_foreigner: 357 amount = getattr(certificate, 'school_fee_3', 0.0)395 amount = schoolfees_dict['initial_foreigner'] 358 396 else: 359 amount = getattr(certificate, 'school_fee_1', 0.0) 360 # Old new students get a discount. 361 if student.entry_session < discount_year \ 362 and certificate.custom_float_1: 363 amount -= certificate.custom_float_1 397 amount = schoolfees_dict['initial'] 364 398 else: 365 399 if student.is_foreigner: 366 amount = getattr(certificate, 'school_fee_4', 0.0)400 amount = schoolfees_dict['returning_foreigner'] 367 401 else: 368 amount = getattr(certificate, 'school_fee_2', 0.0) 369 # Old returning students get a discount. 370 if student.entry_session < discount_year \ 371 and certificate.custom_float_2: 372 amount -= certificate.custom_float_2 402 amount = schoolfees_dict['returning'] 373 403 else: 374 404 if student.state == CLEARED: 375 405 if student.is_foreigner: 376 amount = getattr(certificate, 'school_fee_3', 0.0)406 amount = schoolfees_dict['initial_foreigner'] 377 407 else: 378 amount = getattr(certificate, 'school_fee_1', 0.0) 379 # Old new students get a discount. 380 if student.entry_session < discount_year \ 381 and certificate.custom_float_1: 382 amount -= certificate.custom_float_1 408 amount = schoolfees_dict['initial'] 383 409 elif student.state == PAID and student.is_postgrad: 384 410 p_session += 1 … … 386 412 if academic_session == None: 387 413 return _(u'Session configuration object is not available.'), None 388 389 # Students are only allowed to pay for the next session390 # if current session payment391 # has really been made, i.e. payment object exists.392 #if not self._paymentMade(393 # student, student.current_session):394 # return _('You have not yet paid your current/active' +395 # ' session. Please use the previous session' +396 # ' payment form first.'), None397 398 414 if student.is_foreigner: 399 amount = getattr(certificate, 'school_fee_4', 0.0)415 amount = schoolfees_dict['returning_foreigner'] 400 416 else: 401 amount = getattr(certificate, 'school_fee_2', 0.0) 402 # Old returning students might get a discount. 403 if student.entry_session < discount_year \ 404 and certificate.custom_float_2: 405 amount -= certificate.custom_float_2 417 amount = schoolfees_dict['returning'] 406 418 elif student.state == RETURNING: 407 419 # In case of returning school fee payment the payment session … … 423 435 424 436 if student.is_foreigner: 425 amount = getattr(certificate, 'school_fee_4', 0.0)437 amount = schoolfees_dict['returning_foreigner'] 426 438 else: 427 amount = getattr(certificate, 'school_fee_2', 0.0) 428 # Old returning students might get a discount. 429 if student.entry_session < discount_year \ 430 and certificate.custom_float_2: 431 amount -= certificate.custom_float_2 439 amount = schoolfees_dict['returning'] 432 440 # PHARMD school fee amount is fixed and previously paid 433 441 # installments in current session are deducted. … … 438 446 else: 439 447 amount = 160000.0 - self._pharmdInstallments(student) 448 try: 449 amount = float(amount) 450 except ValueError: 451 return _(u'School fee not yet fixed: p_item = %s' % p_item), None 440 452 # Give 50% school fee discount to staff members. 441 453 if student.is_staff: 442 454 amount /= 2 455 443 456 else: 444 457 fee_name = category + '_fee'
Note: See TracChangeset for help on using the changeset viewer.