Ignore:
Timestamp:
17 Aug 2023, 07:43:50 (15 months ago)
Author:
Henrik Bettermann
Message:

Fix school fees summary.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py

    r17137 r17546  
    265265        SF_PAYMENTS = ('schoolfee', 'schoolfee40', 'secondinstal', 'clearance')
    266266        sf_paid = dict()
    267         session = self.context.student.entry_session
    268         while session < cs + 2:
    269             sf_paid[session] = 0.0
    270             session += 1
    271         sessions = sf_paid.keys()
    272267        try:
    273268            certificate = self.context.student['studycourse'].certificate
    274269        except (AttributeError, TypeError):
    275             return sf_paid, 0, 0
    276         total_sf = 0.0
    277         if self.context.student in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
    278             sf = getattr(certificate, 'school_fee_1', 0.0)
    279         else:
    280             sf = getattr(certificate, 'school_fee_2', 0.0)
    281         if sf is not None:
    282             total_sf = sf
     270            return sf_paid, 0
     271        session = self.context.student.entry_session
     272        # Initiliaze sf_paid dict with items
     273        # session: [school fee in session,, amount paid in session, amount due]
     274        sf_paid[session] = [getattr(certificate, 'school_fee_1', 0.0), 0.0, 0.0]
     275        while session < cs + 1:
     276            session += 1
     277            sf_paid[session]= [getattr(certificate, 'school_fee_2', 0.0), 0.0, 0.0]
     278        sessions = sf_paid.keys()
    283279        brought_fwd = 0.0
     280        # Collect all payments made or brought forward
    284281        for ticket in self.context.values():
    285282            amt = ticket.net_amt
     
    289286                ticket.p_state == 'paid' and \
    290287                ticket.p_session in sessions:
    291                 sf_paid[ticket.p_session] += amt
     288                sf_paid[ticket.p_session][1] += amt
    292289            if ticket.p_state != 'paid' and\
    293290               ticket.p_category == 'brought_fwd':
    294291                  brought_fwd += ticket.amount_auth
    295         return sorted(sf_paid.items(), key=lambda value: value[0]), total_sf, brought_fwd
     292        # Calculate due, first entry session
     293        entry_session = sessions[0]
     294        #   amount due in session =  brought forward from previous sessions + school fee in session - amount paid in session
     295        sf_paid[entry_session][2] = brought_fwd + sf_paid[entry_session][0] - sf_paid[entry_session][1]
     296        for session in sessions[1:]:
     297            #   amount due in session =  brought forward from previous session + school fee in session - amount paid in session
     298            sf_paid[session][2] = sf_paid[session-1][2] + sf_paid[session][0] - sf_paid[session][1]
     299        return sorted(sf_paid.items(), key=lambda value: value[0]), brought_fwd
    296300
    297301    def update(self):
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser_templates/paymentsmanagepage.pt

    r17483 r17546  
    4444  </div>
    4545  <br /><br />
    46   <p tal:condition="python: False">
    47   <strong>Balance Brought Forward:</strong> <span tal:content ="python: view.sfp_made[2]">BROUGHTFORWARD</span>
     46  <p tal:condition="python: True">
     47  <strong>Balance Brought Forward:</strong> <span tal:content ="python: view.sfp_made[1]">BROUGHTFORWARD</span>
    4848  </p>
    4949  <br />
    50   <table class="table" style="width: 50%;" tal:condition="python: False">
     50  <table class="table" style="width: 50%;" tal:condition="python: True">
    5151    <thead>
    5252    <tr>
    5353      <th i18n:translate="">Session</th>
    5454      <th i18n:translate="">School Fees</th>
    55       <th i18n:translate="">Sum Paid</th>
     55      <th i18n:translate="">Amount Paid</th>
    5656      <th i18n:translate="">Amount Due</th>
    5757    </tr>
     
    6060      <tr tal:repeat="sfpm python: view.sfp_made[0]">
    6161        <td tal:content ="python: '%s/%s' %(sfpm[0],sfpm[0]+1)">SESSION</td>
    62         <td tal:content ="python: view.sfp_made[1]">TOTAL</td>
    63         <td tal:content ="python: sfpm[1]">AMOUNT</td>
    64         <td tal:content ="python: view.sfp_made[1]+view.sfp_made[2]-sfpm[1]">DUE</td>
    65        
     62        <td tal:content ="python: sfpm[1][0]">FEE</td>
     63        <td tal:content ="python: sfpm[1][1]">AMOUNT PAID</td>
     64        <td tal:content ="python: sfpm[1][2]">TOTAL AMOUNT DUE</td>
    6665      </tr>
    6766    </tbody>
Note: See TracChangeset for help on using the changeset viewer.