Index: /WAeUP_SRP/base/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/base/WAeUPTables.py	(revision 2664)
+++ /WAeUP_SRP/base/WAeUPTables.py	(revision 2665)
@@ -212,5 +212,5 @@
         out = open(export_file,"a")
         csv_writer = csv.DictWriter(out,fields,)
-        format = '"%(' + ')s","%('.join(fields) + ')s"'
+        #format = '"%(' + ')s","%('.join(fields) + ')s"'
         records = self()
         nr2export = len(records)
@@ -223,6 +223,4 @@
             not_all = False
             d = self.record2dict(fields,record)
-            #d['state'],d['lga'] = formatLGA(d['lga'],voc = self.portal_vocabularies.local_gov_areas)
-            #lines.append(format % d)
             lines.append(d)
             total += 1
Index: /WAeUP_SRP/base/skins/waeup_epayment/dumpSCPayments.py
===================================================================
--- /WAeUP_SRP/base/skins/waeup_epayment/dumpSCPayments.py	(revision 2665)
+++ /WAeUP_SRP/base/skins/waeup_epayment/dumpSCPayments.py	(revision 2665)
@@ -0,0 +1,96 @@
+## Script (Python) "dumpSCPayments.py"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+"""
+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.dumpSCPayments.py')
+from Products.AdvancedQuery import Eq, Between, Le,In
+aq_pins = context.portal_pins.evalAdvancedQuery
+aq_student = context.students_catalog.evalAdvancedQuery
+#students_folder = context.portal_url.getPortalObject().campus.students
+
+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<br>\n\r" % s)
+
+cost_dict = {}
+for k,v in context.getScratchCardCost():
+    cost_dict[''.join(k.split('_'))] = v
+
+used_query = ~Eq('student','') & ~In('prefix_batch',('APP1','APP2','APP3','APP4','APP5',))
+              
+pins = aq_pins(used_query,sortSpecs=('student',))
+#set_trace()
+count = 1
+student_id = 'xxx'
+d = {}
+l = []
+sum_total = 0.0
+log_after = 100
+logger.info("start")
+for pin in pins:
+    if pin.pin.startswith('APP'):
+        continue
+    if student_id != pin.student:
+        if d:
+            res = aq_student(Eq('id',pin.student))
+            if not res:
+                logger.info("student_id %s not found" % pin.student)
+                continue
+            student = res[0]
+            d['faculty'] = student.faculty
+            d['department'] = student.department
+            d['course'] = student.course
+            d['matric_no'] = student.matric_no
+            #d['costs'] = ' '.join(costs)
+            d['pins'] = ' '.join(pins)
+            d['sum'] = sum
+            sum_total += sum
+            # rwrite(("%d: " % count) + "%(student_id)s %(pins)s %(costs)s %(sum)8.2f" % d +\
+            #         " %(faculty)s %(department)s %(course)s" % d)
+            l +=d,
+            d = {}
+            if not count % log_after:
+                logger.info("processed %d/%d" % (log_after,count))
+                # if not count % 1000:
+                #     break
+            count += 1
+        student_id = d['student_id'] = pin.student 
+        costs = ["%8.2f" % cost_dict[pin.prefix_batch],]
+        pins = [pin.pin,]
+        sum = cost_dict[pin.prefix_batch]
+    else:
+        costs += ("%8.2f" % cost_dict[pin.prefix_batch]),
+        pins += pin.pin,
+        sum += cost_dict[pin.prefix_batch]
+fields= ('student_id','pins','sum','matric_no','faculty','department','course')
+csv_name = context.waeup_tool.dumpListToCSV(l,'sc_payments',fields=fields)
+logger.info('%s dumped sc payments to %s' % (member,csv_name))
+logger.info("finished for %d students total N %12.2f %12.2f Euros" % (count,sum_total,sum_total/170))
+    
+    
