Ignore:
Timestamp:
3 Aug 2017, 12:43:47 (7 years ago)
Author:
Henrik Bettermann
Message:

DataForBursaryExporter? now exports also waived payment tickets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r14596 r14761  
    114114    return tickets
    115115
    116 def get_payments(students, p_state=None, **kw):
     116def get_payments(students, p_states=None, **kw):
    117117    """Get all payments of `students` within given payment_date period.
    118118    """
     
    128128        payments_start = tz.localize(payments_start)
    129129        payments_end = tz.localize(payments_end) + timedelta(days=1)
    130         if p_state:
    131             # Only paid or unpaid tickets in payment period are considered
     130        if p_states:
     131            # Only tickets in certain states and payment period are considered
    132132            for student in students:
    133133                for payment in student.get('payments', {}).values():
    134                     if payment.payment_date and payment.p_state == p_state:
     134                    if payment.payment_date and payment.p_state in p_states:
    135135                        payment_date = to_timezone(payment.payment_date, tz)
    136136                        if payment_date > payments_start and \
     
    148148    else:
    149149        # Payment period not given
    150         if p_state:
     150        if p_states:
    151151            # Only paid tickets are considered
    152152            for student in students:
    153153                for payment in student.get('payments', {}).values():
    154                     if payment.p_state == p_state:
     154                    if payment.p_state in p_states:
    155155                        payments.append(payment)
    156156        else:
     
    453453
    454454    def filter_func(self, x, **kw):
    455         return get_payments(x, p_state='unpaid', **kw)
     455        return get_payments(x, p_states=('unpaid',) , **kw)
    456456
    457457class DataForBursaryExporter(StudentPaymentExporter):
     
    460460    payment and student data in one table in order to spare postprocessing of
    461461    two seperate export files. The exporter is primarily used by bursary
    462     officers who have exclusively access to this exporter.
     462    officers who have exclusively access to this exporter. The exporter
     463    exports ``paid`` and ``waived`` payment tickets.
    463464    """
    464465    grok.name('bursary')
    465466
    466467    def filter_func(self, x, **kw):
    467         return get_payments(x, p_state='paid', **kw)
     468        return get_payments(x, p_states=('paid', 'waived'), **kw)
    468469
    469470    fields = tuple(
Note: See TracChangeset for help on using the changeset viewer.