Changeset 10171 for main/waeup.aaua/trunk/src
- Timestamp:
- 10 May 2013, 13:59:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaua/trunk/src/waeup/aaua/students/utils.py
r10120 r10171 33 33 """ 34 34 35 def setPaymentDetails(self, category, student, 36 previous_session, previous_level): 37 """Create Payment object and set the payment data of a student for 38 the payment category specified. 39 40 """ 41 p_item = u'' 42 amount = 0.0 43 if previous_session: 44 if previous_session < student['studycourse'].entry_session: 45 return _('The previous session must not fall below ' 46 'your entry session.'), None 47 if category == 'schoolfee': 48 # School fee is always paid for the following session 49 if previous_session > student['studycourse'].current_session: 50 return _('This is not a previous session.'), None 51 else: 52 if previous_session > student['studycourse'].current_session - 1: 53 return _('This is not a previous session.'), None 54 p_session = previous_session 55 p_level = previous_level 56 p_current = False 57 else: 58 p_session = student['studycourse'].current_session 59 p_level = student['studycourse'].current_level 60 p_current = True 61 academic_session = self._getSessionConfiguration(p_session) 62 if academic_session == None: 63 return _(u'Session configuration object is not available.'), None 64 # Determine fee. 65 if category == 'schoolfee': 66 try: 67 certificate = student['studycourse'].certificate 68 p_item = certificate.code 69 except (AttributeError, TypeError): 70 return _('Study course data are incomplete.'), None 71 if previous_session: 72 # Students can pay for previous sessions in all 73 # workflow states. Fresh students are excluded by the 74 # update method of the PreviousPaymentAddFormPage. 75 if previous_level == 100: 76 amount = getattr(certificate, 'school_fee_1', 0.0) 77 else: 78 amount = getattr(certificate, 'school_fee_2', 0.0) 79 else: 80 if student.state == CLEARED: 81 amount = getattr(certificate, 'school_fee_1', 0.0) 82 elif student.state == RETURNING: 83 # In case of returning school fee payment the 84 # payment session and level contain the values of 85 # the session the student has paid for. Payment 86 # session is always next session. 87 p_session, p_level = self.getReturningData(student) 88 academic_session = self._getSessionConfiguration(p_session) 89 if academic_session == None: 90 return _( 91 u'Session configuration object is not available.' 92 ), None 93 amount = getattr(certificate, 'school_fee_2', 0.0) 94 elif student.is_postgrad and student.state == PAID: 95 # Returning postgraduate students also pay for the 96 # next session but their level always remains the 97 # same. 98 p_session += 1 99 academic_session = self._getSessionConfiguration(p_session) 100 if academic_session == None: 101 return _( 102 u'Session configuration object is not available.' 103 ), None 104 amount = getattr(certificate, 'school_fee_2', 0.0) 105 elif category == 'clearance': 106 try: 107 p_item = student['studycourse'].certificate.code 108 except (AttributeError, TypeError): 109 return _('Study course data are incomplete.'), None 110 amount = academic_session.clearance_fee 111 elif category == 'bed_allocation': 112 p_item = self.getAccommodationDetails(student)['bt'] 113 amount = academic_session.booking_fee 114 elif category == 'hostel_maintenance': 115 amount = academic_session.maint_fee 116 bedticket = student['accommodation'].get( 117 str(student.current_session), None) 118 if bedticket: 119 p_item = bedticket.bed_coordinates 120 else: 121 # Should not happen because this is already checked 122 # in the browser module, but anyway ... 123 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 124 p_item = trans(_('no bed allocated'), portal_language) 125 if amount in (0.0, None): 126 return _('Amount could not be determined.'), None 127 for key in student['payments'].keys(): 128 ticket = student['payments'][key] 129 if ticket.p_state == 'paid' and\ 130 ticket.p_category == category and \ 131 ticket.p_item == p_item and \ 132 ticket.p_session == p_session: 133 return _('This type of payment has already been made.'), None 134 payment = createObject(u'waeup.StudentOnlinePayment') 135 timestamp = ("%d" % int(time()*10000))[1:] 136 payment.p_id = "p%s" % timestamp 137 payment.p_category = category 138 payment.p_item = p_item 139 payment.p_session = p_session 140 payment.p_level = p_level 141 payment.p_current = p_current 142 payment.amount_auth = amount 143 return None, payment 144 35 145 # AAUA prefix 36 146 STUDENT_ID_PREFIX = u'A'
Note: See TracChangeset for help on using the changeset viewer.