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

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

add counted prefixes

  • Property svn:keywords set to Id
File size: 3.2 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 2366 2007-10-16 06:43:01Z 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                  'prefixes': hostel_pbs,
57                 }
58#ac = [pin for pin in aq_pins(In('prefix_batch', clearance_pbs)) if pin.student]
59ac = aq_pins(In('prefix_batch', clearance_pbs)& missing_query)
60fees['clearance'] = {'anz': len(ac),
61                     'fee': 250,
62                     'title': 'Clearance',
63                     'prefixes': clearance_pbs,
64                 }
65#aa = [pin for pin in aq_pins(In('prefix_batch', application_pbs)) if pin.student]
66aa = aq_pins(In('prefix_batch', application_pbs) & missing_query)
67fees['application'] = {'anz' : len(aa),
68                 'fee': 200,
69                 'title': 'Application',
70                  'prefixes': application_pbs,
71                 }
72aso = aq_portal(Eq('portal_type','Payment') & In("SearchableText",("successful",)))
73fees['schoolfee_onl'] = {'anz' : len(aso),
74                 'fee': 1000,
75                 'title': 'Schoolfee (online)',
76                  'prefixes': (),
77                 }
78#assc = [pin for pin in aq_pins(In('prefix_batch', schoolfee_pbs)) if pin.student]
79assc = aq_pins(In('prefix_batch', schoolfee_pbs) & missing_query)
80fees['schoolfee_scratch'] = {'anz' : len(assc),
81                 'fee': 1000,
82                 'title': 'Schoolfee (Scratchcard)',
83                  'prefixes': schoolfee_pbs,
84                 }
85rwrite("Payed fees")
86total = 0
87keys = fees.keys()
88keys.sort()
89for key in keys:
90    fee = fees[key]
91    t = fee['value'] = fee['anz'] * fee['fee']
92    total += t
93    rwrite("%(title)s fees %(anz)d = %(value)d (%(fee)d N %(prefixes)s)" % fee)
94gt = float(total)/1000000
95rwrite("Total %10.2f Million N" % gt)
Note: See TracBrowser for help on using the repository browser.