Changeset 15051 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 12 Jun 2018, 12:38:33 (7 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r15047 r15051 3409 3409 exporters += [('Bursary Data', 'bursary')] 3410 3410 if checkPermission('waeup.exportPaymentsOverview', self.context): 3411 exporters += [('Student Payments Overview', 'sfpaymentsoverview')] 3411 exporters += [('School Fee Payments Overview', 3412 'sfpaymentsoverview'), 3413 ('Session Payments Overview', 3414 'sessionpaymentsoverview')] 3412 3415 self.exporters = exporters 3413 3416 return -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r15049 r15051 549 549 year_range = range(curr_year - 11, curr_year + 1) 550 550 year_range_tuple = tuple([str(year) for year in year_range]) 551 552 551 fields = ('student_id', 'matric_number', 'display_fullname', 553 552 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad', … … 584 583 value, name, context=context) 585 584 585 class SessionPaymentsOverviewExporter(StudentExporter): 586 """The Session Payments Overview Exporter first filters the set of students 587 by searching the students catalog. Then it exports some student base data 588 together with lists of payment years for a predefined range of payment 589 categories. 590 """ 591 grok.name('sessionpaymentsoverview') 592 593 paycats = ('schoolfee', 'clearance', 'gown', 'transcript') 594 fields = ('student_id', 'matric_number', 'display_fullname', 595 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad', 596 'current_level', 'current_session', 'current_mode', 597 'entry_session', 'reg_number' 598 ) + paycats 599 title = _(u'Session Payments Overview') 600 601 def mangle_value(self, value, name, context=None): 602 """ 603 """ 604 if name in self.paycats and context is not None: 605 value = '' 606 for ticket in context['payments'].values(): 607 if ticket.p_category == name: 608 if ticket.p_state in ('waived', 'paid'): 609 value += '%s ' % ticket.p_session 610 value = value.strip().replace(' ', '+') 611 return super( 612 StudentExporter, self).mangle_value( 613 value, name, context=context) 614 586 615 class StudentStudyLevelsOverviewExporter(StudentExporter): 587 616 """The Student Study Levels Overview Exporter first filters the set of -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r15047 r15051 32 32 SchoolFeePaymentsOverviewExporter, StudentStudyLevelsOverviewExporter, 33 33 ComboCardDataExporter, DataForBursaryExporter, 34 StudentUnpaidPaymentExporter, 34 StudentUnpaidPaymentExporter, SessionPaymentsOverviewExporter, 35 35 get_students,) 36 36 from waeup.kofa.students.accommodation import BedTicket … … 1232 1232 return 1233 1233 1234 class SessionPaymentsOverviewExporterTest(StudentImportExportSetup): 1235 1236 layer = FunctionalLayer 1237 1238 def setUp(self): 1239 super(SessionPaymentsOverviewExporterTest, self).setUp() 1240 self.setup_for_export() 1241 return 1242 1243 def test_ifaces(self): 1244 # make sure we fullfill interface contracts 1245 obj = SessionPaymentsOverviewExporter() 1246 verifyObject(ICSVStudentExporter, obj) 1247 verifyClass(ICSVStudentExporter, SessionPaymentsOverviewExporter) 1248 return 1249 1250 def test_get_as_utility(self): 1251 # we can get a payments exporter as utility 1252 result = queryUtility(ICSVExporter, name="sessionpaymentsoverview") 1253 self.assertTrue(result is not None) 1254 return 1255 1256 def test_export(self): 1257 self.setup_student(self.student) 1258 exporter = SessionPaymentsOverviewExporter() 1259 exporter.export([self.student], self.outfile) 1260 result = open(self.outfile, 'rb').read() 1261 self.assertTrue( 1262 'student_id,matric_number,display_fullname,state,certcode,' 1263 'faccode,depcode,is_postgrad,current_level,current_session,' 1264 'current_mode,entry_session,reg_number,schoolfee,clearance,' 1265 'gown,transcript\r\n' 1266 'A111111,234,Anna M. Tester,created,CERT1,NA,NA,0,200,2012,' 1267 'ug_ft,2010,123,2012,,,' in result 1268 ) 1269 return 1270 1271 def test_export_all(self): 1272 # we can really export students 1273 # set values we can expect in export file 1274 self.setup_student(self.student) 1275 # We add successful payments. 1276 payment_2 = StudentOnlinePayment() 1277 payment_2.p_id = 'my-id' 1278 payment_2.p_session = curr_year - 5 1279 payment_2.amount_auth = 13.13 1280 payment_2.p_state = 'paid' 1281 payment_2.p_category = u'schoolfee' 1282 self.student['payments']['my-2ndpayment'] = payment_2 1283 # This one could be a balance payment. 1284 # The amount is being added. 1285 payment_3 = StudentOnlinePayment() 1286 payment_3.p_id = 'my-id_2' 1287 payment_3.p_session = curr_year - 5 1288 payment_3.amount_auth = 1.01 1289 payment_3.p_state = 'paid' 1290 payment_3.p_category = u'schoolfee' 1291 self.student['payments']['my-3rdpayment'] = payment_3 1292 # One session school fee has been waived 1293 payment_4 = StudentOnlinePayment() 1294 payment_4.p_id = 'my-id_2' 1295 payment_4.p_session = curr_year - 4 1296 payment_4.amount_auth = 1.01 1297 payment_4.p_state = 'waived' 1298 payment_4.p_category = u'schoolfee' 1299 self.student['payments']['my-4thpayment'] = payment_4 1300 exporter = SessionPaymentsOverviewExporter() 1301 exporter.export_all(self.app, self.outfile) 1302 result = open(self.outfile, 'rb').read() 1303 self.assertTrue( 1304 'student_id,matric_number,display_fullname,state,certcode,' 1305 'faccode,depcode,is_postgrad,current_level,current_session,' 1306 'current_mode,entry_session,reg_number,schoolfee,clearance,' 1307 'gown,transcript\r\nA111111,234,Anna M. Tester,created,CERT1,' 1308 'NA,NA,0,200,2012,ug_ft,2010,123,2013+2013+2014+2012,,,\r\n' 1309 in result 1310 ) 1311 return 1312 1234 1313 class StudentStudyLevelsOverviewExporterTest(StudentImportExportSetup): 1235 1314 -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r15047 r15051 1073 1073 'studentstudylevels', 'coursetickets', 1074 1074 'studentpayments', 'studentunpaidpayments', 1075 'bedtickets', 'sfpaymentsoverview', 1075 'bedtickets', 'sfpaymentsoverview', 'sessionpaymentsoverview', 1076 1076 'studylevelsoverview', 'combocard', 'bursary') 1077 1077
Note: See TracChangeset for help on using the changeset viewer.