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

Implement previous session payment.

File:
1 edited

Legend:

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

    r9006 r9152  
    4848        return new_session, new_level
    4949
    50     def setPaymentDetails(self, category, student):
     50    def setPaymentDetails(self, category, student,
     51            previous_session, previous_level):
    5152        """Create Payment object and set the payment data of a student for
    5253        the payment category specified.
     
    5758        amount = 0.0
    5859        error = u''
    59         p_session = student['studycourse'].current_session
    60         p_level = student['studycourse'].current_level
     60        if previous_session:
     61            p_session = previous_session
     62            p_level = previous_level
     63            p_current = False
     64        else:
     65            p_session = student['studycourse'].current_session
     66            p_level = student['studycourse'].current_level
     67            p_current = True
    6168        session = str(p_session)
    6269        try:
     
    8996            except (AttributeError, TypeError):
    9097                return _('Study course data are incomplete.'), None
    91             if student.state == CLEARED:
    92                 if student.is_foreigner:
    93                     amount = getattr(certificate, 'school_fee_3', 0.0)
     98            if previous_session:
     99                if student.current_session == student['studycourse'].entry_session:
     100                    if student.is_foreigner:
     101                        amount = getattr(certificate, 'school_fee_3', 0.0)
     102                    else:
     103                        amount = getattr(certificate, 'school_fee_1', 0.0)
    94104                else:
    95                     amount = getattr(certificate, 'school_fee_1', 0.0)
    96             elif student.state == RETURNING:
    97                 # In case of returning school fee payment the payment session
    98                 # and level contain the values of the session the student
    99                 # has paid for.
    100                 p_session, p_level = self.getReturningData(student)
    101                 if student.is_foreigner:
    102                     amount = getattr(certificate, 'school_fee_4', 0.0)
    103                 else:
    104                     amount = getattr(certificate, 'school_fee_2', 0.0)
    105                 try:
    106                     academic_session = grok.getSite()[
    107                         'configuration'][str(p_session)]
    108                 except KeyError:
    109                     return _(u'Session configuration object is not available.'), None
    110             elif student.is_postgrad and student.state == PAID:
    111                 # Returning postgraduate students also pay for the next session
    112                 # but their level always remains the same.
    113                 p_session += 1
    114                 if student.is_foreigner:
    115                     amount = getattr(certificate, 'school_fee_4', 0.0)
    116                 else:
    117                     amount = getattr(certificate, 'school_fee_2', 0.0)
    118                 try:
    119                     academic_session = grok.getSite()[
    120                         'configuration'][str(p_session)]
    121                 except KeyError:
    122                     return _(u'Session configuration object is not available.'), None
     105                    if student.is_foreigner:
     106                        amount = getattr(certificate, 'school_fee_4', 0.0)
     107                    else:
     108                        amount = getattr(certificate, 'school_fee_2', 0.0)
     109            else:
     110                if student.state == CLEARED:
     111                    if student.is_foreigner:
     112                        amount = getattr(certificate, 'school_fee_3', 0.0)
     113                    else:
     114                        amount = getattr(certificate, 'school_fee_1', 0.0)
     115                elif student.state == RETURNING:
     116                    # In case of returning school fee payment the payment session
     117                    # and level contain the values of the session the student
     118                    # has paid for.
     119                    p_session, p_level = self.getReturningData(student)
     120                    if student.is_foreigner:
     121                        amount = getattr(certificate, 'school_fee_4', 0.0)
     122                    else:
     123                        amount = getattr(certificate, 'school_fee_2', 0.0)
     124                    try:
     125                        academic_session = grok.getSite()[
     126                            'configuration'][str(p_session)]
     127                    except KeyError:
     128                        return _(u'Session configuration object is not available.'), None
     129                elif student.is_postgrad and student.state == PAID:
     130                    # Returning postgraduate students also pay for the next session
     131                    # but their level always remains the same.
     132                    p_session += 1
     133                    if student.is_foreigner:
     134                        amount = getattr(certificate, 'school_fee_4', 0.0)
     135                    else:
     136                        amount = getattr(certificate, 'school_fee_2', 0.0)
     137                    try:
     138                        academic_session = grok.getSite()[
     139                            'configuration'][str(p_session)]
     140                    except KeyError:
     141                        return _(u'Session configuration object is not available.'), None
    123142            # Give 50% school fee discount to staff members.
    124143            if student.is_staff:
    125144                amount /= 2
    126145        if amount in (0.0, None):
    127             return _(u'Amount could not be determined.'), None
     146            return _('Amount could not be determined.' +
     147                     ' Would you like to pay for a previous session?'), None
    128148        # Add session specific penalty fee.
    129149        if category == 'schoolfee' and student.is_postgrad:
     
    138158               ticket.p_item == p_item and \
    139159               ticket.p_session == p_session:
    140                   return _('This type of payment has already been made.'), None
     160                  return _('This type of payment has already been made.' +
     161                           ' Would you like to pay for a previous session?'), None
    141162        payment = createObject(u'waeup.StudentOnlinePayment')
    142163        timestamp = ("%d" % int(time()*10000))[1:]
     
    146167        payment.p_session = p_session
    147168        payment.p_level = p_level
     169        payment.p_current = p_current
    148170        payment.amount_auth = amount
    149171        return None, payment
Note: See TracChangeset for help on using the changeset viewer.