Changeset 16136 for main/kofacustom.iuokada/trunk
- Timestamp:
- 28 Jun 2020, 20:42:53 (4 years 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/tests/test_utils.py
r15870 r16136 39 39 self.assertEqual(msg, None) 40 40 return 41 42 def test_set_payment_details(self): 43 self.app['configuration']['2004'].book = 150.0 44 self.app['configuration']['2004'].develop = 90.0 45 self.app['configuration']['2004'].registration = 180.0 46 self.app['configuration']['2004'].municipal_fresh = 280.0 47 self.app['configuration']['2004'].pcf = 380.0 48 self.student['studycourse'].certificate.school_fee_2 = 6666.0 49 IWorkflowState(self.student).setState('cleared') 50 utils = getUtility(IStudentsUtils) 51 error, payment = utils.setPaymentDetails('schoolfee',self.student) 52 self.assertEqual(error, 53 'Registration Fee, Book Deposit, Development Fee, Municipal Fee, ' 54 'Parents Consultative Forum (PCF) Fee must be paid before Tution Fee.') 55 reg_payment = createObject('waeup.StudentOnlinePayment') 56 reg_payment.p_category = u'registration' 57 reg_payment.p_id = u'anyid' 58 reg_payment.p_state = u'paid' 59 reg_payment.p_session = 2004 60 self.student['payments']['anykey'] = reg_payment 61 error, payment = utils.setPaymentDetails('schoolfee',self.student) 62 self.assertEqual(error, 63 'Book Deposit, Development Fee, Municipal Fee, Parents Consultative ' 64 'Forum (PCF) Fee must be paid before Tution Fee.') 65 IWorkflowState(self.student).setState('returning') 66 configuration = createObject('waeup.SessionConfiguration') 67 configuration.academic_session = 2005 68 self.app['configuration'].addSessionConfiguration(configuration) 69 self.app['configuration']['2005'].registration = 170.0 70 error, payment = utils.setPaymentDetails('schoolfee',self.student) 71 self.assertEqual(error, 72 'Registration Fee, Book Deposit, Development Fee, Municipal Fee, ' 73 'Parents Consultative Forum (PCF) Fee must be paid before Tution Fee.') 74 reg_payment.p_session = 2005 75 error, payment = utils.setPaymentDetails('schoolfee',self.student) 76 self.assertEqual(error, 77 'Book Deposit, Development Fee, Municipal Fee, Parents Consultative ' 78 'Forum (PCF) Fee must be paid before Tution Fee.') 79 pcf_payment = createObject('waeup.StudentOnlinePayment') 80 pcf_payment.p_category = u'parentsconsult' 81 pcf_payment.p_id = u'anyid' 82 pcf_payment.p_state = u'paid' 83 pcf_payment.p_session = 2005 84 self.student['payments']['anykey2'] = pcf_payment 85 error, payment = utils.setPaymentDetails('schoolfee',self.student) 86 self.assertEqual(error, 87 'Book Deposit, Development Fee, Municipal Fee must be paid before Tution Fee.') 88 munic_payment = createObject('waeup.StudentOnlinePayment') 89 munic_payment.p_category = u'municipal_fresh' 90 munic_payment.p_id = u'anyid' 91 munic_payment.p_state = u'paid' 92 munic_payment.p_session = 2005 93 self.student['payments']['anykey3'] = munic_payment 94 error, payment = utils.setPaymentDetails('schoolfee',self.student) 95 self.assertEqual(error, 96 'Book Deposit, Development Fee must be paid before Tution Fee.') 97 book_payment = createObject('waeup.StudentOnlinePayment') 98 book_payment.p_category = u'book' 99 book_payment.p_id = u'anyid' 100 book_payment.p_state = u'paid' 101 book_payment.p_session = 2005 102 self.student['payments']['anykey4'] = book_payment 103 develop_payment = createObject('waeup.StudentOnlinePayment') 104 develop_payment.p_category = u'develop' 105 develop_payment.p_id = u'anyid' 106 develop_payment.p_state = u'paid' 107 develop_payment.p_session = 2005 108 self.student['payments']['anykey5'] = develop_payment 109 error, payment = utils.setPaymentDetails('schoolfee',self.student) 110 self.assertEqual(error, None) 111 self.assertEqual(payment.p_level, 200) 112 self.assertEqual(payment.p_session, 2005) 113 self.assertEqual(payment.amount_auth, 6666.0) 114 return -
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/utils.py
r16091 r16136 18 18 import grok 19 19 from time import time 20 from copy import deepcopy 20 21 from zope.component import createObject, getUtility 21 22 from waeup.kofa.interfaces import (IKofaUtils, … … 30 31 """ 31 32 32 # refix33 # prefix 33 34 STUDENT_ID_PREFIX = u'I' 34 35 … … 41 42 #: A tuple containing the names of registration states in which changing of 42 43 #: passport pictures is allowed. 44 43 45 PORTRAIT_CHANGE_STATES = (ADMITTED, CLEARANCE,) 46 47 REQUIRED_PAYMENTS = { 48 'registration': 'Registration Fee', 49 'book': 'Book Deposit', 50 'develop': 'Development Fee', 51 'parentsconsult': 'Parents Consultative Forum (PCF) Fee', 52 'municipal': 'Municipal Fee', 53 } 44 54 45 55 def warnCreditsOOR(self, studylevel, course=None): … … 53 63 return 54 64 65 def _requiredPaymentsMissing(self, student, session): 66 cats_missing = deepcopy(self.REQUIRED_PAYMENTS) 67 if len(student['payments']): 68 for category in self.REQUIRED_PAYMENTS.keys(): 69 for ticket in student['payments'].values(): 70 if ticket.p_state == 'paid' and \ 71 ticket.p_category.startswith(category) and \ 72 ticket.p_session == session: 73 del cats_missing[category] 74 if cats_missing: 75 return "%s must be paid before Tution Fee." % ', '.join( 76 cats_missing.values()) 77 return 78 55 79 def setPaymentDetails(self, category, student, 56 previous_session , previous_level, combi=[]):80 previous_session=None, previous_level=None, combi=[]): 57 81 """Create a payment ticket and set the payment data of a 58 82 student for the payment category specified. … … 78 102 p_level = student['studycourse'].current_level 79 103 p_current = True 104 if category in self.REQUIRED_PAYMENTS.keys() + [ 105 'schoolfee','schoolfee40','secondinstal'] \ 106 and student.state == RETURNING: 107 # In case of school fee or required sundry fee payments the 108 # payment session is always next session if students are in 109 # state returning. 110 p_session, p_level = self.getReturningData(student) 80 111 academic_session = self._getSessionConfiguration(p_session) 81 112 if academic_session == None: … … 84 115 if category in ('schoolfee', 'schoolfee40', 85 116 'secondinstal'): 117 rpm = self._requiredPaymentsMissing(student, p_session) 118 if rpm: 119 return rpm, None 86 120 try: 87 121 certificate = student['studycourse'].certificate … … 111 145 amount = getattr(certificate, 'school_fee_1', 0.0) 112 146 elif student.state == RETURNING: 113 # In case of returning school fee payment the114 # payment session and level contain the values of115 # the session the student has paid for. Payment116 # session is always next session.117 p_session, p_level = self.getReturningData(student)118 academic_session = self._getSessionConfiguration(p_session)119 if academic_session == None:120 return _(121 u'Session configuration object is not available.'122 ), None123 147 amount = getattr(certificate, 'school_fee_2', 0.0) 124 148 elif student.is_postgrad and student.state == PAID:
Note: See TracChangeset for help on using the changeset viewer.