- Timestamp:
- 31 Mar 2007, 15:32:16 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_utilities/readOnlinePaymentsFromLog.py
r1666 r1667 10 10 # $Id$ 11 11 """ 12 list Students for ClearanceOfficers 12 read the successfull epayments from an extract of Z2.log 13 this extract must be created with 14 15 cat /zope/instances/uniben1/log/Z2.log.1 | grep epayment_cb | grep RespCode=00 16 > /zope/instances/uniben1/import/successfullepaymentsDDMMYY.log 17 18 in /zope/instances/uniben1/import/ are already all files from 25.3.07 19 13 20 """ 21 import logging 22 logger = logging.getLogger('Skins.readOnlinePaymentsFromLog') 14 23 15 24 request = context.REQUEST … … 17 26 response = request.RESPONSE 18 27 setheader = request.RESPONSE.setHeader 28 import DateTime 19 29 20 30 def rwrite(s): … … 32 42 aq_students = context.students_catalog.evalAdvancedQuery 33 43 students_folder = context.portal_url.getPortalObject().campus.students 34 tas = context.waeup_tool.getCallbacksFromLog('epaymentsuccessful_z2log2') 44 resp_codes = (("x_RespDesc","resp_desc"), 45 ("x_RespPayRef","resp_pay_reference"), 46 ("x_RespCode","resp_code"), 47 ("x_CardNum","resp_card_num"), 48 ("x_ApprAmt","resp_approved_amount"), 49 ) 50 count = 0 51 correct = 0 52 approved = 0 53 tas = context.waeup_tool.getCallbacksFromLog('successfullepayments260307.log') 35 54 for ta in tas: 55 count += 1 36 56 student_id = ta['student_id'] 37 57 payment_id = ta['payment_id'] 38 58 qs_dict = ta['qs_dict'] 39 rwrite(qs_dict)40 59 if not students_folder.hasObject(student_id): 41 60 rwrite("no student %s" % student_id) … … 50 69 continue 51 70 payment_obj = getattr(payments,payment_id) 52 review_state = wftool.getInfoFor(student_obj,'review_state',None) 53 #from pdb import set_trace 54 if review_state == 'schoolfee_paid': 55 rwrite("student %s has already state %s" % (student_id,review_state)) 56 continue 57 review_state = wftool.getInfoFor(payment_obj,'review_state',None) 58 #from pdb import set_trace 59 if review_state != 'open': 60 rwrite("payment %s for student %s has state %s" % (payment_id,student_id,review_state)) 61 continue 62 resp_codes = (("x_RespDesc","resp_desc"), 63 ("x_RespPayRef","resp_pay_reference"), 64 ("x_RespCode","resp_code"), 65 ("x_CardNum","resp_card_num"), 66 ("x_ApprAmt","resp_approved_amount"), 67 ) 68 pd = {} 71 payment_doc = payment_obj.getContent() 72 pdoc = {} 73 for rc,key in resp_codes: 74 pdoc[key] = getattr(payment_doc,key) 75 readin = {} 69 76 for rc,pdk in resp_codes: 70 pd[pdk] = request.get(rc) 71 rwrite(pd) 72 #payment_obj.getContent().edit(mapping=pd) 73 continue 77 readin[pdk] = qs_dict.get(rc)[0] 78 response_code = readin['resp_code'] 79 if payment_doc.resp_code != response_code: 80 rwrite('"%d","%d","%s","%s","%s","%s"' % ( 81 count,correct, 82 student_id, 83 payment_id, 84 response_code, 85 payment_doc.resp_code 86 )) 87 elif payment_doc.resp_code == response_code: 88 correct +=1 89 rwrite('"%d","%d","%s","%s","%s","%s"' % ( 90 count,correct, 91 student_id, 92 payment_id, 93 response_code, 94 payment_doc.resp_code 95 )) 96 if payment_doc.resp_code == "" and response_code == "00": 97 pd = {} 98 review_state = wftool.getInfoFor(payment_obj,'review_state',None) 99 if review_state != "opened": 100 logger.info('payment object of %s closed' % (student_id)) 101 continue 102 review_state = wftool.getInfoFor(student_obj,'review_state',None) 103 if review_state != "cleared_and_validated": 104 logger.info('%s review_state = %s' % (student_id,review_state)) 105 continue 106 pd['resp_code'] = 'IP' 107 pd['resp_desc'] = 'Payment approved by import, %s' % (DateTime.DateTime()) 108 payment_doc.edit(mapping=pd) 109 if payment_doc.type_description.startswith('School Fee'): 110 wftool.doActionFor(student_obj,'pay_school_fee') 111 logger.info('%s approves epayment for %s by import' % (member,student_id)) 112 wftool.doActionFor(payment_obj,'close') 113 approved += 1 114 if approved > 50: 115 context.waeup_tool.doCommit() 116 logger.info('%s transactions commited' % (approved)) 117 approved = 0
Note: See TracChangeset for help on using the changeset viewer.