Index: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py
===================================================================
--- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py	(revision 13521)
+++ main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py	(revision 13535)
@@ -547,9 +547,7 @@
         self.browser.open(self.student_path)
         self.browser.getLink("Get Matriculation Number").click()
-        self.assertTrue('Matriculation number ND/15/dep1/FT/010 assigned.'
+        self.assertTrue('Matriculation number ND/15/dep1/FT/001 assigned.'
             in self.browser.contents)
-        self.assertEqual(self.student.matric_number, 'ND/15/dep1/FT/010')
-        self.assertEqual(self.app['faculties']['fac1']['dep1'].next_matric_dict,
-                         {2015: 11})
+        self.assertEqual(self.student.matric_number, 'ND/15/dep1/FT/001')
         self.assertRaises(
             LinkNotFoundError,
@@ -560,5 +558,5 @@
         logcontent = open(logfile).read()
         self.assertTrue('W1000000 - waeup.kwarapoly.students.browser.StudentGetMatricNumberView - '
-                        'W1000000 - ND/15/dep1/FT/010 assigned' in logcontent)
+                        'W1000000 - ND/15/dep1/FT/001 assigned' in logcontent)
         return
 
Index: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_utils.py
===================================================================
--- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_utils.py	(revision 13521)
+++ main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_utils.py	(revision 13535)
@@ -5,4 +5,5 @@
 from waeup.kofa.university.faculty import Faculty
 from waeup.kofa.university.department import Department
+from waeup.kofa.students.student import Student
 from waeup.kofa.students.interfaces import IStudentsUtils
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
@@ -48,4 +49,14 @@
 
     def test_setMatricNumber(self):
+        # Add second student
+        secondstudent = Student()
+        secondstudent.firstname = u'second'
+        secondstudent.lastname = u'Student'
+        self.app['students'].addStudent(secondstudent)
+        student_id = secondstudent.student_id
+        secondstudent['studycourse'].certificate = self.certificate
+        secondstudent['studycourse'].entry_session = 2015
+        secondstudent['studycourse'].entry_mode = 'nd_ft'
+        IWorkflowState(secondstudent).setState('school fee paid')
         utils = getUtility(IStudentsUtils)
         self.student.matric_number = None
@@ -59,25 +70,15 @@
         IWorkflowState(self.student).setState('school fee paid')
         msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(self.student.matric_number, 'ND/15/dep1/FT/010')
-        self.assertEqual(
-            self.app['faculties']['fac1']['dep1'].next_matric_dict,
-            {2015: 11})
-        # setting a new matric number in 2016, extends next_matric_dict
-        self.student['studycourse'].entry_session = 2016
-        self.student.matric_number = None
-        msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(
-            self.app['faculties']['fac1']['dep1'].next_matric_dict,
-            {2015: 11, 2016: 11})
-        # setting a new matric number in 2014 again, increases the counter
-        self.student.matric_number = None
-        msg, mnumber = utils.setMatricNumber(self.student)
-        self.assertEqual(
-            self.app['faculties']['fac1']['dep1'].next_matric_dict,
-            {2015: 11, 2016: 12})
-        # matric number must not exist
+        self.assertEqual(self.student.matric_number, 'ND/15/dep1/FT/001')
         msg, mnumber = utils.setMatricNumber(self.student)
         self.assertEqual(msg, 'Matriculation number already set.')
-        # certificate must be set.
+        # Second student gets nex matric number
+        msg, mnumber = utils.setMatricNumber(secondstudent)
+        self.assertEqual(secondstudent.matric_number, 'ND/15/dep1/FT/002')
+        self.student.matric_number = u'ND/15/dep1/FT/011'
+        secondstudent.matric_number = None
+        msg, mnumber = utils.setMatricNumber(secondstudent)
+        self.assertEqual(secondstudent.matric_number, 'ND/15/dep1/FT/012')
+        # Certificate must be set.
         self.student.matric_number = None
         self.student['studycourse'].certificate = None
Index: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/utils.py
===================================================================
--- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/utils.py	(revision 13521)
+++ main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/utils.py	(revision 13535)
@@ -19,5 +19,5 @@
 import random
 from time import time
-from zope.component import createObject, getUtility
+from zope.component import createObject, getUtility, queryUtility
 from zope.catalog.interfaces import ICatalog
 from waeup.kofa.interfaces import CLEARED, RETURNING, PAID
@@ -313,22 +313,6 @@
 
     def increaseMatricInteger(self, student):
-        """Increase counter for matric numbers.
-        """
-        cert = getattr(student.get('studycourse', None), 'certificate', None)
-        entry_session = getattr(
-            student.get('studycourse', None), 'entry_session', None)
-        dep = cert.__parent__.__parent__
-        next_matric_dict = getattr(dep, 'next_matric_dict', None)
-        if not next_matric_dict:
-            # add next_matric_dict attribute
-            dep.next_matric_dict = {}
-        if not dep.next_matric_dict.get(entry_session, None):
-            # initialize counter element with 11
-            dep.next_matric_dict[entry_session] = 11
-            dep._p_changed = True
-            return
-        # increase counter value of entry_session
-        dep.next_matric_dict[entry_session] += 1
-        dep._p_changed = True
+        """We don't use a persistent counter in Kwarapoly.
+        """
         return
 
@@ -343,7 +327,10 @@
         STA = Department Code
         FT = Study Mode Suffix
-        015 = Serial Number (Every department starts from "001" every
+        015 = Serial Number (Every programme starts from "001" every
         session and the numbers build up arithmetically)
         """
+
+        return _('Matriculation assgnment deactivated.'), None
+
         cert = getattr(student.get('studycourse', None), 'certificate', None)
         entry_session = getattr(
@@ -362,19 +349,18 @@
         except ValueError:
             return _('Matriculation number cannot be set.'), None
-        dep = cert.__parent__.__parent__
-        next_integer = getattr(
-            dep, 'next_matric_dict', {}).get(entry_session, 10)
-
-        #############################################
-        # self-repair, can be removed after a while
-        if next_integer == 2:
-            next_integer == 10
-            dep.next_matric_dict[entry_session] = 10
-            dep._p_changed = True
-        #############################################
-
         entry_year = entry_session - 100*(entry_session/100)
-        matric_number = "%s/%s/%s/%s/%03d" % (
-            prefix, entry_year, student.depcode, suffix, next_integer)
+        part1 =  "%s/%s/%s/%s/" % (
+            prefix, entry_year, student.depcode, suffix)
+        cat = queryUtility(ICatalog, name='students_catalog')
+        results = cat.searchResults(matric_number=(part1+'0000', part1+'9999'))
+        if not len(results):
+            return None, part1 + '001'
+        try:
+            numbers = [int(i.matric_number.replace(part1, ''))
+                       for i in results if i.matric_number]
+        except ValueError:
+            return _('Matriculation number cannot be determined.'), None
+        counter = max(numbers) + 1
+        matric_number = "%s%03d" % (part1, counter)
         return None, matric_number
 
