Changeset 2897


Ignore:
Timestamp:
9 Dec 2007, 16:42:12 (17 years ago)
Author:
joachim
Message:

fix upgrade updatePayment and updatePayments

Location:
WAeUP_SRP/base
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Payment.py

    r2891 r2897  
    3131        return "Payments"
    3232
     33
    3334    security.declareProtected(View,"updatePayments")
    3435    def updatePayments(self):
     
    3637        logger = logging.getLogger('PaymentsFolder.updatePayments')
    3738        #import pdb;pdb.set_trace()
    38         wftool = self.portal_workflow
    3939        for payment in self.aq_parent.objectValues():
    40             d = {}
    41             student_record = self.students_catalog.getRecordByKey(self.getStudentId())
    42             doc = payment.getContent()
    43             d['key'] = payment.getId()
    44             d['amount'] = doc.amount
    45             d['type_description'] = doc.type_description
    46             subject = ''
    47             if doc.type_description.startswith('School'):
    48                 subject = 'schoolfee'
    49             sp = doc.type_description.rfind('/')
    50             d['session_id'] = doc.type_description[sp-2:sp]
    51             d['subject'] = subject # zb. schoolfee
    52             while True:
    53                 if doc.resp_code == "SC":
    54                     p_type = "sc"
    55                     p_status = "paid"
    56                     break
    57                 if doc.resp_code in ("00","IP","AP"):
    58                     p_type = "online"
    59                     p_status = "paid"
    60                     break
    61                 p_type = "online"
    62                 p_status = "open"
    63                 break
    64             d['key'] = payment.getId()
    65             d['type'] = p_type  # scratch card
    66             d['item'] = student_record.course
    67             d['status'] = p_status
    68             d['resp_approved_amount'] = getattr(doc,'resp_approved_amount',None)
    69             d['resp_pay_reference'] = doc.resp_pay_reference
    70             d['resp_desc'] = doc.resp_desc
    71             d['order_id'] = doc.order_id
    72             d['resp_code'] = doc.resp_code
    73             d['resp_card_num'] = doc.resp_card_num
    74             d['date'] = getattr(doc,'date',None)
    75             #d['resp_date'] = getattr(doc,'resp_date',None)
    76             # msg = " ".join(["%s: %s" % (key,value) for key,value in d.items()])
    77             # logger.info(msg)
    78 
    79             review_state = wftool.getInfoFor(payment,'review_state',None)
    80             if review_state == "closed":
    81                 wftool.doActionFor(payment,'open')
    82             doc.edit(mapping = d)
    83             if review_state == "closed":
    84                 wftool.doActionFor(payment,'close')
     40            student_record = self.getRecordByKey(self.getStudentId())
     41            payment['updatePayment'](student_record)
    8542
    8643InitializeClass(PaymentsFolder)
     
    11471    ###)
    11572
     73    security.declareProtected(View,"updatePayment")
     74    def updatePayment(self,student_record):
     75        doc = self.getContent()
     76        if getattr(doc,'status',None):
     77            return
     78        wftool = self.portal_workflow
     79        d = {}
     80        #student_record = self.students_catalog.getRecordByKey(self.getStudentId())
     81        d['key'] = self.getId()
     82        d['amount'] = doc.amount
     83        #d['description'] = d['type_description'] = doc.type_description
     84        category = ''
     85        if doc.type_description.startswith('School'):
     86            category = 'schoolfee'
     87        sp = doc.type_description.rfind('/')
     88        d['session_id'] = doc.type_description[sp-2:sp]
     89        d['category'] = category # zb. schoolfee
     90        while True:
     91            if doc.resp_code == "SC":
     92                p_type = "sc"
     93                p_status = "paid"
     94                break
     95            if doc.resp_code in ("00","IP","AP"):
     96                p_type = "online"
     97                p_status = "paid"
     98                break
     99            p_type = "online"
     100            p_status = "started"
     101            break
     102        d['type'] = p_type  # scratch card
     103        d['item'] = getattr(student_record,'course','')
     104        d['status'] = p_status
     105        d['resp_approved_amount'] = getattr(doc,'resp_approved_amount',None)
     106        d['resp_pay_reference'] = doc.resp_pay_reference
     107        d['resp_desc'] = doc.resp_desc
     108        d['order_id'] = self.aq_parent.getId()
     109        d['resp_code'] = doc.resp_code
     110        d['resp_card_num'] = doc.resp_card_num
     111        d['date'] = getattr(doc,'date',None)
     112        # msg = " ".join(["%s: %s" % (key,value) for key,value in d.items()])
     113        # logger.info(msg)
     114       
     115        review_state = wftool.getInfoFor(self,'review_state',None)
     116        if review_state == "closed":
     117            wftool.doActionFor(self,'open')
     118        doc.edit(mapping = d)
     119        if review_state == "closed":
     120            wftool.doActionFor(self,'close')
     121
    116122InitializeClass(Payment)
    117123
  • WAeUP_SRP/base/WAeUPTables.py

    r2868 r2897  
    14741474        except:
    14751475            logger = logging.getLogger('WAeUPTables.PaymentsCatalog.%s' % self.__name__)
    1476             logger.info("could not add or modify entry for %(key)s" % data)
     1476            logger.info("could not add or modify entry for %(order_id)s" % data)
    14771477    ###)
    14781478
  • WAeUP_SRP/base/skins/waeup_epayment/upgradePayments.py

    r2886 r2897  
    5050logger.info("found %d payments" % total)
    5151sid = "xxx"
    52 #set_trace()
    5352count = 1
    5453commit_after = 5
    5554commit_count = 0
    5655
    57 set_trace()
     56student_id = ''
    5857for payment_brain in payments:
    5958    payment = payment_brain.getObject()
    60     payment['updatePayment']()
    61     # student_id = payment.getPath().split('/')[-3]
    62     # student_brain = context.students_catalog.getRecordByKey(student_id)
    63     # if student_brain is None:
    64     #     logger.info("student %s not in students_catalog" % student_id)
    65     #     continue
    66     # d = {}
    67     # doc = payment.getObject().getContent()
    68     # d['key'] = payment.getId
    69     # d['amount'] = doc.amount
    70     # d['description'] = d['type_description'] = doc.type_description
    71     # subject = ''
    72     # if doc.type_description.startswith('School'):
    73     #     subject = 'schoolfee'
    74     # sp = doc.type_description.rfind('/')
    75     # d['session_id'] = doc.type_description[sp-2:sp]
    76     # d['subject'] = subject # zb. schoolfee
    77     # d['target'] = "%s" % (student_brain.course)  # faculty departmen course
    78     # while True:
    79     #     if doc.resp_code == "SC":
    80     #         p_type = "sc"
    81     #         p_status = "paid"
    82     #         break
    83     #     if doc.resp_code == "00":
    84     #         p_type = "onl"
    85     #         p_status = "paid"
    86     #         break
    87     #     p_type = "ONL"
    88     #     p_status = "open"
    89     #     break
    90     # d['key'] = payment.getId
    91     # d['type'] = p_type  # scratch card
    92     # d['status'] = p_status
    93     # d['resp_approved_amount'] = getattr(doc,'resp_approved_amount',None)
    94     # d['resp_pay_reference'] = doc.resp_pay_reference
    95     # d['resp_desc'] = doc.resp_desc
    96     # d['order_id'] = doc.order_id
    97     # d['resp_code'] = doc.resp_code
    98     # d['resp_card_num'] = doc.resp_card_num
    99     # d['date'] = getattr(doc,'date',None)
    100     # d['resp_date'] = getattr(doc,'resp_date',None)
    101     # doc.edit(mapping = d)
    102     # msg = " ".join(["%s: %s" % (key,value) for key,value in d.items()])
    103     # rwrite(msg)
    104     logger.info('upgraded student %s payment %s' % (student_id,d['key']))
     59    if payment_brain.getPath().split('/')[-3] != student_id:
     60        student_id = payment_brain.getPath().split('/')[-3]
     61        student_record = context.students_catalog.getRecordByKey(student_id)
     62    payment['updatePayment'](student_record)
     63    logger.info('upgraded student %s payment %s' % (student_record.id,payment.getId()))
    10564    if not count % commit_after:
    10665        logger.info("committing %d total %d" % (commit_after,count))
    10766        commit_count += 1
    108         # if not commit_count % 2:
    109         #     break
     67        if not commit_count % 2:
     68            break
    11069    count += 1
    11170logger.info("%d of %d upgraded" % (count,total))
Note: See TracChangeset for help on using the changeset viewer.