[7195] | 1 | ## $Id: interfaces.py 15664 2019-10-13 19:15:33Z 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'), |
---|
[7627] | 30 | ) |
---|
| 31 | |
---|
[9405] | 32 | class PaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
[9864] | 33 | """A payment category source delivers all categories of payments. |
---|
| 34 | |
---|
[9405] | 35 | """ |
---|
| 36 | #: name of dict to deliver from kofa utils. |
---|
| 37 | DICT_NAME = 'PAYMENT_CATEGORIES' |
---|
[7627] | 38 | |
---|
[15664] | 39 | class CombiPaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
| 40 | """A payment category source delivers all categories of payments. |
---|
| 41 | |
---|
| 42 | """ |
---|
| 43 | #: name of dict to deliver from kofa utils. |
---|
| 44 | DICT_NAME = 'COMBI_PAYMENT_CATEGORIES' |
---|
| 45 | |
---|
[7819] | 46 | class IPaymentsContainer(IKofaObject): |
---|
[6861] | 47 | """A container for all kind of payment objects. |
---|
| 48 | |
---|
| 49 | """ |
---|
[6864] | 50 | |
---|
[7819] | 51 | class IPayment(IKofaObject): |
---|
[6864] | 52 | """A base representation of payments. |
---|
| 53 | |
---|
| 54 | """ |
---|
[9533] | 55 | p_id = Attribute('Payment identifier') |
---|
[6864] | 56 | |
---|
| 57 | p_category = schema.Choice( |
---|
[7717] | 58 | title = _(u'Payment Category'), |
---|
[10842] | 59 | #default = u'schoolfee', |
---|
[9405] | 60 | source = PaymentCategorySource(), |
---|
[6864] | 61 | required = True, |
---|
| 62 | ) |
---|
| 63 | |
---|
| 64 | p_item = schema.TextLine( |
---|
[9984] | 65 | title = u'', |
---|
[6869] | 66 | default = None, |
---|
[6864] | 67 | required = False, |
---|
| 68 | ) |
---|
| 69 | |
---|
[15664] | 70 | p_combi = schema.List( |
---|
| 71 | title = _(u'Combi Payment'), |
---|
| 72 | value_type = schema.Choice( |
---|
| 73 | source = CombiPaymentCategorySource(), |
---|
| 74 | ), |
---|
| 75 | required = False, |
---|
| 76 | defaultFactory=list, |
---|
| 77 | ) |
---|
| 78 | |
---|
[9984] | 79 | display_item = schema.TextLine( |
---|
| 80 | title = _(u'Payment Item'), |
---|
| 81 | required = False, |
---|
| 82 | readonly = True, |
---|
| 83 | ) |
---|
| 84 | |
---|
[8245] | 85 | p_session = schema.Choice( |
---|
| 86 | title = _(u'Payment Session'), |
---|
| 87 | source = academic_sessions_vocab, |
---|
[9512] | 88 | required = True, |
---|
[8245] | 89 | ) |
---|
| 90 | |
---|
[7020] | 91 | p_state = schema.Choice( |
---|
[7717] | 92 | title = _(u'Payment State'), |
---|
[7020] | 93 | default = u'unpaid', |
---|
| 94 | vocabulary = payment_states, |
---|
| 95 | required = True, |
---|
| 96 | ) |
---|
| 97 | |
---|
[8170] | 98 | creation_date = schema.Datetime( |
---|
[7717] | 99 | title = _(u'Ticket Creation Date'), |
---|
[7623] | 100 | readonly = False, |
---|
[8944] | 101 | required = False, |
---|
[6864] | 102 | ) |
---|
| 103 | |
---|
[8170] | 104 | payment_date = schema.Datetime( |
---|
[7717] | 105 | title = _(u'Payment Date'), |
---|
[6869] | 106 | required = False, |
---|
[6934] | 107 | readonly = False, |
---|
[6864] | 108 | ) |
---|
| 109 | |
---|
[7927] | 110 | amount_auth = schema.Float( |
---|
[7717] | 111 | title = _(u'Amount Authorized'), |
---|
[7927] | 112 | default = 0.0, |
---|
[6864] | 113 | required = True, |
---|
[7931] | 114 | readonly = False, |
---|
[6864] | 115 | ) |
---|
| 116 | |
---|
| 117 | class IOnlinePayment(IPayment): |
---|
| 118 | """A payment via payment gateways. |
---|
| 119 | |
---|
| 120 | """ |
---|
| 121 | |
---|
[6930] | 122 | ac = schema.TextLine( |
---|
[7717] | 123 | title = _(u'Activation Code'), |
---|
[6930] | 124 | default = None, |
---|
| 125 | required = False, |
---|
| 126 | readonly = False, |
---|
| 127 | ) |
---|
| 128 | |
---|
[7927] | 129 | r_amount_approved = schema.Float( |
---|
[7717] | 130 | title = _(u'Response Amount Approved'), |
---|
[7927] | 131 | default = 0.0, |
---|
[6864] | 132 | required = False, |
---|
[6930] | 133 | readonly = False, |
---|
[6864] | 134 | ) |
---|
| 135 | |
---|
| 136 | r_code = schema.TextLine( |
---|
[7717] | 137 | title = _(u'Response Code'), |
---|
[6864] | 138 | default = None, |
---|
[6869] | 139 | required = False, |
---|
[6930] | 140 | readonly = False, |
---|
[6864] | 141 | ) |
---|
[8420] | 142 | |
---|
[8429] | 143 | r_desc = schema.TextLine( |
---|
| 144 | title = _(u'Response Description'), |
---|
| 145 | default = None, |
---|
| 146 | required = False, |
---|
| 147 | readonly = False, |
---|
| 148 | ) |
---|
| 149 | |
---|
[8420] | 150 | def approve(): |
---|
| 151 | "Approve an online payment and set to paid." |
---|
[8703] | 152 | |
---|
[10030] | 153 | class IPayer(IKofaObject): |
---|
| 154 | """An interface for an adapter to publish student and applicant data |
---|
| 155 | through a simple webservice. |
---|
[8703] | 156 | |
---|
[9533] | 157 | """ |
---|
[10030] | 158 | display_fullname = Attribute('Name of payer') |
---|
| 159 | id = Attribute('Id of payer') |
---|
| 160 | reg_number = Attribute('Reg number of payer') |
---|
| 161 | matric_number = Attribute('Matric number of payer') |
---|
| 162 | faculty = Attribute('Faculty of payer') |
---|
| 163 | department = Attribute('Department of payer') |
---|
[10914] | 164 | email= Attribute('Email of payer') |
---|
| 165 | phone= Attribute('Phone number of payer') |
---|
| 166 | current_mode= Attribute('Current study mode of payer') |
---|
| 167 | current_level= Attribute('Current level of payer') |
---|