Changeset 9905 for main/waeup.aaue/trunk/src
- Timestamp:
- 22 Jan 2013, 08:55:00 (12 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/etranzact/tests.py
r9755 r9905 50 50 # Managers can add online payment tickets 51 51 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 52 self.app['configuration']['2004'].school_fee _base= 1234.052 self.app['configuration']['2004'].school_fee = 1234.0 53 53 self.browser.open(self.payments_path) 54 54 IWorkflowState(self.student).setState('cleared') 55 55 self.browser.open(self.payments_path + '/addop') 56 self.browser.getControl(name="form.p_category").value = ['schoolfee _1']56 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 57 57 self.browser.getControl("Create ticket").click() 58 58 self.assertMatches('...ticket created...', … … 81 81 'RETURN_TYPE=%s&' 82 82 'PROGRAMME_TYPE=CERT1&' 83 'PAYMENT_TYPE=School Fee 1st instalment&'83 'PAYMENT_TYPE=School Fee&' 84 84 'ACADEMIC_SESSION=2004/2005&' 85 85 'MATRIC_NO=E1000000&' -
main/waeup.aaue/trunk/src/waeup/aaue/interfaces.py
r9319 r9905 32 32 # Base fees, do not remove. 33 33 34 school_fee_base = schema.Float( 35 title = _(u'School Fee Instalments'), 34 #school_fee_base = schema.Float( 35 # title = _(u'School Fee Instalments'), 36 # default = 0.0, 37 # required = False, 38 # ) 39 40 school_fee = schema.Float( 41 title = _(u'School Fee'), 36 42 default = 0.0, 37 43 required = False, -
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r9853 r9905 26 26 27 27 from waeup.aaue.students.interfaces import ( 28 ICustomStudentOnlinePayment , ICustomCourseTicketAdd)28 ICustomStudentOnlinePayment) 29 29 30 30 class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): … … 53 53 form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 54 54 form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 55 56 class CourseTicketAddFormPage2(CourseTicketAddFormPage):57 """Add a course ticket by student.58 """59 grok.name('ctadd')60 grok.require('waeup.handleStudent')61 form_fields = grok.AutoFields(ICustomCourseTicketAdd) -
main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py
r9537 r9905 30 30 from waeup.aaue.payments.interfaces import ICustomOnlinePayment 31 31 from waeup.aaue.interfaces import MessageFactory as _ 32 33 class CourseSource(BasicContextualSourceFactory):34 """A course source delivers all courses inside the portal by looking35 up a catalog.36 """37 def getValues(self, context):38 catalog = getUtility(ICatalog, name='courses_catalog')39 courses = sorted(list(catalog.searchResults(40 code=(None, None))),key=lambda value: value.code)41 payments = context.student.getPaymentTuples()42 if (context.student.current_session, 'schoolfee_2', 'paid') in payments:43 pass44 else:45 courseslist = list(courses)46 for course in courseslist:47 if course.semester == 2:48 courses.remove(course)49 return courses50 51 def getToken(self, context, value):52 return value.code53 54 def getTitle(self, context, value):55 return "%s - %s (%d)" % (56 value.code, value.title[:64], value.semester)57 32 58 33 class ICustomStudentBase(INigeriaStudentBase): … … 119 94 """ 120 95 121 class ICustomCourseTicketAdd(IKofaObject):122 """An interface for adding course tickets.123 124 """125 course = schema.Choice(126 title = _(u'Course'),127 source = CourseSource(),128 readonly = False,129 )130 131 96 class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): 132 97 """Representation of a student. Skip regular reg_number validation. -
main/waeup.aaue/trunk/src/waeup/aaue/students/student.py
r9502 r9905 35 35 grok.provides(ICustomStudent) 36 36 37 def getPaymentTuples(self):38 """Special AAUE method needed for selecting courses in semesters39 the student has paid for.40 """41 payments = [(p.p_session, p.p_category, p.p_state)42 for p in self['payments'].values()]43 return payments44 45 37 # Set all attributes of Student required in IStudent as field 46 38 # properties. Doing this, we do not have to set initial attributes -
main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py
r9692 r9905 39 39 grok.provides(ICustomStudentStudyLevel) 40 40 41 def addCertCourseTickets(self, cert):42 """Collect all certificate courses and create course43 tickets automatically.44 45 Add ticket only if student has paid for the course.semester.46 """47 payments = self.student.getPaymentTuples()48 if cert is not None:49 for key, val in cert.items():50 if val.level != self.level:51 continue52 if val.course.semester == 2 and \53 not (self.student.current_session,54 'schoolfee_2', 'paid') in payments:55 continue56 ticket = createObject(u'waeup.CourseTicket')57 ticket.automatic = True58 ticket.mandatory = val.mandatory59 ticket.carry_over = False60 self.addCourseTicket(ticket, val.course)61 return62 63 41 CustomStudentStudyLevel = attrs_to_fields( 64 42 CustomStudentStudyLevel, omit=['total_credits', 'gpa']) -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r9755 r9905 92 92 self.browser.open(self.payments_path) 93 93 self.browser.getLink("Add current session payment ticket").click() 94 self.browser.getControl(name="form.p_category").value = ['schoolfee _1']94 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 95 95 self.browser.getControl("Create ticket").click() 96 96 self.assertMatches('...Wrong state...', … … 101 101 self.assertMatches('...Amount could not be determined...', 102 102 self.browser.contents) 103 self.app['configuration']['2004'].school_fee _base= 6666.0104 self.browser.getControl(name="form.p_category").value = ['schoolfee _1']103 self.app['configuration']['2004'].school_fee = 6666.0 104 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 105 105 self.browser.getControl("Create ticket").click() 106 106 self.assertMatches('...ticket created...', … … 119 119 ticket.p_state = 'paid' 120 120 self.browser.open(self.payments_path + '/addop') 121 self.browser.getControl(name="form.p_category").value = ['schoolfee _1']121 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 122 122 self.browser.getControl("Create ticket").click() 123 123 self.assertMatches('...This type of payment has already been made...', … … 151 151 self.assertMatches('...ticket created...', 152 152 self.browser.contents) 153 # Remove all payments so that we can add a school fee payment again 154 keys = [i for i in self.student['payments'].keys()] 155 for payment in keys: 156 del self.student['payments'][payment] 153 154 155 def deactivated_test_for_instalment_payments(self): 156 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 157 self.browser.open(self.payments_path) 157 158 self.browser.open(self.payments_path + '/addop') 158 159 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] … … 194 195 configuration.academic_session = 2005 195 196 self.app['configuration'].addSessionConfiguration(configuration) 196 self.app['configuration']['2005'].school_ fee_base = 7777.0197 self.app['configuration']['2005'].school_base = 7777.0 197 198 self.browser.open(self.payments_path + '/addop') 198 199 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] … … 239 240 self.app['configuration']['2004'].maint_fee = 180.0 240 241 self.app['configuration']['2004'].clearance_fee = 1234.0 241 self.app['configuration']['2004'].school_fee _base= 6666.0242 self.app['configuration']['2004'].school_fee = 6666.0 242 243 utils = getUtility(IStudentsUtils) 243 244 … … 245 246 configuration.academic_session = 2005 246 247 self.app['configuration'].addSessionConfiguration(configuration) 247 self.app['configuration']['2005'].school_fee _base= 7777.0248 249 error, payment = utils.setPaymentDetails('schoolfee _1',self.student)248 self.app['configuration']['2005'].school_fee = 7777.0 249 250 error, payment = utils.setPaymentDetails('schoolfee',self.student) 250 251 self.assertEqual(payment, None) 251 252 self.assertEqual(error, u'Wrong state.') 252 253 253 254 IWorkflowState(self.student).setState('cleared') 254 error, payment = utils.setPaymentDetails('schoolfee _1',self.student)255 error, payment = utils.setPaymentDetails('schoolfee',self.student) 255 256 self.assertEqual(payment.p_level, 100) 256 257 self.assertEqual(payment.p_session, 2004) … … 264 265 # ... for returning 265 266 self.app['configuration']['2005'].penalty_ug = 88.0 266 error, payment = utils.setPaymentDetails('schoolfee _1',self.student)267 error, payment = utils.setPaymentDetails('schoolfee',self.student) 267 268 self.assertEqual(payment.amount_auth, 6765.0) 268 269 IWorkflowState(self.student).setState('returning') 269 error, payment = utils.setPaymentDetails('schoolfee _1',self.student)270 error, payment = utils.setPaymentDetails('schoolfee',self.student) 270 271 self.assertEqual(payment.p_level, 200) 271 272 self.assertEqual(payment.p_session, 2005) … … 313 314 return 314 315 315 def test_student_course_registration(self):316 def deactivated_test_student_course_registration(self): 316 317 317 318 # Add more courses -
main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
r9527 r9905 67 67 return _(u'Session configuration object is not available.'), None 68 68 # Determine fee. 69 if category == 'schoolfee':70 return _('School fee has to be paid by two instalments.'), None71 69 if category == 'transfer': 72 70 amount = academic_session.transfer_fee … … 80 78 amount = academic_session.clearance_fee 81 79 p_item = student['studycourse'].certificate.code 82 elif category == 'schoolfee _1':80 elif category == 'schoolfee': 83 81 try: 84 82 certificate = student['studycourse'].certificate … … 86 84 except (AttributeError, TypeError): 87 85 return _('Study course data are incomplete.'), None 88 payment_allowed = False89 86 if student.state == CLEARED: 90 payment_allowed = True 91 amount = academic_session.school_fee_base 87 amount = academic_session.school_fee 92 88 elif student.state == RETURNING or\ 93 89 (student.is_postgrad and student.state == PAID): … … 101 97 # next session but their level always remains the same. 102 98 p_session += 1 103 initial_instalment_made = False104 for key in student['payments'].keys():105 ticket = student['payments'][key]106 if ticket.p_category == 'schoolfee_1' and \107 ticket.p_state == 'paid':108 initial_instalment_made = True109 if ticket.p_state == 'paid' and\110 ticket.p_category == 'schoolfee_2' and \111 ticket.p_item == p_item and \112 ticket.p_session == p_session-1: # = current session113 payment_allowed = True114 if not initial_instalment_made:115 payment_allowed = True116 99 try: 117 100 academic_session = grok.getSite()[ … … 119 102 except KeyError: 120 103 return _(u'Session configuration object is not available.'), None 121 amount = academic_session.school_fee _base104 amount = academic_session.school_fee 122 105 else: 123 106 return _('Wrong state.'), None 124 if not payment_allowed:125 return _('The previous 2nd school fee instalment '126 'has not yet been paid.'), None127 elif category == 'schoolfee_2':128 try:129 certificate = student['studycourse'].certificate130 p_item = certificate.code131 except (AttributeError, TypeError):132 return _('Study course data are incomplete.'), None133 payment_allowed = False134 for key in student['payments'].keys():135 ticket = student['payments'][key]136 if ticket.p_state == 'paid' and\137 ticket.p_category == 'schoolfee_1' and \138 ticket.p_item == p_item and \139 ticket.p_session == p_session:140 payment_allowed = True141 if not payment_allowed:142 return _('The 1st school fee instalment '143 'has not yet been paid or session has '144 'not yet been started.'), None145 amount = academic_session.school_fee_base146 107 if amount in (0.0, None): 147 108 return _(u'Amount could not be determined.'), None 148 109 # Add session specific penalty fee. 149 if category == 'schoolfee _1' and student.is_postgrad:110 if category == 'schoolfee' and student.is_postgrad: 150 111 amount += academic_session.penalty_pg 151 elif category == 'schoolfee _1':112 elif category == 'schoolfee': 152 113 amount += academic_session.penalty_ug 153 114 # Create ticket. -
main/waeup.aaue/trunk/src/waeup/aaue/utils/utils.py
r9755 r9905 40 40 41 41 SELECTABLE_PAYMENT_CATEGORIES = { 42 'schoolfee_1': 'School Fee 1st instalment', 43 'schoolfee_2': 'School Fee 2nd instalment', 42 'schoolfee': 'School Fee', 43 #'schoolfee_1': 'School Fee 1st instalment', 44 #'schoolfee_2': 'School Fee 2nd instalment', 44 45 'clearance': 'Acceptance Fee', 45 46 'hostel_maintenance': 'Hostel Maintenance Fee',
Note: See TracChangeset for help on using the changeset viewer.