Ignore:
Timestamp:
25 Feb 2008, 18:09:19 (17 years ago)
Author:
joachim
Message:

fix for #101 okene,please test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py

    r3069 r3226  
    1212Info for the PaymentsFolder
    1313"""
     14from Products.AdvancedQuery import Eq, Between, Le,In
    1415
    1516mtool = context.portal_membership
    1617wftool = context.portal_workflow
    1718member = mtool.getAuthenticatedMember()
     19payments_catalog = context.payments_catalog
     20aq_payments = payments_catalog.evalAdvancedQuery
    1821if mtool.isAnonymousUser():
    1922    return None
     
    3841import DateTime
    3942request = context.REQUEST
    40 students = context.portal_url.getPortalObject().campus.students
     43#students = context.portal_url.getPortalObject().campus.students
    4144student_id = context.getStudentId()
    4245if student_id is None:
    4346    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
    44 student = getattr(students,student_id)
     47#student = getattr(students,student_id)
    4548student_record = context.students_catalog.getRecordByKey(student_id)
    4649#context['updatePayments']()
    47 payments = []
    4850
    4951info = {}
     
    7577
    7678info['student_name'] = student_record.name
    77 
    78 for payment_id,payment in context.objectItems():
     79payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
     80payments = []
     81payment_records = aq_payments(Eq('student_id',student_id) & Eq('session_id',student_record.session))
     82vocabularies = context.portal_vocabularies
     83paid_fees = []
     84for payment in payment_records:
     85    if payment.status == "paid":
     86        paid_fees += "%s_%s" % (payment.type,payment.session_id),
     87for payment in payment_records:
    7988    row = {}
    80     row['id'] = payment_id
    81     row['title'] = payment.Title()
    82     url = row['url'] = payment.absolute_url()
    83     payment_doc = payment.getContent()
    84     row['type'] = payment_doc.portal_type
    85     review_state = row['review_state'] = wftool.getInfoFor(payment,'review_state',None)
    86     if payment_doc.type_description.startswith('School Fee'):
    87         row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
    88     else:
    89         row['is_approvable'] = is_so and (review_state == "opened")
    90     row['is_requeryable'] = False
    91     #set_trace()
    92     row['resp_desc'] = getattr(payment_doc,'resp_desc','no response')
    93     row['trans_ref'] = getattr(payment_doc,'order_id','')
    94     if payment_doc.type_description.startswith('School Fee'):
    95         if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated',) and \
    96             hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin',):
    97             row['is_requeryable'] = True
    98             row['callback_url'] = "%(url)s/interswitch_cb" % row
    99             href = '%(query_url)s' % info
    100             href += '?transRef=%(trans_ref)s' % row
    101             href += '&prodID=%(prod_id)s' % info
    102             href += '&redirectURL=%(callback_url)s' % row
    103             row['href'] = href
    104     elif payment_doc.type_description.startswith('Hostel'):
    105         if (review_state == 'opened' and \
    106             hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
    107             row['is_requeryable'] = True
    108             row['callback_url'] = "%(url)s/interswitch_acco_cb" % row
    109             href = '%(query_url)s' % info
    110             href += '?transRef=%(trans_ref)s' % row
    111             href += '&prodID=%(prod_id)s' % info
    112             href += '&redirectURL=%(callback_url)s' % row
    113             row['href'] = href
    114     if (review_state == "closed") and payment_doc.resp_code in ('SC','00','AP','IP',):
     89    row['id'] = payment.key
     90    row['title'] = "%s for Session %s, Naira %s, %s" % (vocabularies.payment_categories.get(payment.category),
     91                                                        vocabularies.sessions.get(payment.session_id),
     92                                                        payment.amount,
     93                                                        payment.date.strftime("%d/%m/%y %H:%M:%S"))
     94    url = row['url'] = "%s/p%s" % (payments_path,payment.order_id[6:])
     95    row['is_requeryable'] = "%s_%s" % (payment.type,payment.session_id) not in paid_fees
     96    row['is_approvable'] = is_so and row['is_requeryable']
     97    row['resp_desc'] = payment.resp_desc or payment.status
     98    row['trans_ref'] = payment.order_id
     99    if row['is_requeryable']:
     100        row['callback_url'] = "%(url)s/interswitch_cb" % row
     101        href = '%(query_url)s' % info
     102        href += '?transRef=%(trans_ref)s' % row
     103        href += '&prodID=%(prod_id)s' % info
     104        href += '&redirectURL=%(callback_url)s' % row
     105        row['href'] = href
     106    if payment.status == 'paid':
    115107        row['confirmed'] = 'active'
    116108    else:
     
    118110    row['is_editable'] = is_so and (row['confirmed'] == 'active')
    119111    payments.append(row)
     112# for payment_id,payment in context.objectItems():
     113#     row = {}
     114#     row['id'] = payment_id
     115#     row['title'] = payment.Title()
     116#     url = row['url'] = payment.absolute_url()
     117#     payment_doc = payment.getContent()
     118#     row['type'] = payment_doc.portal_type
     119#     review_state = row['review_state'] = wftool.getInfoFor(payment,'review_state',None)
     120#     if payment_doc.type_description.startswith('School Fee'):
     121#         row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
     122#     else:
     123#         row['is_approvable'] = is_so and (review_state == "opened")
     124#     row['is_requeryable'] = False
     125#     #set_trace()
     126#     row['resp_desc'] = getattr(payment_doc,'resp_desc','no response')
     127#     row['trans_ref'] = getattr(payment_doc,'order_id','')
     128#     if payment_doc.type_description.startswith('School Fee'):
     129#         if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated',) and \
     130#             hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin',):
     131#             row['is_requeryable'] = True
     132#             row['callback_url'] = "%(url)s/interswitch_cb" % row
     133#             href = '%(query_url)s' % info
     134#             href += '?transRef=%(trans_ref)s' % row
     135#             href += '&prodID=%(prod_id)s' % info
     136#             href += '&redirectURL=%(callback_url)s' % row
     137#             row['href'] = href
     138#     elif payment_doc.type_description.startswith('Hostel'):
     139#         if (review_state == 'opened' and \
     140#             hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin','delejason','isouaba'):
     141#             row['is_requeryable'] = True
     142#             row['callback_url'] = "%(url)s/interswitch_acco_cb" % row
     143#             href = '%(query_url)s' % info
     144#             href += '?transRef=%(trans_ref)s' % row
     145#             href += '&prodID=%(prod_id)s' % info
     146#             href += '&redirectURL=%(callback_url)s' % row
     147#             row['href'] = href
     148#     if (review_state == "closed") and payment_doc.resp_code in ('SC','00','AP','IP',):
     149#         row['confirmed'] = 'active'
     150#     else:
     151#         row['confirmed'] = 'unsuccessful'
     152#     row['is_editable'] = is_so and (row['confirmed'] == 'active')
     153#     payments.append(row)
    120154# payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
    121155# sos = context.portal_catalog(container_path=payments_path)
Note: See TracChangeset for help on using the changeset viewer.