Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 11593)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 11596)
@@ -16,20 +16,13 @@
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##
-import os
 import shutil
 import tempfile
-import grok
-from StringIO import StringIO
 from hurry.workflow.interfaces import IWorkflowState
 from zope.component.hooks import setSite, clearSite
 from zope.component import getUtility, createObject
-from zope.interface import verify
 from waeup.kofa.app import University
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
 from waeup.kofa.students.accommodation import BedTicket
 from waeup.kofa.testing import FunctionalTestCase
-from waeup.kofa.interfaces import (
-    IExtFileStore, IFileStoreNameChooser)
-from waeup.kofa.students.interfaces import IStudentsUtils
 from waeup.aaue.testing import FunctionalLayer
 
@@ -265,94 +258,4 @@
         return
 
-    def test_get_returning_data(self):
-        # Student is in level 100, session 2004 with verdict A
-        utils = getUtility(IStudentsUtils)
-        self.assertEqual(utils.getReturningData(self.student),(2005, 200))
-        self.student['studycourse'].current_verdict = 'C'
-        self.assertEqual(utils.getReturningData(self.student),(2005, 110))
-        self.student['studycourse'].current_verdict = 'NEOR'
-        self.assertEqual(utils.getReturningData(self.student),(2005, 100))
-        return
-
-    def test_set_payment_details(self):
-        self.app['configuration']['2004'].gown_fee = 150.0
-        self.app['configuration']['2004'].transfer_fee = 90.0
-        self.app['configuration']['2004'].booking_fee = 150.0
-        self.app['configuration']['2004'].maint_fee = 180.0
-        self.app['configuration']['2004'].clearance_fee = 1234.0
-        self.app['configuration']['2004'].school_fee = 6666.0
-        utils = getUtility(IStudentsUtils)
-
-        configuration = createObject('waeup.SessionConfiguration')
-        configuration.academic_session = 2005
-        self.app['configuration'].addSessionConfiguration(configuration)
-        self.app['configuration']['2005'].school_fee = 7777.0
-
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
-        self.assertEqual(payment, None)
-        self.assertEqual(error, u'Wrong state.')
-
-        IWorkflowState(self.student).setState('cleared')
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
-        self.assertEqual(payment.p_level, 100)
-        self.assertEqual(payment.p_session, 2004)
-        self.assertEqual(payment.amount_auth, 6666.0)
-        self.assertEqual(payment.p_item, u'CERT1')
-        self.assertEqual(error, None)
-
-        # Add penalty fee ...
-        # ... for cleared
-        self.app['configuration']['2004'].penalty_ug = 99.0
-        # ... for returning
-        self.app['configuration']['2005'].penalty_ug = 88.0
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
-        self.assertEqual(payment.amount_auth, 6765.0)
-        IWorkflowState(self.student).setState('returning')
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
-        self.assertEqual(payment.p_level, 200)
-        self.assertEqual(payment.p_session, 2005)
-        self.assertEqual(payment.amount_auth, 7865.0)
-        self.assertEqual(payment.p_item, u'CERT1')
-        self.assertEqual(error, None)
-
-        error, payment = utils.setPaymentDetails('clearance',self.student)
-        self.assertEqual(payment.p_level, 100)
-        self.assertEqual(payment.p_session, 2004)
-        self.assertEqual(payment.amount_auth, 1234.0)
-        self.assertEqual(payment.p_item, u'CERT1')
-        self.assertEqual(error, None)
-
-        error, payment = utils.setPaymentDetails('gown',self.student)
-        self.assertEqual(payment.p_level, 100)
-        self.assertEqual(payment.p_session, 2004)
-        self.assertEqual(payment.amount_auth, 150.0)
-        self.assertEqual(payment.p_item, u'')
-        self.assertEqual(error, None)
-
-        error, payment = utils.setPaymentDetails('hostel_maintenance',self.student)
-        self.assertEqual(payment.p_level, 100)
-        self.assertEqual(payment.p_session, 2004)
-        self.assertEqual(payment.amount_auth, 180.0)
-        self.assertEqual(payment.p_item, u'')
-        self.assertEqual(error, None)
-
-        error, payment = utils.setPaymentDetails('bed_allocation',self.student)
-        self.assertEqual(payment.p_level, 100)
-        self.assertEqual(payment.p_session, 2004)
-        self.assertEqual(payment.amount_auth, 150.0)
-        self.assertEqual(payment.p_item, u'')
-        self.assertEqual(error, None)
-
-        error, payment = utils.setPaymentDetails('transfer',self.student)
-        self.assertEqual(payment.p_level, 100)
-        self.assertEqual(payment.p_session, 2004)
-        self.assertEqual(payment.amount_auth, 90.0)
-        self.assertEqual(payment.p_item, u'')
-        self.assertEqual(error, None)
-
-        error, payment = utils.setPaymentDetails('schoolfee',self.student, 2004, 100)
-        self.assertEqual(error, u'Previous session payment not yet implemented.')
-        return
-
     def deactivated_test_student_course_registration(self):
 
@@ -429,35 +332,3 @@
         return
 
-    def test_maxCredits(self):
-        dummy = object()
-        utils = getUtility(IStudentsUtils)
-        self.assertEqual(utils.maxCredits(dummy), 48)
-        return
-
-    def test_set_matric_number(self):
-        site = grok.getSite()
-        utils = getUtility(IStudentsUtils)
-        site['configuration'].next_matric_integer = 1
-        self.student.matric_number = None
-        msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(msg, None)
-        self.assertEqual(mnumber, 1)
-        self.assertEqual(self.student.matric_number, 'fac1/dep1/04/00001')
-        self.assertEqual(site['configuration'].next_matric_integer, 2)
-        # Part time have an extended matric number
-        self.student.matric_number = None
-        self.student['studycourse'].certificate.study_mode = 'ug_pt'
-        msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00002')
-        # Foundation programme students don't get matric number.
-        self.student.matric_number = None
-        self.student['studycourse'].certificate.study_mode = 'found'
-        msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(msg, 'Matriculation number cannot be set.')
-        self.assertEqual(mnumber, None)
-        # Certificate must be set.
-        self.student.matric_number = None
-        self.student['studycourse'].certificate = None
-        msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(msg, 'No certificate assigned.')
-        return
+
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py	(revision 11596)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py	(revision 11596)
@@ -0,0 +1,154 @@
+## $Id$
+##
+## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+import grok
+from hurry.workflow.interfaces import IWorkflowState
+from zope.component import getUtility, createObject
+from waeup.kofa.students.tests.test_browser import StudentsFullSetup
+from waeup.kofa.students.interfaces import IStudentsUtils
+from waeup.aaue.testing import FunctionalLayer
+
+class StudentsUtilsTests(StudentsFullSetup):
+
+    layer = FunctionalLayer
+
+    def test_get_returning_data(self):
+        # Student is in level 100, session 2004 with verdict A
+        utils = getUtility(IStudentsUtils)
+        self.assertEqual(utils.getReturningData(self.student),(2005, 200))
+        self.student['studycourse'].current_verdict = 'C'
+        self.assertEqual(utils.getReturningData(self.student),(2005, 110))
+        self.student['studycourse'].current_verdict = 'NEOR'
+        self.assertEqual(utils.getReturningData(self.student),(2005, 100))
+        return
+
+    def test_set_payment_details(self):
+        self.app['configuration']['2004'].gown_fee = 150.0
+        self.app['configuration']['2004'].transfer_fee = 90.0
+        self.app['configuration']['2004'].booking_fee = 150.0
+        self.app['configuration']['2004'].maint_fee = 180.0
+        self.app['configuration']['2004'].clearance_fee = 1234.0
+        self.app['configuration']['2004'].school_fee = 6666.0
+        utils = getUtility(IStudentsUtils)
+
+        configuration = createObject('waeup.SessionConfiguration')
+        configuration.academic_session = 2005
+        self.app['configuration'].addSessionConfiguration(configuration)
+        self.app['configuration']['2005'].school_fee = 7777.0
+
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment, None)
+        self.assertEqual(error, u'Wrong state.')
+
+        IWorkflowState(self.student).setState('cleared')
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 6666.0)
+        self.assertEqual(payment.p_item, u'CERT1')
+        self.assertEqual(error, None)
+
+        # Add penalty fee ...
+        # ... for cleared
+        self.app['configuration']['2004'].penalty_ug = 99.0
+        # ... for returning
+        self.app['configuration']['2005'].penalty_ug = 88.0
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.amount_auth, 6765.0)
+        IWorkflowState(self.student).setState('returning')
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.p_level, 200)
+        self.assertEqual(payment.p_session, 2005)
+        self.assertEqual(payment.amount_auth, 7865.0)
+        self.assertEqual(payment.p_item, u'CERT1')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('clearance',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 1234.0)
+        self.assertEqual(payment.p_item, u'CERT1')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('gown',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 150.0)
+        self.assertEqual(payment.p_item, u'')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('hostel_maintenance',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 180.0)
+        self.assertEqual(payment.p_item, u'')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('bed_allocation',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 150.0)
+        self.assertEqual(payment.p_item, u'')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('transfer',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 90.0)
+        self.assertEqual(payment.p_item, u'')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('schoolfee',self.student, 2004, 100)
+        self.assertEqual(error, u'Previous session payment not yet implemented.')
+        return
+
+    def test_maxCredits(self):
+        dummy = object()
+        utils = getUtility(IStudentsUtils)
+        self.assertEqual(utils.maxCredits(dummy), 48)
+        return
+
+    def test_setMatricNumber(self):
+        site = grok.getSite()
+        utils = getUtility(IStudentsUtils)
+        site['configuration'].next_matric_integer = 1
+        self.student.matric_number = None
+        # So far we don't set matric numbers of ft students.
+        msg, mnumber = utils.setMatricNumber(self.student)
+        self.assertEqual(msg, 'Matriculation number cannot be set.')
+        self.assertEqual(mnumber, None)
+        #self.assertEqual(msg, None)
+        #self.assertEqual(mnumber, 1)
+        #self.assertEqual(self.student.matric_number, 'fac1/dep1/04/00001')
+        #self.assertEqual(site['configuration'].next_matric_integer, 2)
+        # Part time have an extended matric number
+        self.student.matric_number = None
+        self.student['studycourse'].certificate.study_mode = 'ug_pt'
+        msg, mnumber = utils.setMatricNumber(self.student)
+        self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00001')
+        # Foundation programme students don't get matric number.
+        self.student.matric_number = None
+        self.student['studycourse'].certificate.study_mode = 'found'
+        msg, mnumber = utils.setMatricNumber(self.student)
+        self.assertEqual(msg, 'Matriculation number cannot be set.')
+        self.assertEqual(mnumber, None)
+        # Certificate must be set.
+        self.student.matric_number = None
+        self.student['studycourse'].certificate = None
+        msg, mnumber = utils.setMatricNumber(self.student)
+        self.assertEqual(msg, 'No certificate assigned.')
+        return
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 11593)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 11596)
@@ -71,5 +71,8 @@
                       (5, '1st Class Honours'))
 
-    def _constructMatricNumber(self, student, next_integer):
+    def constructMatricNumber(self, student):
+        next_integer = grok.getSite()['configuration'].next_matric_integer
+        if next_integer == 0:
+            return None
         faccode = student.faccode
         depcode = student.depcode
@@ -77,9 +80,12 @@
         if student.current_mode in ('ug_pt', 'de_pt'):
             return "PTP/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
-        if student.current_mode in ('pg_ft', 'pg_pt'):
-            return "SPS/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
-        if student.current_mode == 'found':
-            return None
-        return "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
+        #if student.current_mode in ('pg_ft', 'pg_pt'):
+        #    return "SPS/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
+        #if student.current_mode in ('dp_ft', 'dp_pt'):
+        #    return "DIP/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
+        #if student.current_mode == 'found':
+        #    return None
+        #return "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
+        return None
 
     def getReturningData(self, student):
