Changeset 15060 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 25 Jun 2018, 09:44:43 (6 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r15042 r15060 448 448 'zope.mgr - students.browser.DatacenterExportJobContainerJobConfig ' 449 449 '- exported: students ' 450 '(None, None, None, None, None, None, , , all, all, all ), '450 '(None, None, None, None, None, None, , , all, all, all, all), ' 451 451 'job_id=%s' 452 452 % job_id in logcontent) -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r15055 r15060 590 590 """The Session Payments Overview Exporter first filters the set of students 591 591 by searching the students catalog. Then it exports some student base data 592 together with lists of payment years for a predefined range of payment 593 categories. 592 together with the total amount paid in predefined payment categories 593 over the previous three session (referring to current academic session). 594 Sample output: 595 596 header: ``...schoolfee13,schoolfee14,schoolfee15,gown13,gown14,gown15...`` 597 598 data: ``...2000.0,,3000.0,,,1000.0,...`` 599 600 This csv data string means that the student paid 2000 school fee in 2013 601 3000 in 2015. She furthermore paid 1000 for gown rental in 2015. 594 602 """ 595 603 grok.name('sessionpaymentsoverview') 596 604 597 605 paycats = ('schoolfee', 'clearance', 'gown', 'transcript') 598 fields = ('student_id', 'matric_number', 'display_fullname',606 regular_fields = ('student_id', 'matric_number', 'display_fullname', 599 607 'state', 'certcode', 'faccode', 'depcode', 'is_postgrad', 600 608 'current_level', 'current_session', 'current_mode', 601 609 'entry_session', 'reg_number' 602 ) + paycats610 ) 603 611 title = _(u'Session Payments Overview') 604 612 605 def mangle_value(self, value, name, context=None): 606 """ 607 """ 608 if name in self.paycats and context is not None: 609 value = '' 613 @property 614 def paycatyears(self): 615 cas = grok.getSite()['configuration'].current_academic_session 616 paycatyears = [] 617 if cas: 618 year_range = range(cas - 2, cas+1) 619 year_range_tuple = tuple([str(year)[2:] for year in year_range]) 620 paycatyears = [ 621 cat+year for cat in self.paycats for year in year_range_tuple] 622 return paycatyears 623 624 @property 625 def fields(self): 626 return self.regular_fields + tuple(self.paycatyears) 627 628 def mangle_value(self, value, name, context=None): 629 """ 630 """ 631 amounts = dict() 632 for catyear in self.paycatyears: 633 amounts[catyear] = 0.0 634 if name[:-2] in self.paycats and context is not None: 610 635 for ticket in context['payments'].values(): 611 if ticket.p_category == name :636 if ticket.p_category == name[:-2]: 612 637 if ticket.p_state in ('waived', 'paid'): 613 value += '%s ' % ticket.p_session 614 value = value.strip().replace(' ', '+') 638 if str(ticket.p_session)[2:] == name[-2:]: 639 amounts[name] += ticket.amount_auth 640 if amounts[name] == 0.0: 641 value = '' 642 elif isinstance(amounts[name], float): 643 value = round(amounts[name], 2) 615 644 return super( 616 645 StudentExporter, self).mangle_value( -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r15051 r15060 1239 1239 super(SessionPaymentsOverviewExporterTest, self).setUp() 1240 1240 self.setup_for_export() 1241 grok.getSite()['configuration'].current_academic_session = curr_year - 4 1241 1242 return 1242 1243 … … 1262 1263 'student_id,matric_number,display_fullname,state,certcode,' 1263 1264 '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 1265 'current_mode,entry_session,reg_number,schoolfee12,' 1266 'schoolfee13,schoolfee14,clearance12,clearance13,clearance14,' 1267 'gown12,gown13,gown14,transcript12,transcript13,transcript14\r\n' 1268 'A111111,234,Anna M. Tester,created,CERT1,NA,NA,0,200,' 1269 '2012,ug_ft,2010,123,' 1270 '12.12,,,,,,,,,,,\r\n' in result 1268 1271 ) 1269 1272 return 1270 1273 1271 1274 def test_export_all(self): 1272 # we can really export students1273 # set values we can expect in export file1274 1275 self.setup_student(self.student) 1275 1276 # We add successful payments. … … 1302 1303 result = open(self.outfile, 'rb').read() 1303 1304 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' 1305 'student_id,matric_number,display_fullname,state,certcode,faccode,' 1306 'depcode,is_postgrad,current_level,current_session,' 1307 'current_mode,entry_session,reg_number,' 1308 'schoolfee12,schoolfee13,schoolfee14,' 1309 'clearance12,clearance13,clearance14,' 1310 'gown12,gown13,gown14,' 1311 'transcript12,transcript13,transcript14\r\n' 1312 'A111111,234,Anna M. Tester,created,CERT1,NA,NA,0,200,2012,ug_ft,' 1313 '2010,123,' 1314 '12.12,14.14,1.01,,,,,,,,,\r\n' 1309 1315 in result 1310 1316 )
Note: See TracChangeset for help on using the changeset viewer.