Changeset 17016 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 10 Jul 2022, 08:40:43 (2 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r16976 r17016 41 41 IApplicantOnlinePayment, IApplicantsUtils, 42 42 IApplicantRegisterUpdate, ISpecialApplicant, 43 IApplicantRefereeReport 43 IApplicantRefereeReport, 44 IApplicantBalancePayment 44 45 ) 45 46 from waeup.kofa.utils.helpers import (html2dict, … … 831 832 def render(self): 832 833 return 834 835 class BalancePaymentAddFormPage(KofaAddFormPage): 836 """ Page to add an online payment which can balance s previous session 837 payment. 838 """ 839 grok.context(IApplicant) 840 grok.name('addbp') 841 grok.template('balancepaymentaddform') 842 grok.require('waeup.manageApplication') 843 form_fields = grok.AutoFields(IApplicantBalancePayment) 844 label = _('Add balance') 845 #pnav = 4 846 847 @property 848 def selectable_payment_options(self): 849 options = getUtility( 850 IKofaUtils).selectable_payment_options(self.context) 851 return sorted(options.items(), key=lambda value: value[1]) 852 853 @action(_('Create ticket'), style='primary') 854 def createTicket(self, **data): 855 p_category = data['p_category'] 856 p_option = data.get('p_option', None) 857 balance_amount = data.get('balance_amount', None) 858 applicants_utils = getUtility(IApplicantsUtils) 859 error, payment = applicants_utils.setBalanceDetails( 860 self.context, p_category, balance_amount) 861 if error is not None: 862 self.flash(error, type="danger") 863 return 864 if p_option: 865 payment.p_option = p_option 866 self.context[payment.p_id] = payment 867 self.flash(_('Payment ticket created.')) 868 self.context.writeLogMessage(self,'added: %s' % payment.p_id) 869 self.redirect(self.url(payment)) 870 return 871 872 @action(_('Cancel'), validator=NullValidator) 873 def cancel(self, **data): 874 self.redirect(self.url(self.context)) 833 875 834 876 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py
r16976 r17016 30 30 from waeup.kofa.interfaces import ( 31 31 IKofaObject, validate_email, validate_html, 32 SimpleKofaVocabulary )32 SimpleKofaVocabulary, ContextualDictSourceFactoryBase) 33 33 from waeup.kofa.interfaces import MessageFactory as _ 34 34 from waeup.kofa.payments.interfaces import IOnlinePayment … … 45 45 curr_year = datetime.now().year 46 46 return range(curr_year - 6, curr_year + 5) 47 48 class ApplicantBalancePaymentCategorySource(ContextualDictSourceFactoryBase): 49 """A source that delivers all selectable items of balance payments. 50 """ 51 #: name of dict to deliver from kofa utils. 52 DICT_NAME = 'APPLICANT_BALANCE_PAYMENT_CATEGORIES' 47 53 48 54 class RegNumInSource(ValidationError): … … 693 699 """Approve payment and process applicant. 694 700 """ 701 702 class IApplicantBalancePayment(IKofaObject): 703 """An interface for adding balances. 704 """ 705 706 p_category = schema.Choice( 707 title = _(u'Payment Category'), 708 default = u'application', 709 required = True, 710 source = ApplicantBalancePaymentCategorySource(), 711 ) 712 713 balance_amount = schema.Float( 714 title = _(u'Balance Amount'), 715 default = None, 716 required = True, 717 readonly = False, 718 description = _( 719 u'Balance in Naira '), 720 ) 695 721 696 722 class IApplicantRefereeReport(IKofaObject): -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r17009 r17016 1086 1086 return 1087 1087 1088 def test_pay_balance(self): 1089 # Managers can make balance payment 1090 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1091 self.browser.open(self.manage_path) 1092 self.fill_correct_values() 1093 self.browser.getControl("Save").click() 1094 self.browser.open(self.view_path + '/addbp') 1095 self.browser.getControl(name="form.p_category").value = ['donation'] 1096 self.browser.getControl(name="form.balance_amount").value = '10000' 1097 self.browser.getControl("Create ticket").click() 1098 self.assertTrue('Wrong state' in self.browser.contents) 1099 IWorkflowState(self.applicant).setState('submitted') 1100 self.browser.getControl("Create ticket").click() 1101 self.assertTrue('Payment ticket created.' in self.browser.contents) 1102 self.browser.getLink("Approve payment").click() 1103 self.assertTrue('Payment approved' in self.browser.contents) 1104 return 1105 1088 1106 def prepare_special_container(self): 1089 1107 # Add special application container -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py
r17009 r17016 22 22 from datetime import datetime 23 23 import grok 24 from zope.component import getUtility 24 from zope.component import getUtility, createObject 25 25 from zope.catalog.interfaces import ICatalog 26 26 from waeup.kofa.interfaces import MessageFactory as _ … … 89 89 return 90 90 91 def setBalanceDetails(self, applicant, category, balance_amount): 92 """Create a balance payment ticket and set the payment data 93 as selected by the applicant. 94 """ 95 if applicant.state not in (PAID, ADMITTED, SUBMITTED, PROCESSED): 96 return _('Wrong state.'), None 97 p_item = u'Balance' 98 amount = balance_amount 99 if amount in (0.0, None) or amount < 0: 100 return _('Amount must be greater than 0.'), None 101 payment = createObject(u'waeup.ApplicantOnlinePayment') 102 timestamp = ("%d" % int(time()*10000))[1:] 103 payment.p_id = "p%s" % timestamp 104 payment.p_category = category 105 payment.p_item = p_item 106 if applicant.__parent__.year: 107 payment.p_session = applicant.__parent__.year 108 else: 109 payment.p_session = datetime.now().year 110 payment.amount_auth = amount 111 return None, payment 112 91 113 def getApplicantsStatistics(self, container): 92 114 """Count applicants in applicants containers. -
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r16976 r17016 194 194 'late_registration': 'Late Course Registration Fee', 195 195 'combi': 'Combi Payment', 196 'donation': 'Donation', 196 197 } 197 198 … … 219 220 BALANCE_PAYMENT_CATEGORIES = { 220 221 'schoolfee': 'School Fee', 222 } 223 224 APPLICANT_BALANCE_PAYMENT_CATEGORIES = { 225 'donation': 'Donation', 221 226 } 222 227
Note: See TracChangeset for help on using the changeset viewer.