Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py	(revision 15792)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py	(revision 15798)
@@ -5,6 +5,8 @@
 from zope.app.testing.xmlrpc import ServerProxy
 from zope.component import getUtility
-from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
+from waeup.kofa.interfaces import (
+    IExtFileStore, IFileStoreNameChooser, IKofaUtils)
 from waeup.kofa.testing import FunctionalLayer
+from waeup.kofa.utils.helpers import to_timezone
 from waeup.kofa.students.payments import StudentOnlinePayment
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
@@ -520,2 +522,103 @@
             xmlrpclib.ProtocolError, server.get_student_id, stud_id)
         return
+
+    def test_get_bursary_data(self):
+        tz = getUtility(IKofaUtils).tzinfo
+        payment1 = StudentOnlinePayment()
+        payment1.p_id = 'my-id1'
+        payment1.p_session = 2012
+        payment1.amount_auth = 12.12
+        payment1.p_state = u'paid'
+        payment1.p_category = u'schoolfee'
+        self.student['payments']['my-payment1'] = payment1
+        payment2 = StudentOnlinePayment()
+        payment2.p_id = 'my-id2'
+        payment2.p_session = 2012
+        payment2.amount_auth = 12.12
+        payment2.p_state = u'paid'
+        payment2.p_category = u'clearance'
+        self.student['payments']['my-payment2'] = payment2
+        server = ServerProxy('http://mgr:mgrpw@localhost/app', allow_none=True)
+        result = server.get_bursary_data(None,None,None,None,'dep1')
+        self.assertEqual(
+            result, [
+            ['K1000000', '234', '123', 'Anna', None, 'Tester', 'created',
+             2004, 2004, None, 'fac1', 'dep1', 'CERT1', 'my-id1', 12.12,
+             'schoolfee', None, 2012, 'paid',
+             str('%s#' % to_timezone(payment1.creation_date, tz)), 'None#'],
+            ['K1000000', '234', '123', 'Anna', None, 'Tester',
+             'created', 2004, 2004, None, 'fac1', 'dep1', 'CERT1',
+             'my-id2', 12.12, 'clearance', None, 2012, 'paid',
+             str('%s#' % to_timezone(payment2.creation_date, tz)), 'None#']]
+             )
+        REQUEST_XML = """\
+<?xml version="1.0"?>
+<methodCall>
+<methodName>get_bursary_data</methodName>
+<params>
+<param>
+<value><string></string></value>
+<value><string></string></value>
+<value><string></string></value>
+<value><string></string></value>
+<value><string>dep1</string></value>
+</param>
+</params>
+</methodCall>"""
+        RESPONSE_XML = """\
+<?xml version='1.0'?>
+<methodResponse>
+<params>
+<param>
+<value><array><data>
+<value><array><data>
+<value><string>K1000000</string></value>
+<value><string>234</string></value>
+<value><string>123</string></value>
+<value><string>Anna</string></value>
+<value><nil/></value><value><string>Tester</string></value>
+<value><string>created</string></value>
+<value><int>2004</int></value>
+<value><int>2004</int></value>
+<value><nil/></value><value><string>fac1</string></value>
+<value><string>dep1</string></value>
+<value><string>CERT1</string></value>
+<value><string>my-id1</string></value>
+<value><double>12.12</double></value>
+<value><string>schoolfee</string></value>
+<value><nil/></value><value><int>2012</int></value>
+<value><string>paid</string></value>
+<value><string>%s</string></value>
+<value><string>None#</string></value>
+</data></array></value>
+<value><array><data>
+<value><string>K1000000</string></value>
+<value><string>234</string></value>
+<value><string>123</string></value>
+<value><string>Anna</string></value>
+<value><nil/></value><value><string>Tester</string></value>
+<value><string>created</string></value>
+<value><int>2004</int></value>
+<value><int>2004</int></value>
+<value><nil/></value><value><string>fac1</string></value>
+<value><string>dep1</string></value>
+<value><string>CERT1</string></value>
+<value><string>my-id2</string></value>
+<value><double>12.12</double></value>
+<value><string>clearance</string></value>
+<value><nil/></value><value><int>2012</int></value>
+<value><string>paid</string></value>
+<value><string>%s</string></value>
+<value><string>None#</string></value>
+</data></array></value>
+</data></array></value>
+</param>
+</params>
+</methodResponse>
+"""
+        xmlout = self.XMLRPC_post(REQUEST_XML)
+        response = RESPONSE_XML % (str('%s#' % to_timezone(payment1.creation_date, tz)),
+                                   str('%s#' % to_timezone(payment2.creation_date, tz))
+                                   )
+        self.assertEqual(xmlout, response)
+        return
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py	(revision 15792)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py	(revision 15798)
@@ -23,7 +23,9 @@
 from zope.catalog.interfaces import ICatalog
 from waeup.kofa.interfaces import (
-    IUniversity, IExtFileStore, IFileStoreNameChooser,
+    IUniversity, IExtFileStore, IFileStoreNameChooser, IKofaUtils
     )
-from waeup.kofa.utils.helpers import get_fileformat
+from waeup.kofa.utils.helpers import get_fileformat, to_timezone
+from waeup.kofa.students.catalog import StudentsQuery
+from waeup.kofa.students.export import get_payments
 
 
@@ -339,2 +341,58 @@
                 result['fingerprints'][num] = xmlrpclib.Binary(fp_file.read())
         return result
+
+    @grok.require('waeup.xmlrpc')
+    def get_bursary_data(self,
+            current_session=None, current_level=None, certcode=None,
+            current_mode=None, depcode=None):
+        """Returns bursary data of a subset of students.
+        """
+        if not current_session:
+            current_session = None
+        if not current_level:
+            current_level = None
+        if not depcode:
+            depcode = None
+        if not certcode:
+            certcode = None
+        if not current_mode:
+            current_mode = None
+        hitlist = []
+        cat = queryUtility(ICatalog, name='students_catalog')
+        results = list(
+            cat.searchResults(
+                current_session=(current_session, current_session),
+                current_level=(current_level, current_level),
+                certcode=(certcode, certcode),
+                current_mode=(current_mode, current_mode),
+                depcode=(depcode, depcode),
+                ))
+        payments = get_payments(results)
+        tz = getUtility(IKofaUtils).tzinfo
+        for payment in payments:
+            hitlist.append(
+                (
+                payment.student.student_id,
+                payment.student.matric_number,
+                payment.student.reg_number,
+                payment.student.firstname,
+                payment.student.middlename,
+                payment.student.lastname,
+                payment.student.state,
+                payment.student.current_session,
+                payment.student.entry_session,
+                payment.student.entry_mode,
+                payment.student.faccode,
+                payment.student.depcode,
+                payment.student.certcode,
+                payment.p_id,
+                payment.amount_auth,
+                payment.p_category,
+                payment.display_item,
+                payment.p_session,
+                payment.p_state,
+                str('%s#' % to_timezone(payment.creation_date, tz)),
+                str('%s#' % to_timezone(payment.payment_date, tz)),
+                )
+                )
+        return hitlist
