Ignore:
Timestamp:
10 Mar 2025, 16:40:53 (11 hours ago)
Author:
Henrik Bettermann
Message:

Implement required combi split payments.

File:
1 edited

Legend:

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

    r17947 r18034  
    4949    PORTRAIT_CHANGE_STATES = (ADMITTED, CLEARANCE,)
    5050
    51     REQUIRED_PAYMENTS_FRESH = {
     51    REQUIRED_PAYMENTS_FRESH_SCIENCE = {
    5252        'registration_fresh': 'Registration Fee (Fresh)',
    5353        'book': 'Book Deposit',
     
    5555        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
    5656        'municipal_fresh': 'Fresh Students Municipal Fee',
    57         }
    58 
     57        'matric': 'Matriculation Fee',
     58        'waecneco': 'WAEC/NECO Verification',
     59        'jambver': 'JAMB Verification Fee',
     60        'health_insurance': 'Student Health Insurance',
     61        'id_card': 'I.D. Card',
     62        'medical_screening': 'Medical Screening Fees',
     63        'science': 'Science Bench Fee',
     64        }
     65
     66    REQUIRED_PAYMENTS_FRESH_NON_SCIENCE = {
     67        'registration_fresh': 'Registration Fee (Fresh)',
     68        'book': 'Book Deposit',
     69        'develop': 'Development Fee',
     70        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
     71        'municipal_fresh': 'Fresh Students Municipal Fee',
     72        'matric': 'Matriculation Fee',
     73        'waecneco': 'WAEC/NECO Verification',
     74        'jambver': 'JAMB Verification Fee',
     75        'health_insurance': 'Student Health Insurance',
     76        'id_card': 'I.D. Card',
     77        'medical_screening': 'Medical Screening Fees',
     78        }
     79
     80    # all students (except PHM) returning
    5981    REQUIRED_PAYMENTS_RETURNING = {
    6082        'registration_return': 'Registration Fee (Returning)',
     
    6385        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
    6486        'municipal_returning': 'Returning Students Municipal Fee',
     87        'health_insurance': 'Student Health Insurance',
     88        }
     89
     90
     91    # all stdents (except PHM) final year
     92    REQUIRED_PAYMENTS_FINAL = {
     93        'registration_return': 'Registration Fee (Returning)',
     94        'book': 'Book Deposit',
     95        'develop': 'Development Fee',
     96        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
     97        'municipal_returning': 'Returning Students Municipal Fee',
     98        'health_insurance': 'Student Health Insurance',
     99        'alumni': 'Alumni Fees',
     100        'conv': 'Convocation Fees',
     101        'clearance': 'Clearance Fees',
     102        }
     103
     104    # PHM returning students
     105    REQUIRED_PAYMENTS_RETURNING_PHARMACY = {
     106        'registration_return': 'Registration Fee (Returning)',
     107        'book': 'Book Deposit',
     108        'develop': 'Development Fee',
     109        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
     110        'municipal_returning': 'Returning Students Municipal Fee',
     111        'health_insurance': 'Student Health Insurance',
     112        'lab_support': 'Lab Support',
     113        }
     114
     115    # PHM students final year
     116    REQUIRED_PAYMENTS_FINAL_PHARMACY = {
     117        'registration_return': 'Registration Fee (Returning)',
     118        'book': 'Book Deposit',
     119        'develop': 'Development Fee',
     120        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
     121        'municipal_returning': 'Returning Students Municipal Fee',
     122        'health_insurance': 'Student Health Insurance',
     123        'alumni': 'Alumni Fees',
     124        'conv': 'Convocation Fees',
     125        'clearance': 'Clearance Fees',
     126        'lab_support': 'Lab Support',
    65127        }
    66128
     
    87149        return
    88150
    89     def _requiredPaymentsMissing(self, student, session):
    90         # Deactivated on 29/09/20 (don't know why)
    91         return
    92 
     151    def _is_payment_for_final(self, student):
     152        studycourse = student['studycourse']
     153        certificate = getattr(studycourse,'certificate',None)
     154        current_level = studycourse.current_level
     155        if None in (current_level, certificate):
     156            return False
     157        end_level = certificate.end_level
     158        if current_level >= end_level-100:
     159            return True
     160        return False
     161
     162    def _collect_required_payment_items(self, student):
    93163        if student.is_postgrad:
    94164            rp = self.REQUIRED_PAYMENTS_PG
     165        elif student.is_fresh and student.faccode in ('ENG', 'HSC', 'NAS', 'PHM'):
     166            rp = self.REQUIRED_PAYMENTS_FRESH_SCIENCE
    95167        elif student.is_fresh:
    96             rp = self.REQUIRED_PAYMENTS_FRESH
     168            rp = self.REQUIRED_PAYMENTS_FRESH_NON_SCIENCE
     169        elif student.faccode == 'PHM' and self._is_payment_for_final(student):
     170            rp = self.REQUIRED_PAYMENTS_FINAL_PHARMACY
     171        elif student.faccode == 'PHM':
     172            rp = self.REQUIRED_PAYMENTS_RETURNING_PHARMACY
     173        elif self._is_payment_for_final(student):
     174            rp = self.REQUIRED_PAYMENTS_FINAL
    97175        else:
    98             rp = self.REQUIRED_PAYMENTS_RETURNING
     176            rp = REQUIRED_PAYMENTS_RETURNING
     177        return rp
     178
     179    def _requiredPaymentsMissing(self, student, session):
     180        # Has the required combi payment been made?
    99181        for ticket in student['payments'].values():
    100182            if ticket.p_category == 'required_combi'and \
     
    102184                ticket.p_state == 'paid':
    103185                return
     186        # If not, check single payments
     187        rp = self._collect_required_payment_items(student)
    104188        cats_missing = deepcopy(rp)
    105189        if len(student['payments']):
     
    114198        return "%s must be paid before Tution Fee. Make either single payments or make a 'Required Combi Payment'." % ', '.join(
    115199            cats_missing.values())
     200
     201    @property
     202    def _all_required_payments(self):
     203        return set(
     204            self.REQUIRED_PAYMENTS_PG.keys()
     205            + self.REQUIRED_PAYMENTS_FRESH_SCIENCE.keys()
     206            + self.REQUIRED_PAYMENTS_FRESH_NON_SCIENCE.keys()
     207            + self.REQUIRED_PAYMENTS_FINAL_PHARMACY.keys()
     208            + self.REQUIRED_PAYMENTS_RETURNING_PHARMACY.keys()
     209            + self.REQUIRED_PAYMENTS_FINAL.keys()
     210            + self.REQUIRED_PAYMENTS_RETURNING.keys()
     211            )
    116212
    117213    def samePaymentMade(self, student, category, p_item, p_session):
     
    158254            p_level = student['studycourse'].current_level
    159255            p_current = True
    160             if category in self.REQUIRED_PAYMENTS_FRESH.keys() \
    161                 + self.REQUIRED_PAYMENTS_RETURNING.keys() \
    162                 + ['schoolfee','schoolfee40','secondinstal'] \
     256            if category in list(self._all_required_payments) + ['required_combi',] \
    163257                and student.state == RETURNING:
    164258                # In case of school fee or required sundry fee payments the
     
    253347                p_item += u'%s + ' % categories[cat]
    254348            p_item = p_item.strip(' + ')
     349
    255350        elif category == 'required_combi':
    256             if student.is_postgrad:
    257                 rp = self.REQUIRED_PAYMENTS_PG
    258             elif student.is_fresh:
    259                 rp = self.REQUIRED_PAYMENTS_FRESH
    260             else:
    261                 rp = self.REQUIRED_PAYMENTS_RETURNING
    262             for cat in rp:
     351            rp = self._collect_required_payment_items(student)
     352            for cat in rp.keys():
    263353                fee_name = cat + '_fee'
    264354                cat_amount = getattr(academic_session, fee_name, 0.0)
     
    268358                p_item += u'%s + ' % rp[cat]
    269359            p_item = p_item.strip(' + ')
     360
    270361        else:
    271362            fee_name = category + '_fee'
Note: See TracChangeset for help on using the changeset viewer.