source: WAeUP_SRP/base/Payment.py @ 2871

Last change on this file since 2871 was 2859, checked in by joachim, 17 years ago

implementing the payments_catalog

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1#-*- mode: python; mode: fold -*-
2from Globals import InitializeClass
3from AccessControl import ClassSecurityInfo
4
5from Products.CMFCore.utils import UniqueObject, getToolByName
6from Products.CMFCore.permissions import View
7from Products.CMFCore.permissions import ModifyPortalContent
8from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder
9#from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
10from Products.CPSDocument.CPSDocument import CPSDocument
11from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
12from Products.WAeUP_SRP.WAeUPTables import AccommodationTable
13import Globals
14import DateTime
15import logging
16import re
17p_home = Globals.package_home(globals())
18i_home = Globals.INSTANCE_HOME
19
20class PaymentsFolder(CPSDocument): ###(
21    """
22    WAeUP PaymentsFolder containing Paymentsmmodation halls
23    """
24    meta_type = 'PaymentsFolder'
25    portal_type = meta_type
26    security = ClassSecurityInfo()
27
28    security.declareProtected(View,"Title")
29    def Title(self):
30        """compose title"""
31        return "Payments"
32
33    security.declareProtected(View,"updatePayments")
34    def updatePayments(self):
35        """upgrade all payments in folder"""
36        logger = logging.getLogger('PaymentsFolder.updatePayments')
37        #import pdb;pdb.set_trace()
38        for payment in self.aq_parent.objectValues():
39            d = {}
40            student_record = self.students_catalog.getRecordByKey(self.getStudentId())
41            doc = payment.getContent()
42            d['key'] = payment.getId()
43            d['amount'] = doc.amount
44            d['description'] = d['type_description'] = doc.type_description
45            subject = ''
46            if doc.type_description.startswith('School'):
47                subject = 'schoolfee'
48            sp = doc.type_description.rfind('/')
49            d['session_id'] = doc.type_description[sp-2:sp]
50            d['subject'] = subject # zb. schoolfee
51            while True:
52                if doc.resp_code == "SC":
53                    p_type = "sc"
54                    p_status = "paid"
55                    break
56                if doc.resp_code in ("00","IP"):
57                    p_type = "online"
58                    p_status = "paid"
59                    break
60                p_type = "online"
61                p_status = "open"
62                break
63            d['key'] = payment.getId()
64            d['type'] = p_type  # scratch card
65            d['target'] = student_record.course
66            d['status'] = p_status
67            d['resp_approved_amount'] = getattr(doc,'resp_approved_amount',None)
68            d['resp_pay_reference'] = doc.resp_pay_reference
69            d['resp_desc'] = doc.resp_desc
70            d['order_id'] = doc.order_id
71            d['resp_code'] = doc.resp_code
72            d['resp_card_num'] = doc.resp_card_num
73            d['date'] = getattr(doc,'date',None)
74            d['resp_date'] = getattr(doc,'resp_date',None)
75            # msg = " ".join(["%s: %s" % (key,value) for key,value in d.items()])
76            # logger.info(msg)
77            doc.edit(mapping = d)
78
79InitializeClass(PaymentsFolder)
80
81def addPaymentsFolder(container, id, REQUEST=None, **kw):
82    """Add a PaymentsFolder."""
83    ob = PaymentsFolder(id, **kw)
84    return CPSBase_adder(container, ob, REQUEST=REQUEST)
85###)
86
87class Payment(CPSDocument): ###(
88    """
89    WAeUP Payment containing Departments
90    """
91    meta_type = 'Payment'
92    portal_type = meta_type
93    security = ClassSecurityInfo()
94
95    security.declareProtected(View,"Title") ###(
96    def Title(self):
97        """compose title"""
98        content = self.getContent()
99        description = getattr(content,'type_description','')
100        d = getattr(content,'date','')
101        #pay_date = "%s/%s/%s %s:%s:%s" %(d[:2],d[2:4],d[4:6],d[6:8],d[8:10],d[10:])
102        pay_date = d.strftime("%d/%m/%y %H:%M:%S")
103        amount = getattr(content,'amount','')
104        if not (description or pay_date or amount):
105            return self.getId()
106        return "%(description)s, Naira %(amount)s, %(pay_date)s" % vars()
107    ###)
108
109InitializeClass(Payment)
110
111def addPayment(container, id, REQUEST=None, **kw):
112    """Add a Payment."""
113    ob = Payment(id, **kw)
114    return CPSBase_adder(container, ob, REQUEST=REQUEST)
115###)
Note: See TracBrowser for help on using the repository browser.