Ignore:
Timestamp:
15 Nov 2018, 10:24:58 (6 years ago)
Author:
Henrik Bettermann
Message:

Catch error and resize table.

File:
1 edited

Legend:

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

    r15243 r15244  
    9292        if entry_session != 0 and  stud.entry_session != entry_session:
    9393            continue
    94         if breakdown == 'faccode':
    95             if getattr(stud, 'faccode') not in paths:
    96                 # studs can have a faccode ``None``
    97                 continue
     94        if None in  (getattr(stud, 'faccode'), getattr(stud, 'depcode')):
     95            continue
    9896        # Dep codes are not unique.
    9997        if breakdown == 'depcode':
     
    163161        i = 0
    164162        while i < len(data[idx]):
    165             row.append("%s (%s)" % ("{:,}".format(data[idx][i+1]), data[idx][i]))
     163            if row_name == 'Total':
     164                row.append(
     165                    "%s\n(%s)" % ("{:,}".format(data[idx][i+1]), data[idx][i]))
     166            else:
     167                row.append(
     168                    "%s (%s)" % ("{:,}".format(data[idx][i+1]), data[idx][i]))
    166169            i += 2
    167170        row = [row_name] + row
     
    242245    def create_pdf(self, job_id):
    243246        creator = getUtility(IPDFCreator, name=self.pdfcreator)
    244         maxlength = len(str(self.data[2][-1][-1])) \
    245             + len(str(self.data[2][-1][-2])) \
    246             + 3
    247         maxlength = max(maxlength, 10)
     247        # maxlength = len(str(self.data[2][-1][-1])) \
     248        #     + len(str(self.data[2][-1][-2])) \
     249        #     + 3
     250        # maxlength = max(maxlength, 10)
    248251        table_data = tbl_data_to_table(*self.data)
    249         col_widths = [None,] + [.17*cm*maxlength] * len(self.data[1]) + [None,]
     252        # col_widths = [None,] + [.17*cm*maxlength] * len(self.data[1]) + [None,]
    250253        pdf_data = [Paragraph('<b>%s - Report %s</b>'
    251254                              % (self.creation_dt_string, job_id),
     
    266269                    Spacer(1, 12),]
    267270        pdf_data += [
    268             Table(table_data, style=TABLE_STYLE, colWidths=col_widths)]
     271            Table(table_data, style=TABLE_STYLE)]
    269272        right_footer = translate(
    270             _('${a} Student Payments - ${b} -',
    271             mapping = {'a':self.mode, 'b':self.session}))
     273            _('Student Payments - ${a} - ${b} - ${c} - ',
     274            mapping = {'a':self.mode, 'b':self.session, 'c':self.level}))
    272275        pdf = creator.create_pdf(
    273276            pdf_data, None, self.title, self.author, right_footer
Note: See TracChangeset for help on using the changeset viewer.