Ignore:
Timestamp:
4 Sep 2012, 07:09:29 (12 years ago)
Author:
Henrik Bettermann
Message:

Prepare for previous session payments but disable student payments completely. setPaymentDetails has to be written from the scratch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py

    r8981 r9155  
    4848        return new_session, new_level
    4949
    50     def setPaymentDetails(self, category, student):
     50    def setPaymentDetails(self, category, student,
     51            previous_session=None, previous_level=None):
    5152        """Create Payment object and set the payment data of a student for
    5253        the payment category specified.
    5354
    5455        """
    55         details = {}
    56         p_item = u''
    57         amount = 0.0
    58         error = u''
    59         p_session = student['studycourse'].current_session
    60         p_level = student['studycourse'].current_level
    61         session = str(p_session)
    62         try:
    63             academic_session = grok.getSite()['configuration'][session]
    64         except KeyError:
    65             return _(u'Session configuration object is not available.'), None
    66         # Determine fee.
    67         if category == 'transfer':
    68             amount = academic_session.transfer_fee
    69         elif category == 'gown':
    70             amount = academic_session.gown_fee
    71         elif category == 'bed_allocation':
    72             amount = academic_session.booking_fee
    73         elif category == 'hostel_maintenance':
    74             amount = academic_session.maint_fee
    75         elif category == 'clearance':
    76             try:
    77                 p_item = student['studycourse'].certificate.code
    78             except (AttributeError, TypeError):
    79                 return _('Study course data are incomplete.'), None
    80             if p_item in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
    81                 'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'):
    82                 amount = 17250.0
    83             else:
    84                 amount = 34250.0
    85         elif category == 'schoolfee':
    86             try:
    87                 certificate = student['studycourse'].certificate
    88                 p_item = certificate.code
    89             except (AttributeError, TypeError):
    90                 return _('Study course data are incomplete.'), None
    91             if student.state == CLEARED:
    92                 amount = getattr(certificate, 'school_fee_1', 0.0)
    93             elif student.state == RETURNING:
    94                 # In case of returning school fee payment the payment session
    95                 # and level contain the values of the session the student
    96                 # has paid for.
    97                 p_session, p_level = self.getReturningData(student)
    98                 amount = getattr(certificate, 'school_fee_2', 0.0)
    99                 try:
    100                     academic_session = grok.getSite()[
    101                         'configuration'][str(p_session)]
    102                 except KeyError:
    103                     return _(u'Session configuration object is not available.'), None
    104             elif student.is_postgrad and student.state == PAID:
    105                 # Returning postgraduate students also pay for the next session
    106                 # but their level always remains the same.
    107                 p_session += 1
    108                 amount = getattr(certificate, 'school_fee_2', 0.0)
    109                 try:
    110                     academic_session = grok.getSite()[
    111                         'configuration'][str(p_session)]
    112                 except KeyError:
    113                     return _(u'Session configuration object is not available.'), None
    114         if amount in (0.0, None):
    115             return _(u'Amount could not be determined.'), None
    116         # Add session specific penalty fee.
    117         if category == 'schoolfee' and student.is_postgrad:
    118             amount += academic_session.penalty_pg
    119         elif category == 'schoolfee':
    120             amount += academic_session.penalty_ug
    121         # Create ticket.
    122         for key in student['payments'].keys():
    123             ticket = student['payments'][key]
    124             if ticket.p_state == 'paid' and\
    125                ticket.p_category == category and \
    126                ticket.p_item == p_item and \
    127                ticket.p_session == p_session:
    128                   return _('This type of payment has already been made.'), None
    129         payment = createObject(u'waeup.StudentOnlinePayment')
    130         timestamp = ("%d" % int(time()*10000))[1:]
    131         payment.p_id = "p%s" % timestamp
    132         payment.p_category = category
    133         payment.p_item = p_item
    134         payment.p_session = p_session
    135         payment.p_level = p_level
    136         payment.amount_auth = amount
    137         return None, payment
     56        return _(u'Payment components not yet configured.'), None
     57
    13858
    13959    # FUTMinna prefix
Note: See TracChangeset for help on using the changeset viewer.