Beispiel #1
0
def build_consumption_report(filename=None, format='pdf'):
    ''' PDF: List of consumptions '''
    if not filename:
        filename = get_temp_filename('pdf')

    doc = Document(title=_(u"List of consumptions"))

    table = Table(2)
    table.add_header_row([Text(_(u"Date")), Text(_(u"Consumption"))])

    # column alignments
    table.set_alignment(Table.ALIGN_LEFT, column=0)
    table.set_alignment(Table.ALIGN_LEFT, column=1)

    operations = [(op[0], op[1]) for op in consumption()]

    for operation in operations:
        table.add_row(
            [Text(unicode(operation[0])),
             Text(unicode(operation[1]))])

    doc.add_element(table)

    gen = PDFGenerator(doc, filename)
    gen.render_document()

    return gen.get_filename()
Beispiel #2
0
def build_consumption_report(filename=None, format='pdf'):
    ''' PDF: List of consumptions '''
    if not filename:
        filename = get_temp_filename('pdf')

    doc = Document(title=_(u"List of consumptions"))

    table = Table(2)
    table.add_header_row([
            Text(_(u"Date")),
            Text(_(u"Consumption"))])

    # column alignments
    table.set_alignment(Table.ALIGN_LEFT, column=0)
    table.set_alignment(Table.ALIGN_LEFT, column=1)

    operations = [(op[0], op[1]) for op in consumption()]

    for operation in operations:
        table.add_row([
            Text(unicode(operation[0])),
            Text(unicode(operation[1]))])

    doc.add_element(table)

    gen = PDFGenerator(doc, filename)
    gen.render_document()

    return gen.get_filename()
Beispiel #3
0
 def set_data_for(self):
     consumptions = consumption()
     consumptions.reverse()
     self.data = [(op[0].strftime(_(u'%x %Hh:%Mmn')),\
                         formatted_number(op[1]))
         for op in consumptions]
Beispiel #4
0
 def set_data_for(self):
     consumptions = consumption()
     consumptions.reverse()
     self.data = [(op[0].strftime(_(u'%x %Hh:%Mmn')),\
                         formatted_number(op[1]))
         for op in consumptions]