Index: main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py	(revision 9006)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py	(revision 9152)
@@ -221,15 +221,36 @@
         utils = getUtility(IStudentsUtils)
 
+        self.student.nationality = u'NG'
+
         configuration = createObject('waeup.SessionConfiguration')
         configuration.academic_session = 2005
         self.app['configuration'].addSessionConfiguration(configuration)
 
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, None, None)
         self.assertEqual(payment, None)
-        self.assertEqual(error, u'Amount could not be determined.')
-
+        self.assertTrue(u'Amount could not be determined.' in error)
+
+        # Previous session payment, fresh and returning
+        # are being distinguished by their entry_level
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, 2004, 300)
+        self.assertEqual(payment.amount_auth, 40000.0)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.p_level, 300)
+        self.assertFalse(payment.p_current)
+        self.student['studycourse'].entry_session = 2003
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, 2004, 300)
+        self.assertEqual(payment.amount_auth, 20000.0)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.p_level, 300)
+        self.assertFalse(payment.p_current)
+
+        # Current payment, fresh and returning
+        # are being distinguished by their state
         IWorkflowState(self.student).setState('cleared')
-        self.student.nationality = u'NG'
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
@@ -237,4 +258,5 @@
         self.assertEqual(payment.p_item, u'CERT1')
         self.assertEqual(error, None)
+        self.assertTrue(payment.p_current)
 
         # Add penalty fee ...
@@ -243,9 +265,11 @@
         # ... for returning
         self.app['configuration']['2005'].penalty_ug = 88.0
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, None, None)
         self.assertEqual(payment.amount_auth, 40099.0)
 
         IWorkflowState(self.student).setState('returning')
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 200)
         self.assertEqual(payment.p_session, 2005)
@@ -255,5 +279,6 @@
 
         self.student.is_staff = True
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails('schoolfee',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 200)
         self.assertEqual(payment.p_session, 2005)
@@ -266,5 +291,6 @@
         self.student.nationality = u'DE'
         self.certificate.school_fee_3 = 60000.0
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails(
+            'schoolfee', self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
@@ -277,5 +303,6 @@
         self.student.nationality = u'DE'
         self.certificate.school_fee_4 = 20000.0
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        error, payment = utils.setPaymentDetails(
+            'schoolfee', self.student, None, None)
         self.assertEqual(payment.p_level, 200)
         self.assertEqual(payment.p_session, 2005)
@@ -284,5 +311,6 @@
         self.assertEqual(error, None)
 
-        error, payment = utils.setPaymentDetails('clearance',self.student)
+        error, payment = utils.setPaymentDetails('clearance',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
@@ -291,5 +319,6 @@
         self.assertEqual(error, None)
 
-        error, payment = utils.setPaymentDetails('gown',self.student)
+        error, payment = utils.setPaymentDetails('gown',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
@@ -298,5 +327,6 @@
         self.assertEqual(error, None)
 
-        error, payment = utils.setPaymentDetails('hostel_maintenance',self.student)
+        error, payment = utils.setPaymentDetails('hostel_maintenance',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
@@ -305,5 +335,6 @@
         self.assertEqual(error, None)
 
-        error, payment = utils.setPaymentDetails('bed_allocation',self.student)
+        error, payment = utils.setPaymentDetails('bed_allocation',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
@@ -312,5 +343,6 @@
         self.assertEqual(error, None)
 
-        error, payment = utils.setPaymentDetails('transfer',self.student)
+        error, payment = utils.setPaymentDetails('transfer',
+            self.student, None, None)
         self.assertEqual(payment.p_level, 100)
         self.assertEqual(payment.p_session, 2004)
