Ignore:
Timestamp:
21 May 2015, 07:38:15 (9 years ago)
Author:
Henrik Bettermann
Message:

Add StudentUnpaidPaymentExporter? to export only unpaid tickets. This exporter is designed for finding and finally purging outdated payment ticket.

File:
1 edited

Legend:

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

    r12873 r12971  
    8686    return tickets
    8787
    88 def get_payments(students, paid=False, **kw):
     88def get_payments(students, p_state=None, **kw):
    8989    """Get all payments of `students` within given payment_date period.
    9090    """
     
    100100        payments_start = tz.localize(payments_start)
    101101        payments_end = tz.localize(payments_end)
    102         if paid:
    103             # Only paid tickets in payment period are considered
     102        if p_state:
     103            # Only paid or unpaid tickets in payment period are considered
    104104            for student in students:
    105105                for payment in student.get('payments', {}).values():
    106                     if payment.payment_date and payment.p_state == 'paid':
     106                    if payment.payment_date and payment.p_state == p_state:
    107107                        payment_date = to_timezone(payment.payment_date, tz)
    108108                        if payment_date > payments_start and \
     
    120120    else:
    121121        # Payment period not given
    122         if paid:
     122        if p_state:
    123123            # Only paid tickets are considered
    124124            for student in students:
    125125                for payment in student.get('payments', {}).values():
    126                     if payment.p_state == 'paid':
     126                    if payment.p_state == p_state:
    127127                        payments.append(payment)
    128128        else:
     
    382382            value, name, context=context)
    383383
     384class StudentUnpaidPaymentExporter(StudentPaymentExporter):
     385    """The Student Unpaid Payment Exporter works just like the
     386    Student Payments Exporter but it exports only unpaid tickets.
     387    This exporter is designed for finding and finally purging outdated
     388    payment ticket.
     389    """
     390    grok.name('studentunpaidpayments')
     391
     392    title = _(u'Student Unpaid Payments')
     393
     394    def filter_func(self, x, **kw):
     395        return get_payments(x, p_state='unpaid', **kw)
     396
    384397class DataForBursaryExporter(StudentPaymentExporter):
    385398    """The DataForBursary Exporter works just like the Student Payments Exporter
     
    392405
    393406    def filter_func(self, x, **kw):
    394         return get_payments(x, paid=True, **kw)
     407        return get_payments(x, p_state='paid', **kw)
    395408
    396409    fields = tuple(
Note: See TracChangeset for help on using the changeset viewer.