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