Changeset 10173 for main/waeup.aaua/trunk/src
- Timestamp:
- 12 May 2013, 05:28:42 (12 years ago)
- Location:
- main/waeup.aaua/trunk/src/waeup/aaua/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaua/trunk/src/waeup/aaua/students/tests/test_browser.py
r10157 r10173 119 119 # ... and voila next session registration is allowed 120 120 self.assertTrue(self.student['studycourse'].next_session_allowed) 121 122 def test_set_payment_details(self): 123 self.certificate.school_fee_1 = 100.0 124 self.certificate.school_fee_2 = 200.0 125 utils = getUtility(IStudentsUtils) 126 127 IWorkflowState(self.student).setState('cleared') 128 self.certificate.study_mode = 'ug_ft' 129 error, payment = utils.setPaymentDetails('schoolfee',self.student) 130 self.assertEqual(payment.p_level, 100) 131 self.assertEqual(payment.p_session, 2004) 132 self.assertEqual(payment.amount_auth, 100.0) 133 self.assertEqual(payment.p_item, u'CERT1') 134 self.assertEqual(error, None) 135 136 IWorkflowState(self.student).setState('returning') 137 configuration = createObject('waeup.SessionConfiguration') 138 configuration.academic_session = 2005 139 self.app['configuration'].addSessionConfiguration(configuration) 140 error, payment = utils.setPaymentDetails('schoolfee',self.student) 141 self.assertEqual(payment.p_level, 200) 142 self.assertEqual(payment.p_session, 2005) 143 self.assertEqual(payment.amount_auth, 200.0) 144 self.assertEqual(payment.p_item, u'CERT1') 145 self.assertEqual(error, None) 146 147 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 148 self.assertEqual(error, u'Payment by instalments not allowed.') 149 self.certificate.ratio = 0.0 150 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 151 self.assertEqual(error, u'Payment by instalments not allowed.') 152 error, payment = utils.setPaymentDetails('schoolfee_2',self.student) 153 self.assertEqual(error, u'Payment by instalments not allowed.') 154 self.certificate.ratio = 0.4 155 error, payment = utils.setPaymentDetails('schoolfee',self.student) 156 self.assertEqual(error, u'Payment by instalments required.') 157 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 158 self.assertEqual(payment.amount_auth, 80.0) 159 error, payment = utils.setPaymentDetails('schoolfee_2',self.student) 160 self.assertEqual(payment.amount_auth, 120.0) 161 IWorkflowState(self.student).setState('cleared') 162 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 163 self.assertEqual(payment.amount_auth, 40.0) 164 error, payment = utils.setPaymentDetails('schoolfee_2',self.student) 165 self.assertEqual(payment.amount_auth, 60.0) -
main/waeup.aaua/trunk/src/waeup/aaua/students/utils.py
r10171 r10173 34 34 35 35 def setPaymentDetails(self, category, student, 36 previous_session , previous_level):36 previous_session=None, previous_level=None): 37 37 """Create Payment object and set the payment data of a student for 38 38 the payment category specified. … … 42 42 amount = 0.0 43 43 if previous_session: 44 if previous_session < student['studycourse'].entry_session: 45 return _('The previous session must not fall below ' 46 'your entry session.'), None 47 if category == 'schoolfee': 48 # School fee is always paid for the following session 49 if previous_session > student['studycourse'].current_session: 50 return _('This is not a previous session.'), None 51 else: 52 if previous_session > student['studycourse'].current_session - 1: 53 return _('This is not a previous session.'), None 54 p_session = previous_session 55 p_level = previous_level 56 p_current = False 57 else: 58 p_session = student['studycourse'].current_session 59 p_level = student['studycourse'].current_level 60 p_current = True 44 return _('Previous session payment not yet implemented.'), None 45 p_session = student['studycourse'].current_session 46 p_level = student['studycourse'].current_level 47 p_current = True 61 48 academic_session = self._getSessionConfiguration(p_session) 62 49 if academic_session == None: 63 50 return _(u'Session configuration object is not available.'), None 64 51 # Determine fee. 65 if category == 'schoolfee':52 if category in ('schoolfee', 'schoolfee_1', 'schoolfee_2'): 66 53 try: 67 54 certificate = student['studycourse'].certificate … … 69 56 except (AttributeError, TypeError): 70 57 return _('Study course data are incomplete.'), None 71 if previous_session: 72 # Students can pay for previous sessions in all 73 # workflow states. Fresh students are excluded by the 74 # update method of the PreviousPaymentAddFormPage. 75 if previous_level == 100: 58 ratio = getattr(certificate, 'ratio', 0.0) 59 if ratio is None: 60 ratio = 0.0 61 if category == 'schoolfee' and ratio > 0: 62 return _('Payment by instalments required.'), None 63 if category in ('schoolfee_1', 'schoolfee_2') and ratio == 0: 64 return _('Payment by instalments not allowed.'), None 65 if student.state == CLEARED: 66 if category == 'schoolfee': 76 67 amount = getattr(certificate, 'school_fee_1', 0.0) 77 else: 68 elif category == 'schoolfee_1': 69 amount = getattr(certificate, 'school_fee_1', 0.0) * ratio 70 elif category == 'schoolfee_2': 71 amount = getattr(certificate, 'school_fee_1', 0.0) * (1- ratio) 72 elif student.state == RETURNING: 73 # In case of returning school fee payment the 74 # payment session and level contain the values of 75 # the session the student has paid for. Payment 76 # session is always next session. 77 p_session, p_level = self.getReturningData(student) 78 academic_session = self._getSessionConfiguration(p_session) 79 if academic_session == None: 80 return _( 81 u'Session configuration object is not available.' 82 ), None 83 if category == 'schoolfee': 78 84 amount = getattr(certificate, 'school_fee_2', 0.0) 79 else: 80 if student.state == CLEARED: 81 amount = getattr(certificate, 'school_fee_1', 0.0) 82 elif student.state == RETURNING: 83 # In case of returning school fee payment the 84 # payment session and level contain the values of 85 # the session the student has paid for. Payment 86 # session is always next session. 87 p_session, p_level = self.getReturningData(student) 88 academic_session = self._getSessionConfiguration(p_session) 89 if academic_session == None: 90 return _( 91 u'Session configuration object is not available.' 92 ), None 85 elif category == 'schoolfee_1': 86 amount = getattr(certificate, 'school_fee_2', 0.0) * ratio 87 elif category == 'schoolfee_2' and ratio: 88 amount = getattr(certificate, 'school_fee_2', 0.0) * (1- ratio) 89 elif student.is_postgrad and student.state == PAID: 90 # Returning postgraduate students also pay for the 91 # next session but their level always remains the 92 # same. 93 p_session += 1 94 academic_session = self._getSessionConfiguration(p_session) 95 if academic_session == None: 96 return _( 97 u'Session configuration object is not available.' 98 ), None 99 if category == 'schoolfee': 93 100 amount = getattr(certificate, 'school_fee_2', 0.0) 94 elif student.is_postgrad and student.state == PAID: 95 # Returning postgraduate students also pay for the 96 # next session but their level always remains the 97 # same. 98 p_session += 1 99 academic_session = self._getSessionConfiguration(p_session) 100 if academic_session == None: 101 return _( 102 u'Session configuration object is not available.' 103 ), None 104 amount = getattr(certificate, 'school_fee_2', 0.0) 105 elif category == 'clearance': 106 try: 107 p_item = student['studycourse'].certificate.code 108 except (AttributeError, TypeError): 109 return _('Study course data are incomplete.'), None 110 amount = academic_session.clearance_fee 111 elif category == 'bed_allocation': 112 p_item = self.getAccommodationDetails(student)['bt'] 113 amount = academic_session.booking_fee 114 elif category == 'hostel_maintenance': 115 amount = academic_session.maint_fee 116 bedticket = student['accommodation'].get( 117 str(student.current_session), None) 118 if bedticket: 119 p_item = bedticket.bed_coordinates 120 else: 121 # Should not happen because this is already checked 122 # in the browser module, but anyway ... 123 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 124 p_item = trans(_('no bed allocated'), portal_language) 101 elif category == 'schoolfee_1': 102 amount = getattr(certificate, 'school_fee_2', 0.0) * ratio 103 elif category == 'schoolfee_2' and ratio: 104 amount = getattr(certificate, 'school_fee_2', 0.0) * (1- ratio) 125 105 if amount in (0.0, None): 126 106 return _('Amount could not be determined.'), None
Note: See TracChangeset for help on using the changeset viewer.