Changeset 14333 for main


Ignore:
Timestamp:
11 Dec 2016, 09:02:09 (8 years ago)
Author:
Henrik Bettermann
Message:

Start customization of payment components.

Location:
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri
Files:
2 edited

Legend:

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

    r14332 r14333  
    2323from kofacustom.coewarri.interfaces import MessageFactory as _
    2424
     25
     26def local_nonlocal(student):
     27    lga = getattr(student, 'lga')
     28    if lga and lga.startswith('delta'):
     29        return 'local'
     30    else:
     31        return 'non-local'
     32
    2533class CustomStudentsUtils(NigeriaStudentsUtils):
    2634    """A collection of customized methods.
    2735
    2836    """
     37
     38    def setPaymentDetails(self, category, student,
     39            previous_session, previous_level):
     40        """Create a payment ticket and set the payment data of a
     41        student for the payment category specified.
     42        """
     43        p_item = u''
     44        amount = 0.0
     45        if previous_session:
     46            if previous_session < student['studycourse'].entry_session:
     47                return _('The previous session must not fall below '
     48                         'your entry session.'), None
     49            if category == 'schoolfee':
     50                # School fee is always paid for the following session
     51                if previous_session > student['studycourse'].current_session:
     52                    return _('This is not a previous session.'), None
     53            else:
     54                if previous_session > student['studycourse'].current_session - 1:
     55                    return _('This is not a previous session.'), None
     56            p_session = previous_session
     57            p_level = previous_level
     58            p_current = False
     59        else:
     60            p_session = student['studycourse'].current_session
     61            p_level = student['studycourse'].current_level
     62            p_current = True
     63        academic_session = self._getSessionConfiguration(p_session)
     64        if academic_session == None:
     65            return _(u'Session configuration object is not available.'), None
     66        # Determine fee.
     67        if category == 'schoolfee':
     68            try:
     69                certificate = student['studycourse'].certificate
     70                p_item = certificate.code
     71            except (AttributeError, TypeError):
     72                return _('Study course data are incomplete.'), None
     73            if previous_session:
     74                # Students can pay for previous sessions in all
     75                # workflow states.  Fresh students are excluded by the
     76                # update method of the PreviousPaymentAddFormPage.
     77                if previous_level == 100:
     78                    amount = getattr(certificate, 'school_fee_1', 0.0)
     79                else:
     80                    amount = getattr(certificate, 'school_fee_2', 0.0)
     81            else:
     82                if student.state == CLEARED:
     83                    amount = getattr(certificate, 'school_fee_1', 0.0)
     84                elif student.state == RETURNING:
     85                    # In case of returning school fee payment the
     86                    # payment session and level contain the values of
     87                    # the session the student has paid for. Payment
     88                    # session is always next session.
     89                    p_session, p_level = self.getReturningData(student)
     90                    academic_session = self._getSessionConfiguration(p_session)
     91                    if academic_session == None:
     92                        return _(
     93                            u'Session configuration object is not available.'
     94                            ), None
     95                    amount = getattr(certificate, 'school_fee_2', 0.0)
     96                elif student.is_postgrad and student.state == PAID:
     97                    # Returning postgraduate students also pay for the
     98                    # next session but their level always remains the
     99                    # same.
     100                    p_session += 1
     101                    academic_session = self._getSessionConfiguration(p_session)
     102                    if academic_session == None:
     103                        return _(
     104                            u'Session configuration object is not available.'
     105                            ), None
     106                    amount = getattr(certificate, 'school_fee_2', 0.0)
     107        elif category == 'clearance':
     108            try:
     109                p_item = student['studycourse'].certificate.code
     110            except (AttributeError, TypeError):
     111                return _('Study course data are incomplete.'), None
     112            amount = academic_session.clearance_fee
     113        elif category == 'bed_allocation':
     114            p_item = self.getAccommodationDetails(student)['bt']
     115            amount = academic_session.booking_fee
     116        elif category == 'hostel_maintenance':
     117            amount = 0.0
     118            bedticket = student['accommodation'].get(
     119                str(student.current_session), None)
     120            if bedticket is not None and bedticket.bed is not None:
     121                p_item = bedticket.bed_coordinates
     122                if bedticket.bed.__parent__.maint_fee > 0:
     123                    amount = bedticket.bed.__parent__.maint_fee
     124                else:
     125                    # fallback
     126                    amount = academic_session.maint_fee
     127            else:
     128                return _(u'No bed allocated.'), None
     129        elif category == 'transcript':
     130            amount = academic_session.transcript_fee
     131        elif category == 'transfer':
     132            amount = academic_session.transfer_fee
     133        elif category == 'late_registration':
     134            amount = academic_session.late_registration_fee
     135        if amount in (0.0, None):
     136            return _('Amount could not be determined.'), None
     137        if self.samePaymentMade(student, category, p_item, p_session):
     138            return _('This type of payment has already been made.'), None
     139        if self._isPaymentDisabled(p_session, category, student):
     140            return _('This category of payments has been disabled.'), None
     141        payment = createObject(u'waeup.StudentOnlinePayment')
     142        timestamp = ("%d" % int(time()*10000))[1:]
     143        payment.p_id = "p%s" % timestamp
     144        payment.p_category = category
     145        payment.p_item = p_item
     146        payment.p_session = p_session
     147        payment.p_level = p_level
     148        payment.p_current = p_current
     149        payment.amount_auth = amount
     150        return None, payment
    29151
    30152    # prefix
  • main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/utils/utils.py

    r14126 r14333  
    3232        'prence': 'Pre-NCE Programme',
    3333        }
     34
     35    STUDY_MODES_DICT = {
     36        'ume_ft': 'UME Full Time',
     37        'ug_ft': 'Undergraduate Full Time',
     38        'ug_pt': 'Undergraduate Part Time',
     39        'dp_pt': 'Diploma Part Time',
     40        'ct_ft': 'Certificate Full Time',
     41        'dp_ft': 'Diploma Full Time',
     42        'de_ft': 'Direct Entry Full Time',
     43        'de_pt': 'Direct Entry Part Time',
     44        'nd_ft': 'National Diploma Full Time',
     45        'nd_pt': 'National Diploma Part Time',
     46        'hnd_ft': 'Higher National Diploma Full Time',
     47        'hnd_pt': 'Higher National Diploma Part Time',
     48        'pg_ft': 'Postgraduate Full Time',
     49        'pg_pt': 'Postgraduate Part Time',
     50        'pgd_ft': 'Postgraduate Diploma Full Time',
     51        'pgd_pt': 'Postgraduate Diploma Part Time',
     52        'special_pg_pt': 'Special Postgraduate Part Time',
     53        'nce_ft': 'NCE Full Time',
     54        'nce_pt': 'NCE Part Time',
     55        'ug_sw': 'Undergraduate Sandwich',
     56        'nce_sw': 'NCE Sandwich',
     57        'jm_ft': 'Joint Matriculation Full Time',
     58        'ph_ft': 'Post Higher Education Full Time',
     59        'transfer_pt': 'Transfer Part Time',
     60        'transfer_ft': 'Transfer Full Time',
     61        'ct_pt': 'Certificate Part Time',
     62        'rmd_ft': 'Remedial with deficiencies',
     63        'rm_ft': 'Remedial',
     64        'transfer': 'Transfer',
     65        'prence': 'Pre-NCE',
     66        'prend': 'Pre-ND',
     67        'pce': 'PCE',
     68        'pd_ft': 'Professional Diploma in Education',
     69        'found': 'Foundation',
     70        'no': 'no application',
     71        }
Note: See TracChangeset for help on using the changeset viewer.