Changeset 9155 for main/waeup.futminna/trunk/src
- Timestamp:
- 4 Sep 2012, 07:09:29 (12 years ago)
- Location:
- main/waeup.futminna/trunk/src/waeup/futminna
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.futminna/trunk/src/waeup/futminna/interswitch/tests.py
r8619 r9155 51 51 self.browser.open(self.payments_path + '/addop') 52 52 self.browser.getControl("Create ticket").click() 53 self.assertMatches('... ticket created...',53 self.assertMatches('...Payment components not yet configured...', 54 54 self.browser.contents) 55 ctrl = self.browser.getControl(name='val_id')56 value = ctrl.options[0]57 self.browser.getLink(value).click()58 self.assertMatches('...Amount Authorized...',59 self.browser.contents)60 self.assertMatches(61 '...<span>40000.0</span>...',62 self.browser.contents)63 self.payment_url = self.browser.url64 55 65 66 # def callback_url(self, payment_url, resp, apprAmt):67 # return payment_url + (68 # '/isw_callback?echo=' +69 # '&resp=%s' +70 # '&desc=Something went wrong' +71 # '&txnRef=p1331792385335' +72 # '&payRef=' + '&retRef=' +73 # '&cardNum=0' +74 # '&apprAmt=%s' +75 # '&url=http://xyz') % (resp, apprAmt)76 77 def test_interswitch_form(self):78 79 # Manager can access InterswitchForm80 self.browser.getLink("CollegePAY", index=0).click()81 self.assertMatches('...Total Amount Authorized:...',82 self.browser.contents)83 # The total amount to be processed by Interswitch84 # has been reduced by the Interswitch fee of 150 Nairas85 self.assertMatches(86 '...<input type="hidden" name="amount" value="4000000.0" />...',87 self.browser.contents)88 89 # @external_test90 # def test_callback(self):91 92 # Manager can call callback manually93 # self.browser.open(self.callback_url(self.payment_url, 'XX', '300'))94 # self.assertMatches('...Unsuccessful callback: Something went wrong...',95 # self.browser.contents)96 # self.assertMatches('...Failed...',97 # self.browser.contents)98 # self.browser.open(self.payment_url + '/isw_callback')99 # self.assertMatches('...Unsuccessful callback: Incomplete query string...',100 # self.browser.contents)101 # self.assertMatches('...Failed...',102 # self.browser.contents)103 # self.browser.open(self.callback_url(self.payment_url, '00', '300000'))104 # self.assertMatches('...Wrong amount...',105 # self.browser.contents)106 # self.browser.open(self.callback_url(self.payment_url, '00', '4000000'))107 # self.assertMatches('...Valid callback received...',108 # self.browser.contents)109 110 @external_test111 def test_webservice(self):112 113 self.browser.open(self.payment_url + '/request_webservice')114 self.assertMatches('...Unsuccessful callback...',115 self.browser.contents)116 # The payment is now in state failed117 self.assertMatches('...<span>Failed</span>...',118 self.browser.contents)119 56 120 57 class InterswitchTestsApplicants(ApplicantsFullSetup): -
main/waeup.futminna/trunk/src/waeup/futminna/students/interfaces.py
r8869 r9155 71 71 """ 72 72 73 p_current = schema.Bool( 74 title = _(u'Current Session Payment'), 75 default = True, 76 required = False, 77 ) 78 73 79 p_level = schema.Int( 74 80 title = _(u'Payment Level'), -
main/waeup.futminna/trunk/src/waeup/futminna/students/tests/test_browser.py
r8981 r9155 70 70 layer = FunctionalLayer 71 71 72 def test_manage_payments(self):73 # Add missing configuration data74 self.app['configuration']['2004'].gown_fee = 150.075 self.app['configuration']['2004'].transfer_fee = 90.076 #self.app['configuration']['2004'].clearance_fee = 120.077 self.app['configuration']['2004'].booking_fee = 150.078 self.app['configuration']['2004'].maint_fee = 180.079 80 # Managers can add online payment tickets81 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')82 self.browser.open(self.payments_path)83 self.browser.getControl("Add online payment ticket").click()84 self.browser.getControl("Create ticket").click()85 self.assertMatches('...Amount could not be determined...',86 self.browser.contents)87 IWorkflowState(self.student).setState('cleared')88 self.browser.open(self.payments_path + '/addop')89 self.browser.getControl("Create ticket").click()90 self.assertMatches('...ticket created...',91 self.browser.contents)92 ctrl = self.browser.getControl(name='val_id')93 value = ctrl.options[0]94 self.browser.getLink(value).click()95 self.assertMatches('...Amount Authorized...',96 self.browser.contents)97 # Managers can open payment slip98 self.browser.getLink("Download payment slip").click()99 self.assertEqual(self.browser.headers['Status'], '200 Ok')100 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')101 # Set ticket paid102 ticket = self.student['payments'].items()[0][1]103 ticket.p_state = 'paid'104 self.browser.open(self.payments_path + '/addop')105 self.browser.getControl("Create ticket").click()106 self.assertMatches('...This type of payment has already been made...',107 self.browser.contents)108 # Remove all payments so that we can add a school fee payment again109 keys = [i for i in self.student['payments'].keys()]110 for payment in keys:111 del self.student['payments'][payment]112 self.browser.open(self.payments_path + '/addop')113 self.browser.getControl("Create ticket").click()114 self.assertMatches('...ticket created...',115 self.browser.contents)116 self.browser.open(self.payments_path + '/addop')117 self.browser.getControl(name="form.p_category").value = ['gown']118 self.browser.getControl("Create ticket").click()119 self.assertMatches('...ticket created...',120 self.browser.contents)121 self.browser.open(self.payments_path + '/addop')122 self.browser.getControl(name="form.p_category").value = ['transfer']123 self.browser.getControl("Create ticket").click()124 self.assertMatches('...ticket created...',125 self.browser.contents)126 self.browser.open(self.payments_path + '/addop')127 self.browser.getControl(128 name="form.p_category").value = ['bed_allocation']129 self.browser.getControl("Create ticket").click()130 self.assertMatches('...ticket created...',131 self.browser.contents)132 self.browser.open(self.payments_path + '/addop')133 self.browser.getControl(134 name="form.p_category").value = ['hostel_maintenance']135 self.browser.getControl("Create ticket").click()136 self.assertMatches('...ticket created...',137 self.browser.contents)138 self.browser.open(self.payments_path + '/addop')139 self.browser.getControl(name="form.p_category").value = ['clearance']140 self.browser.getControl("Create ticket").click()141 self.assertMatches('...ticket created...',142 self.browser.contents)143 self.browser.open(self.payments_path + '/addop')144 self.browser.getControl(name="form.p_category").value = ['schoolfee']145 self.browser.getControl("Create ticket").click()146 self.assertMatches('...ticket created...',147 self.browser.contents)148 # In state returning we can add a new school fee ticket since149 # p_session and p_level is different150 IWorkflowState(self.student).setState('returning')151 self.browser.open(self.payments_path + '/addop')152 self.browser.getControl(name="form.p_category").value = ['schoolfee']153 self.browser.getControl("Create ticket").click()154 self.assertMatches('...Session configuration object is not...',155 self.browser.contents)156 # Uups, we forgot to add a session configuration for next session157 configuration = createObject('waeup.SessionConfiguration')158 configuration.academic_session = 2005159 self.app['configuration'].addSessionConfiguration(configuration)160 self.browser.open(self.payments_path + '/addop')161 self.browser.getControl(name="form.p_category").value = ['schoolfee']162 self.browser.getControl("Create ticket").click()163 self.assertMatches('...ticket created...',164 self.browser.contents)165 # In state admitted school fee can't be determined166 IWorkflowState(self.student).setState('admitted')167 self.browser.open(self.payments_path + '/addop')168 self.browser.getControl(name="form.p_category").value = ['schoolfee']169 self.browser.getControl("Create ticket").click()170 self.assertMatches('...Amount could not be determined...',171 self.browser.contents)172 173 # If the session configuration doesn't exist an error message will174 # be shown. No other requirement is being checked.175 del self.app['configuration']['2004']176 self.browser.open(self.payments_path)177 self.browser.getControl("Add online payment ticket").click()178 self.browser.getControl("Create ticket").click()179 self.assertMatches('...Session configuration object is not...',180 self.browser.contents)181 182 72 def test_get_returning_data(self): 183 73 # Student is in level 100, session 2004 with verdict A … … 189 79 self.assertEqual(utils.getReturningData(self.student),(2005, 100)) 190 80 return 191 192 def test_set_payment_details(self):193 self.app['configuration']['2004'].gown_fee = 150.0194 self.app['configuration']['2004'].transfer_fee = 90.0195 self.app['configuration']['2004'].booking_fee = 150.0196 self.app['configuration']['2004'].maint_fee = 180.0197 utils = getUtility(IStudentsUtils)198 199 configuration = createObject('waeup.SessionConfiguration')200 configuration.academic_session = 2005201 self.app['configuration'].addSessionConfiguration(configuration)202 203 error, payment = utils.setPaymentDetails('schoolfee',self.student)204 self.assertEqual(payment, None)205 self.assertEqual(error, u'Amount could not be determined.')206 207 IWorkflowState(self.student).setState('cleared')208 error, payment = utils.setPaymentDetails('schoolfee',self.student)209 self.assertEqual(payment.p_level, 100)210 self.assertEqual(payment.p_session, 2004)211 self.assertEqual(payment.amount_auth, 40000.0)212 self.assertEqual(payment.p_item, u'CERT1')213 self.assertEqual(error, None)214 215 # Add penalty fee ...216 # ... for cleared217 self.app['configuration']['2004'].penalty_ug = 99.0218 # ... for returning219 self.app['configuration']['2005'].penalty_ug = 88.0220 error, payment = utils.setPaymentDetails('schoolfee',self.student)221 self.assertEqual(payment.amount_auth, 40099.0)222 223 IWorkflowState(self.student).setState('returning')224 error, payment = utils.setPaymentDetails('schoolfee',self.student)225 self.assertEqual(payment.p_level, 200)226 self.assertEqual(payment.p_session, 2005)227 self.assertEqual(payment.amount_auth, 20088.0)228 self.assertEqual(payment.p_item, u'CERT1')229 self.assertEqual(error, None)230 231 error, payment = utils.setPaymentDetails('clearance',self.student)232 self.assertEqual(payment.p_level, 100)233 self.assertEqual(payment.p_session, 2004)234 self.assertEqual(payment.amount_auth, 34250.0)235 self.assertEqual(payment.p_item, u'CERT1')236 self.assertEqual(error, None)237 238 error, payment = utils.setPaymentDetails('gown',self.student)239 self.assertEqual(payment.p_level, 100)240 self.assertEqual(payment.p_session, 2004)241 self.assertEqual(payment.amount_auth, 150.0)242 self.assertEqual(payment.p_item, u'')243 self.assertEqual(error, None)244 245 error, payment = utils.setPaymentDetails('hostel_maintenance',self.student)246 self.assertEqual(payment.p_level, 100)247 self.assertEqual(payment.p_session, 2004)248 self.assertEqual(payment.amount_auth, 180.0)249 self.assertEqual(payment.p_item, u'')250 self.assertEqual(error, None)251 252 error, payment = utils.setPaymentDetails('bed_allocation',self.student)253 self.assertEqual(payment.p_level, 100)254 self.assertEqual(payment.p_session, 2004)255 self.assertEqual(payment.amount_auth, 150.0)256 self.assertEqual(payment.p_item, u'')257 self.assertEqual(error, None)258 259 error, payment = utils.setPaymentDetails('transfer',self.student)260 self.assertEqual(payment.p_level, 100)261 self.assertEqual(payment.p_session, 2004)262 self.assertEqual(payment.amount_auth, 90.0)263 self.assertEqual(payment.p_item, u'')264 self.assertEqual(error, None)265 return -
main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py
r8981 r9155 48 48 return new_session, new_level 49 49 50 def setPaymentDetails(self, category, student): 50 def setPaymentDetails(self, category, student, 51 previous_session=None, previous_level=None): 51 52 """Create Payment object and set the payment data of a student for 52 53 the payment category specified. 53 54 54 55 """ 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 138 58 139 59 # FUTMinna prefix
Note: See TracChangeset for help on using the changeset viewer.