source: WAeUP_SRP/base/skins/waeup_utilities/getPaymentStatistic.py @ 2365

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

add getPaymentStatistic

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1## Script (Python) "getPaymentStatistic"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: getPaymentStatistic.py 2365 2007-10-16 06:29:48Z joachim $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18mtool = context.portal_membership
19member = mtool.getAuthenticatedMember()
20if str(member) not in ('admin','joachim'):
21    return
22
23import logging
24import DateTime
25logger = logging.getLogger('Skins.getPaymentStatistic')
26from Products.AdvancedQuery import Eq, Between, Le,In
27pins = context.portal_pins
28aq_pins = context.portal_pins.evalAdvancedQuery
29aq_portal = context.portal_catalog_real.evalAdvancedQuery
30request = context.REQUEST
31session = request.SESSION
32response = request.RESPONSE
33setheader = request.RESPONSE.setHeader
34def rwrite(s):
35    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
36    response.write("%s<br>\n\r" % s)
37
38pbs = pins.uniqueValuesFor('prefix_batch')
39hostel_pbs = []
40for pb in pbs:
41    if pb.startswith('HMU') or pb.startswith('HMF'):
42        hostel_pbs.append(pb)
43clearance_pbs = [pb for pb in pbs if pb.startswith('CLR')]
44application_pbs = [pb for pb in pbs if pb.startswith('APP')]
45
46schoolfee_pbs = list(pbs)[:]
47for pb in application_pbs + hostel_pbs + clearance_pbs:
48    schoolfee_pbs.remove(pb)
49fees = {}
50missing_query = ~Eq('student','')
51#ah = [pin for pin in aq_pins(In('prefix_batch', hostel_pbs)) if pin.student]
52ah = aq_pins(In('prefix_batch', hostel_pbs) & missing_query)
53fees['hostel'] = {'anz': len(ah),
54                 'fee': 500,
55                 'title': 'Hostel Maintainance',
56                 }
57#ac = [pin for pin in aq_pins(In('prefix_batch', clearance_pbs)) if pin.student]
58ac = aq_pins(In('prefix_batch', clearance_pbs)& missing_query)
59fees['clearance'] = {'anz': len(ac),
60                 'fee': 250,
61                 'title': 'Clearance',
62                 }
63#aa = [pin for pin in aq_pins(In('prefix_batch', application_pbs)) if pin.student]
64aa = aq_pins(In('prefix_batch', application_pbs) & missing_query)
65fees['application'] = {'anz' : len(aa),
66                 'fee': 200,
67                 'title': 'Application',
68                 }
69aso = aq_portal(Eq('portal_type','Payment') & In("SearchableText",("successful",)))
70fees['schoolfee_onl'] = {'anz' : len(aso),
71                 'fee': 1000,
72                 'title': 'Schoolfee (online)',
73                 }
74#assc = [pin for pin in aq_pins(In('prefix_batch', schoolfee_pbs)) if pin.student]
75assc = aq_pins(In('prefix_batch', schoolfee_pbs) & missing_query)
76fees['schoolfee_scratch'] = {'anz' : len(assc),
77                 'fee': 1000,
78                 'title': 'Schoolfee (Scratchcard)',
79                 }
80rwrite("Payed fees")
81total = 0
82for fee in fees.values():
83    t = fee['value'] = fee['anz'] * fee['fee']
84    total += t
85    rwrite("%(title)s fees %(anz)d = %(value)d (%(fee)d N)" % fee)
86gt = float(total)/1000000
87rwrite("Total %10.2f Million N" % gt)
Note: See TracBrowser for help on using the repository browser.