## Script (Python) "getPaymentStatistic" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: getPaymentStatistic.py 2365 2007-10-16 06:29:48Z joachim $ """ """ try: from Products.zdb import set_trace except: def set_trace(): pass mtool = context.portal_membership member = mtool.getAuthenticatedMember() if str(member) not in ('admin','joachim'): return import logging import DateTime logger = logging.getLogger('Skins.getPaymentStatistic') from Products.AdvancedQuery import Eq, Between, Le,In pins = context.portal_pins aq_pins = context.portal_pins.evalAdvancedQuery aq_portal = context.portal_catalog_real.evalAdvancedQuery request = context.REQUEST session = request.SESSION response = request.RESPONSE setheader = request.RESPONSE.setHeader def rwrite(s): response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.write("%s
\n\r" % s) pbs = pins.uniqueValuesFor('prefix_batch') hostel_pbs = [] for pb in pbs: if pb.startswith('HMU') or pb.startswith('HMF'): hostel_pbs.append(pb) clearance_pbs = [pb for pb in pbs if pb.startswith('CLR')] application_pbs = [pb for pb in pbs if pb.startswith('APP')] schoolfee_pbs = list(pbs)[:] for pb in application_pbs + hostel_pbs + clearance_pbs: schoolfee_pbs.remove(pb) fees = {} missing_query = ~Eq('student','') #ah = [pin for pin in aq_pins(In('prefix_batch', hostel_pbs)) if pin.student] ah = aq_pins(In('prefix_batch', hostel_pbs) & missing_query) fees['hostel'] = {'anz': len(ah), 'fee': 500, 'title': 'Hostel Maintainance', } #ac = [pin for pin in aq_pins(In('prefix_batch', clearance_pbs)) if pin.student] ac = aq_pins(In('prefix_batch', clearance_pbs)& missing_query) fees['clearance'] = {'anz': len(ac), 'fee': 250, 'title': 'Clearance', } #aa = [pin for pin in aq_pins(In('prefix_batch', application_pbs)) if pin.student] aa = aq_pins(In('prefix_batch', application_pbs) & missing_query) fees['application'] = {'anz' : len(aa), 'fee': 200, 'title': 'Application', } aso = aq_portal(Eq('portal_type','Payment') & In("SearchableText",("successful",))) fees['schoolfee_onl'] = {'anz' : len(aso), 'fee': 1000, 'title': 'Schoolfee (online)', } #assc = [pin for pin in aq_pins(In('prefix_batch', schoolfee_pbs)) if pin.student] assc = aq_pins(In('prefix_batch', schoolfee_pbs) & missing_query) fees['schoolfee_scratch'] = {'anz' : len(assc), 'fee': 1000, 'title': 'Schoolfee (Scratchcard)', } rwrite("Payed fees") total = 0 for fee in fees.values(): t = fee['value'] = fee['anz'] * fee['fee'] total += t rwrite("%(title)s fees %(anz)d = %(value)d (%(fee)d N)" % fee) gt = float(total)/1000000 rwrite("Total %10.2f Million N" % gt)