Changeset 17457 for main/waeup.uniben/trunk/src/waeup/uniben/students
- Timestamp:
- 26 Jun 2023, 21:30:00 (17 months ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/students
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r17395 r17457 551 551 error, payment = utils.setPaymentDetails('schoolfee', 552 552 self.student, 2002, 300, None) 553 self.assertEqual(payment.amount_auth, 40000.0)553 self.assertEqual(payment.amount_auth, 63000.0) 554 554 self.assertEqual(payment.p_session, 2002) 555 555 self.assertEqual(payment.p_level, 300) … … 557 557 error, payment = utils.setPaymentDetails('schoolfee', 558 558 self.student, 2003, 300, None) 559 self.assertEqual(payment.amount_auth, 2 0000.0)559 self.assertEqual(payment.amount_auth, 26800.0) 560 560 self.assertEqual(payment.p_session, 2003) 561 561 self.assertEqual(payment.p_level, 300) … … 569 569 self.assertEqual(payment.p_level, 100) 570 570 self.assertEqual(payment.p_session, 2004) 571 self.assertEqual(payment.amount_auth, 40000.0)571 self.assertEqual(payment.amount_auth, 63000.0) 572 572 self.assertEqual(payment.p_item, u'CERT1') 573 573 self.assertEqual(error, None) … … 581 581 error, payment = utils.setPaymentDetails('schoolfee', 582 582 self.student, None, None, None) 583 self.assertEqual(payment.amount_auth, 40099.0)583 self.assertEqual(payment.amount_auth, 63099.0) 584 584 585 585 IWorkflowState(self.student).setState('returning') … … 602 602 self.assertEqual(payment.p_level, 200) 603 603 self.assertEqual(payment.p_session, 2005) 604 self.assertEqual(payment.amount_auth, 2 0088.0)604 self.assertEqual(payment.amount_auth, 26888.0) 605 605 self.assertEqual(payment.p_item, u'CERT1') 606 606 self.assertEqual(error, None) 607 607 608 608 # Old returning students may pay less. 609 self.certificate.school_fee_2 = 50000.0610 self.certificate.custom_float_2 = 30000.0609 #self.certificate.school_fee_2 = 50000.0 610 #self.certificate.custom_float_2 = 30000.0 611 611 error, payment = utils.setPaymentDetails( 612 612 'schoolfee', self.student, None, None, None) 613 self.assertEqual(payment.amount_auth, 2 0088.0)613 self.assertEqual(payment.amount_auth, 26888.0) 614 614 615 615 # Staff members pay less. 616 self.certificate.custom_float_2 = None617 616 self.student.is_staff = True 618 617 error, payment = utils.setPaymentDetails('schoolfee', … … 620 619 self.assertEqual(payment.p_level, 200) 621 620 self.assertEqual(payment.p_session, 2005) 622 self.assertEqual(payment.amount_auth, 25088.0)621 self.assertEqual(payment.amount_auth, 13488.0) 623 622 self.assertEqual(payment.p_item, u'CERT1') 624 623 self.assertEqual(error, None) … … 628 627 self.student.is_staff = False 629 628 self.student.nationality = u'DE' 630 self.certificate.school_fee_3 = 60000.0631 629 error, payment = utils.setPaymentDetails( 632 630 'schoolfee', self.student, None, None, None) 633 631 self.assertEqual(payment.p_level, 100) 634 632 self.assertEqual(payment.p_session, 2004) 635 self.assertEqual(payment.amount_auth, 60099.0)633 self.assertEqual(payment.amount_auth, 300099.0) 636 634 self.assertEqual(payment.p_item, u'CERT1') 637 635 self.assertEqual(error, None) 638 636 IWorkflowState(self.student).setState('returning') 639 637 self.student.is_staff = False 640 self.certificate.school_fee_4 = 20000.0641 638 error, payment = utils.setPaymentDetails( 642 639 'schoolfee', self.student, None, None, None) 643 640 self.assertEqual(payment.p_level, 200) 644 641 self.assertEqual(payment.p_session, 2005) 645 self.assertEqual(payment.amount_auth, 2 0088.0)642 self.assertEqual(payment.amount_auth, 277088.0) 646 643 self.assertEqual(payment.p_item, u'CERT1') 647 644 self.assertEqual(error, None) -
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.