[7195] | 1 | ## $Id: interfaces.py 15792 2019-11-10 20:11:40Z henrik $ |
---|
[6861] | 2 | ## |
---|
[7195] | 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[6969] | 18 | from zope.interface import Attribute |
---|
[6864] | 19 | from zope import schema |
---|
[8245] | 20 | from waeup.kofa.interfaces import ( |
---|
[11450] | 21 | IKofaObject, SimpleKofaVocabulary, academic_sessions_vocab, |
---|
| 22 | ContextualDictSourceFactoryBase) |
---|
[7811] | 23 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[6861] | 24 | |
---|
[7819] | 25 | payment_states = SimpleKofaVocabulary( |
---|
[7717] | 26 | (_('Not yet paid'),'unpaid'), |
---|
| 27 | (_('Paid'),'paid'), |
---|
| 28 | (_('Failed'),'failed'), |
---|
[12568] | 29 | (_('Fees waived'),'waived'), |
---|
[15792] | 30 | (_('Scholarship'),'scholarship'), |
---|
[7627] | 31 | ) |
---|
| 32 | |
---|
[9405] | 33 | class PaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
[9864] | 34 | """A payment category source delivers all categories of payments. |
---|
| 35 | |
---|
[9405] | 36 | """ |
---|
| 37 | #: name of dict to deliver from kofa utils. |
---|
| 38 | DICT_NAME = 'PAYMENT_CATEGORIES' |
---|
[7627] | 39 | |
---|
[15664] | 40 | class CombiPaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
| 41 | """A payment category source delivers all categories of payments. |
---|
| 42 | |
---|
| 43 | """ |
---|
| 44 | #: name of dict to deliver from kofa utils. |
---|
| 45 | DICT_NAME = 'COMBI_PAYMENT_CATEGORIES' |
---|
| 46 | |
---|
[7819] | 47 | class IPaymentsContainer(IKofaObject): |
---|
[6861] | 48 | """A container for all kind of payment objects. |
---|
| 49 | |
---|
| 50 | """ |
---|
[6864] | 51 | |
---|
[7819] | 52 | class IPayment(IKofaObject): |
---|
[6864] | 53 | """A base representation of payments. |
---|
| 54 | |
---|
| 55 | """ |
---|
[9533] | 56 | p_id = Attribute('Payment identifier') |
---|
[6864] | 57 | |
---|
| 58 | p_category = schema.Choice( |
---|
[7717] | 59 | title = _(u'Payment Category'), |
---|
[10842] | 60 | #default = u'schoolfee', |
---|
[9405] | 61 | source = PaymentCategorySource(), |
---|
[6864] | 62 | required = True, |
---|
| 63 | ) |
---|
| 64 | |
---|
| 65 | p_item = schema.TextLine( |
---|
[9984] | 66 | title = u'', |
---|
[6869] | 67 | default = None, |
---|
[6864] | 68 | required = False, |
---|
| 69 | ) |
---|
| 70 | |
---|
[15664] | 71 | p_combi = schema.List( |
---|
| 72 | title = _(u'Combi Payment'), |
---|
| 73 | value_type = schema.Choice( |
---|
| 74 | source = CombiPaymentCategorySource(), |
---|
| 75 | ), |
---|
| 76 | required = False, |
---|
| 77 | defaultFactory=list, |
---|
| 78 | ) |
---|
| 79 | |
---|
[9984] | 80 | display_item = schema.TextLine( |
---|
| 81 | title = _(u'Payment Item'), |
---|
| 82 | required = False, |
---|
| 83 | readonly = True, |
---|
| 84 | ) |
---|
| 85 | |
---|
[8245] | 86 | p_session = schema.Choice( |
---|
| 87 | title = _(u'Payment Session'), |
---|
| 88 | source = academic_sessions_vocab, |
---|
[9512] | 89 | required = True, |
---|
[8245] | 90 | ) |
---|
| 91 | |
---|
[7020] | 92 | p_state = schema.Choice( |
---|
[7717] | 93 | title = _(u'Payment State'), |
---|
[7020] | 94 | default = u'unpaid', |
---|
| 95 | vocabulary = payment_states, |
---|
| 96 | required = True, |
---|
| 97 | ) |
---|
| 98 | |
---|
[8170] | 99 | creation_date = schema.Datetime( |
---|
[7717] | 100 | title = _(u'Ticket Creation Date'), |
---|
[7623] | 101 | readonly = False, |
---|
[8944] | 102 | required = False, |
---|
[6864] | 103 | ) |
---|
| 104 | |
---|
[8170] | 105 | payment_date = schema.Datetime( |
---|
[7717] | 106 | title = _(u'Payment Date'), |
---|
[6869] | 107 | required = False, |
---|
[6934] | 108 | readonly = False, |
---|
[6864] | 109 | ) |
---|
| 110 | |
---|
[7927] | 111 | amount_auth = schema.Float( |
---|
[7717] | 112 | title = _(u'Amount Authorized'), |
---|
[7927] | 113 | default = 0.0, |
---|
[6864] | 114 | required = True, |
---|
[7931] | 115 | readonly = False, |
---|
[6864] | 116 | ) |
---|
| 117 | |
---|
| 118 | class IOnlinePayment(IPayment): |
---|
| 119 | """A payment via payment gateways. |
---|
| 120 | |
---|
| 121 | """ |
---|
| 122 | |
---|
[6930] | 123 | ac = schema.TextLine( |
---|
[7717] | 124 | title = _(u'Activation Code'), |
---|
[6930] | 125 | default = None, |
---|
| 126 | required = False, |
---|
| 127 | readonly = False, |
---|
| 128 | ) |
---|
| 129 | |
---|
[7927] | 130 | r_amount_approved = schema.Float( |
---|
[7717] | 131 | title = _(u'Response Amount Approved'), |
---|
[7927] | 132 | default = 0.0, |
---|
[6864] | 133 | required = False, |
---|
[6930] | 134 | readonly = False, |
---|
[6864] | 135 | ) |
---|
| 136 | |
---|
| 137 | r_code = schema.TextLine( |
---|
[7717] | 138 | title = _(u'Response Code'), |
---|
[6864] | 139 | default = None, |
---|
[6869] | 140 | required = False, |
---|
[6930] | 141 | readonly = False, |
---|
[6864] | 142 | ) |
---|
[8420] | 143 | |
---|
[8429] | 144 | r_desc = schema.TextLine( |
---|
| 145 | title = _(u'Response Description'), |
---|
| 146 | default = None, |
---|
| 147 | required = False, |
---|
| 148 | readonly = False, |
---|
| 149 | ) |
---|
| 150 | |
---|
[8420] | 151 | def approve(): |
---|
| 152 | "Approve an online payment and set to paid." |
---|
[8703] | 153 | |
---|
[10030] | 154 | class IPayer(IKofaObject): |
---|
| 155 | """An interface for an adapter to publish student and applicant data |
---|
| 156 | through a simple webservice. |
---|
[8703] | 157 | |
---|
[9533] | 158 | """ |
---|
[10030] | 159 | display_fullname = Attribute('Name of payer') |
---|
| 160 | id = Attribute('Id of payer') |
---|
| 161 | reg_number = Attribute('Reg number of payer') |
---|
| 162 | matric_number = Attribute('Matric number of payer') |
---|
| 163 | faculty = Attribute('Faculty of payer') |
---|
| 164 | department = Attribute('Department of payer') |
---|
[10914] | 165 | email= Attribute('Email of payer') |
---|
| 166 | phone= Attribute('Phone number of payer') |
---|
| 167 | current_mode= Attribute('Current study mode of payer') |
---|
| 168 | current_level= Attribute('Current level of payer') |
---|