Index: WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py
===================================================================
--- WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py	(revision 3050)
+++ WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py	(revision 3069)
@@ -14,4 +14,5 @@
 
 mtool = context.portal_membership
+wftool = context.portal_workflow
 member = mtool.getAuthenticatedMember()
 if mtool.isAnonymousUser():
@@ -74,30 +75,26 @@
 
 info['student_name'] = student_record.name
-payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
-sos = context.portal_catalog(container_path=payments_path)
-info['is_so'] = is_so
 
-for so in sos:
+for payment_id,payment in context.objectItems():
     row = {}
-    row['id'] = so.getId
-    row['title'] = so.Title
-    url = row['url'] = "%s/%s" % (payments_path,so.getId)
-    so_doc = context.restrictedTraverse(url,default=None).getContent()
-    row['type'] = so.portal_type
-    review_state = row['review_state'] = so.review_state
-    if so_doc.type_description.startswith('School Fee'):
-        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] in ('cleared_and_validated','returning')
+    row['id'] = payment_id
+    row['title'] = payment.Title()
+    url = row['url'] = payment.absolute_url()
+    payment_doc = payment.getContent()
+    row['type'] = payment_doc.portal_type
+    review_state = row['review_state'] = wftool.getInfoFor(payment,'review_state',None)
+    if payment_doc.type_description.startswith('School Fee'):
+        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
     else:
-        row['is_approvable'] = False    # is_so and (review_state == "opened")
+        row['is_approvable'] = is_so and (review_state == "opened")
     row['is_requeryable'] = False
     #set_trace()
-    row['resp_desc'] = getattr(so_doc,'resp_desc','no response')
-    row['trans_ref'] = getattr(so_doc,'order_id','')
-    if so_doc.type_description.startswith('School Fee'):
-        if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated','returning') and \
-                                  hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
+    row['resp_desc'] = getattr(payment_doc,'resp_desc','no response')
+    row['trans_ref'] = getattr(payment_doc,'order_id','')
+    if payment_doc.type_description.startswith('School Fee'):
+        if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated',) and \
+            hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin',):
             row['is_requeryable'] = True
-            row['callback_url'] = "%s/payments/%s/interswitch_cb" % (student.absolute_url(),
-                                                            so.getId)
+            row['callback_url'] = "%(url)s/interswitch_cb" % row
             href = '%(query_url)s' % info
             href += '?transRef=%(trans_ref)s' % row
@@ -105,10 +102,9 @@
             href += '&redirectURL=%(callback_url)s' % row
             row['href'] = href
-    elif so_doc.type_description.startswith('Hostel'):
+    elif payment_doc.type_description.startswith('Hostel'):
         if (review_state == 'opened' and \
-                                  hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
+            hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
             row['is_requeryable'] = True
-            row['callback_url'] = "%s/payments/%s/interswitch_acco_cb" % (student.absolute_url(),
-                                                            so.getId)
+            row['callback_url'] = "%(url)s/interswitch_acco_cb" % row
             href = '%(query_url)s' % info
             href += '?transRef=%(trans_ref)s' % row
@@ -116,5 +112,5 @@
             href += '&redirectURL=%(callback_url)s' % row
             row['href'] = href
-    if (review_state == "closed") and so_doc.resp_code in ('SC','00','AP','IP',):
+    if (review_state == "closed") and payment_doc.resp_code in ('SC','00','AP','IP',):
         row['confirmed'] = 'active'
     else:
@@ -122,4 +118,52 @@
     row['is_editable'] = is_so and (row['confirmed'] == 'active')
     payments.append(row)
+# payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
+# sos = context.portal_catalog(container_path=payments_path)
+# info['is_so'] = is_so
+
+# for so in sos:
+#     row = {}
+#     row['id'] = so.getId
+#     row['title'] = so.Title
+#     url = row['url'] = "%s/%s" % (payments_path,so.getId)
+#     so_doc = context.restrictedTraverse(url,default=None).getContent()
+#     row['type'] = so.portal_type
+#     review_state = row['review_state'] = so.review_state
+#     if so_doc.type_description.startswith('School Fee'):
+#         row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] in ('cleared_and_validated','returning')
+#     else:
+#         row['is_approvable'] = False    # is_so and (review_state == "opened")
+#     row['is_requeryable'] = False
+#     #set_trace()
+#     row['resp_desc'] = getattr(so_doc,'resp_desc','no response')
+#     row['trans_ref'] = getattr(so_doc,'order_id','')
+#     if so_doc.type_description.startswith('School Fee'):
+#         if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated','returning') and \
+#                                   hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
+#             row['is_requeryable'] = True
+#             row['callback_url'] = "%s/payments/%s/interswitch_cb" % (student.absolute_url(),
+#                                                             so.getId)
+#             href = '%(query_url)s' % info
+#             href += '?transRef=%(trans_ref)s' % row
+#             href += '&prodID=%(prod_id)s' % info
+#             href += '&redirectURL=%(callback_url)s' % row
+#             row['href'] = href
+#     elif so_doc.type_description.startswith('Hostel'):
+#         if (review_state == 'opened' and \
+#                                   hasattr(so_doc, 'order_id') and not so_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
+#             row['is_requeryable'] = True
+#             row['callback_url'] = "%s/payments/%s/interswitch_acco_cb" % (student.absolute_url(),
+#                                                             so.getId)
+#             href = '%(query_url)s' % info
+#             href += '?transRef=%(trans_ref)s' % row
+#             href += '&prodID=%(prod_id)s' % info
+#             href += '&redirectURL=%(callback_url)s' % row
+#             row['href'] = href
+#     if (review_state == "closed") and so_doc.resp_code in ('SC','00','AP','IP',):
+#         row['confirmed'] = 'active'
+#     else:
+#         row['confirmed'] = 'unsuccessful'
+#     row['is_editable'] = is_so and (row['confirmed'] == 'active')
+#     payments.append(row)
 
 payments.sort(cmp_id)
