Ignore:
Timestamp:
13 May 2014, 19:10:58 (11 years ago)
Author:
Henrik Bettermann
Message:

Add samePaymentMade method to StudentsUtils?.

File:
1 edited

Legend:

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

    r11619 r11641  
    362362            'sf_all' in academic_session.payment_disabled:
    363363            return True
     364        return False
     365
     366    def samePaymentMade(self, student, category, p_item, p_session):
     367        for key in student['payments'].keys():
     368            ticket = student['payments'][key]
     369            if ticket.p_state == 'paid' and\
     370               ticket.p_category == category and \
     371               ticket.p_item == p_item and \
     372               ticket.p_session == p_session:
     373                  return True
    364374        return False
    365375
     
    463473        if amount in (0.0, None):
    464474            return _('Amount could not be determined.'), None
    465         for key in student['payments'].keys():
    466             ticket = student['payments'][key]
    467             if ticket.p_state == 'paid' and\
    468                ticket.p_category == category and \
    469                ticket.p_item == p_item and \
    470                ticket.p_session == p_session:
    471                   return _('This type of payment has already been made.'), None
     475        if self.samePaymentMade(student, category, p_item, p_session):
     476            return _('This type of payment has already been made.'), None
    472477        if self._isPaymentDisabled(p_session, category, student):
    473478            return _('Payment temporarily disabled.'), None
     
    498503        if amount in (0.0, None) or amount < 0:
    499504            return _('Amount must be greater than 0.'), None
    500         for key in student['payments'].keys():
    501             ticket = student['payments'][key]
    502             if ticket.p_state == 'paid' and\
    503                ticket.p_category == 'balance' and \
    504                ticket.p_item == p_item and \
    505                ticket.p_session == p_session:
    506                   return _('This type of payment has already been made.'), None
     505        if self.samePaymentMade(student, 'balance', p_item, p_session):
     506            return _('This type of payment has already been made.'), None
    507507        payment = createObject(u'waeup.StudentOnlinePayment')
    508508        timestamp = ("%d" % int(time()*10000))[1:]
Note: See TracChangeset for help on using the changeset viewer.