Index: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py
===================================================================
--- main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py	(revision 17545)
+++ main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py	(revision 17546)
@@ -265,21 +265,18 @@
         SF_PAYMENTS = ('schoolfee', 'schoolfee40', 'secondinstal', 'clearance')
         sf_paid = dict()
-        session = self.context.student.entry_session
-        while session < cs + 2:
-            sf_paid[session] = 0.0
-            session += 1
-        sessions = sf_paid.keys()
         try:
             certificate = self.context.student['studycourse'].certificate
         except (AttributeError, TypeError):
-            return sf_paid, 0, 0
-        total_sf = 0.0
-        if self.context.student in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
-            sf = getattr(certificate, 'school_fee_1', 0.0)
-        else:
-            sf = getattr(certificate, 'school_fee_2', 0.0)
-        if sf is not None:
-            total_sf = sf
+            return sf_paid, 0
+        session = self.context.student.entry_session
+        # Initiliaze sf_paid dict with items
+        # session: [school fee in session,, amount paid in session, amount due]
+        sf_paid[session] = [getattr(certificate, 'school_fee_1', 0.0), 0.0, 0.0]
+        while session < cs + 1:
+            session += 1
+            sf_paid[session]= [getattr(certificate, 'school_fee_2', 0.0), 0.0, 0.0]
+        sessions = sf_paid.keys()
         brought_fwd = 0.0
+        # Collect all payments made or brought forward
         for ticket in self.context.values():
             amt = ticket.net_amt
@@ -289,9 +286,16 @@
                 ticket.p_state == 'paid' and \
                 ticket.p_session in sessions:
-                sf_paid[ticket.p_session] += amt
+                sf_paid[ticket.p_session][1] += amt
             if ticket.p_state != 'paid' and\
                ticket.p_category == 'brought_fwd':
                   brought_fwd += ticket.amount_auth
-        return sorted(sf_paid.items(), key=lambda value: value[0]), total_sf, brought_fwd
+        # Calculate due, first entry session
+        entry_session = sessions[0]
+        #   amount due in session =  brought forward from previous sessions + school fee in session - amount paid in session
+        sf_paid[entry_session][2] = brought_fwd + sf_paid[entry_session][0] - sf_paid[entry_session][1]
+        for session in sessions[1:]:
+            #   amount due in session =  brought forward from previous session + school fee in session - amount paid in session
+            sf_paid[session][2] = sf_paid[session-1][2] + sf_paid[session][0] - sf_paid[session][1]
+        return sorted(sf_paid.items(), key=lambda value: value[0]), brought_fwd
 
     def update(self):
Index: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser_templates/paymentsmanagepage.pt
===================================================================
--- main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser_templates/paymentsmanagepage.pt	(revision 17545)
+++ main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser_templates/paymentsmanagepage.pt	(revision 17546)
@@ -44,14 +44,14 @@
   </div>
   <br /><br />
-  <p tal:condition="python: False">
-  <strong>Balance Brought Forward:</strong> <span tal:content ="python: view.sfp_made[2]">BROUGHTFORWARD</span>
+  <p tal:condition="python: True">
+  <strong>Balance Brought Forward:</strong> <span tal:content ="python: view.sfp_made[1]">BROUGHTFORWARD</span>
   </p>
   <br />
-  <table class="table" style="width: 50%;" tal:condition="python: False">
+  <table class="table" style="width: 50%;" tal:condition="python: True">
     <thead>
     <tr>
       <th i18n:translate="">Session</th>
       <th i18n:translate="">School Fees</th>
-      <th i18n:translate="">Sum Paid</th>
+      <th i18n:translate="">Amount Paid</th>
       <th i18n:translate="">Amount Due</th>
     </tr>
@@ -60,8 +60,7 @@
       <tr tal:repeat="sfpm python: view.sfp_made[0]">
         <td tal:content ="python: '%s/%s' %(sfpm[0],sfpm[0]+1)">SESSION</td>
-        <td tal:content ="python: view.sfp_made[1]">TOTAL</td>
-        <td tal:content ="python: sfpm[1]">AMOUNT</td>
-        <td tal:content ="python: view.sfp_made[1]+view.sfp_made[2]-sfpm[1]">DUE</td>
-        
+        <td tal:content ="python: sfpm[1][0]">FEE</td>
+        <td tal:content ="python: sfpm[1][1]">AMOUNT PAID</td>
+        <td tal:content ="python: sfpm[1][2]">TOTAL AMOUNT DUE</td>
       </tr>
     </tbody>
