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