Index: WAeUP_SRP/trunk/skins/waeup_utilities/ti_167_resolve.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_utilities/ti_167_resolve.py	(revision 2059)
+++ WAeUP_SRP/trunk/skins/waeup_utilities/ti_167_resolve.py	(revision 2059)
@@ -0,0 +1,65 @@
+## Script (Python) "ti_167_resolve"
+##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
+import logging
+logger = logging.getLogger('Skins.ti_167_resolve')
+from Products.AdvancedQuery import Eq, Between, Le,In,MatchGlob
+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
+students = context.portal_url.getPortalObject().campus.students
+
+#from string import Template
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write("%s<br>\n\r" % s)
+
+batches = context.portal_catalog(portal_type = "ScratchCardBatch")
+logger.info("starting to insert cost property into pins-catatlog")
+batch_cost = {}
+for batch in batches:
+    prefix_batch = ''.join(batch.getId.split('_'))
+    cost = batch.getObject().getContent().cost
+    batch_cost[prefix_batch] = cost
+    # query = Eq('prefix_batch',prefix_batch)
+    # pins = aq_pins(query)
+    # for pin in pins:
+    #     context.portal_pins.modifyRecord(pin=pin.pin,cost=cost)
+# logger.info("finished to insert cost property into pins-catatlog")
+query = Eq('portal_type',"Payment")
+payments = aq_portal(query)
+count = 0
+no_cost = 0
+for payment in payments:
+    if payment.Title.find('n/a') > -1:
+        #set_trace()
+        payment_doc = payment.getObject().getContent()
+        prefix_batch = ''.join(str(payment_doc.order_id).split('-')[:2])
+        if batch_cost.has_key(prefix_batch):
+            count += 1
+            payment_doc.edit(mapping = {'amount': 
+                                        batch_cost[prefix_batch]})
+        else:
+            rwrite("cost %s:%s not found" % (prefix_batch,payment_doc.order_id))
+            no_cost +=1
+logger.info("updated %d payment amounts, %d costs not found" % (count,no_cost))
+
+    
