## $Id: utils.py 17043 2022-07-28 20:34:46Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """General helper functions and utilities for the application section. """ from time import time from datetime import datetime from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils from waeup.kofa.applicants.workflow import (INITIALIZED, STARTED, PAID, ADMITTED, NOT_ADMITTED, SUBMITTED, CREATED) from kofacustom.edocons.applicants.interfaces import DESTINATION_COST from kofacustom.edocons.interfaces import MessageFactory as _ class ApplicantsUtils(NigeriaApplicantsUtils): """A collection of parameters and methods subject to customization. """ ADDITIONAL_FILES = ( ('Testimonial','testimonial'), ('Statement of Result','res_stat'), ) SEPARATORS_DICT = { 'form.applicant_id': _(u'Base Data'), 'form.course1': _(u'Programmes/Courses Desired'), 'form.hq_type': _(u'Higher Education Record'), 'form.presently': _(u'Course or Programme Presently Attending'), 'form.nysc_year': _(u'NYSC Information'), 'form.employer': _(u'Employment History'), 'form.jamb_subjects': _(u'JAMB Data'), 'form.jamb_subjects_list': _(u'JAMB Data'), 'form.notice': _(u'Application Process Information'), 'form.pp_school': _(u'Post Primary School Qualification'), 'form.presently_inst': _(u'Presently attending a course or programme'), 'form.fst_sit_fname': _(u'First Sitting Record'), 'form.scd_sit_fname': _(u'Second Sitting Record'), 'form.referees': _(u'Referees'), 'form.cbt_score': _(u'CBT Data'), } APP_TYPES_DICT = { 'ase': ['Admission Screening Exercise', 'ASE'], 'ct': ['Certificate Programmes', 'CTP'], 'app': ['General Studies', 'APP'], 'tsc': ['Transcript', 'TRF'], } def setPaymentDetails(self, container, payment, applicant): """Set the payment data of an applicant. In contrast to its `StudentsUtils` counterpart, the payment ticket must exist and is an argument of this method. """ timestamp = ("%d" % int(time()*10000))[1:] payment.p_id = "p%s" % timestamp payment.p_item = container.title if container.year: payment.p_session = container.year else: payment.p_session = datetime.now().year payment.amount_auth = 0.0 if applicant.special: if applicant.special_application: try: session_config = grok.getSite()['configuration'][ str(payment.p_session)] except KeyError: return _(u'Session configuration object is not available.') fee_name = applicant.special_application + '_fee' payment.amount_auth = getattr(session_config, fee_name, None) payment.p_category = applicant.special_application if payment.amount_auth in (0.0, None): return _('Amount could not be determined. Have you saved the form?') return elif applicant.container_code.startswith('tsc'): if not applicant.charge: return _(u'No transcript charge selected.') cost = DESTINATION_COST[applicant.charge][1] payment.amount_auth = applicant.no_copies * cost if applicant.curriculum: payment.amount_auth += applicant.no_copies * 5000 payment.p_category = 'transcript' return payment.p_category = 'application' container_fee = container.application_fee if not container_fee: return _('Amount could not be determined.') payment.amount_auth = container_fee return