Beispiel #1
0
 def balance_info(cls, dc, **kwargs):
     qs = cls.objects.filter(**kwargs)
     qs = qs.order_by('value_date')
     bal = ZERO
     s = ''
     for mvt in qs:
         amount = mvt.amount
         if mvt.dc == dc:
             bal -= amount
             s += ' -' + str(amount)
         else:
             bal += amount
             s += ' +' + str(amount)
         s += " ({0}) ".format(mvt.voucher)
         # s += " ({0} {1}) ".format(
         #     mvt.voucher,
         #     dd.fds(mvt.voucher.voucher_date))
     if bal:
         return s + "= " + str(bal)
     return ''
     if False:
         from lino_xl.lib.cal.utils import day_and_month
         mvts = []
         for dm in get_due_movements(CREDIT, models.Q(partner=self.pupil)):
             s = dm.match
             s += " [{0}]".format(day_and_month(dm.due_date))
             s += " ("
             s += ', '.join([str(i.voucher) for i in dm.debts])
             if len(dm.payments):
                 s += " - "
                 s += ', '.join([str(i.voucher) for i in dm.payments])
             s += "): {0}".format(dm.balance)
             mvts.append(s)
         return '\n'.join(mvts)
Beispiel #2
0
 def balance_info(cls, dc, **kwargs):
     qs = cls.objects.filter(**kwargs)
     qs = qs.order_by('value_date')
     bal = ZERO
     s = ''
     for mvt in qs:
         amount = mvt.amount
         if mvt.dc == dc:
             bal -= amount
             s += ' -' + str(amount)
         else:
             bal += amount
             s += ' +' + str(amount)
         s += " ({0}) ".format(mvt.voucher)
         # s += " ({0} {1}) ".format(
         #     mvt.voucher,
         #     dd.fds(mvt.voucher.voucher_date))
     if bal:
         return s + "= " + str(bal)
     return ''
     if False:
         from lino_xl.lib.cal.utils import day_and_month
         mvts = []
         for dm in get_due_movements(CREDIT, partner=self.pupil):
             s = dm.match
             s += " [{0}]".format(day_and_month(dm.due_date))
             s += " ("
             s += ', '.join([str(i.voucher) for i in dm.debts])
             if len(dm.payments):
                 s += " - "
                 s += ', '.join([str(i.voucher) for i in dm.payments])
             s += "): {0}".format(dm.balance)
             mvts.append(s)
         return '\n'.join(mvts)
Beispiel #3
0
    def custom_build(self, ar, obj, target):
        from openpyxl.workbook import Workbook
        from openpyxl.styles import Alignment
        events = obj.events_by_course().order_by('start_date')

        xt = XlsTable()
        
        # def func(enr):
        #     # s = ''.join([str(e) for e in enr.pupil_info])
        #     s = enr.pupil_info.text
        #     print(20160512, s, E.tostring(enr.pupil_info))
        #     return s
        # xt.add_column("Teilnehmer", func)
        xt.add_column(
            "Teilnehmer", lambda enr: enr.pupil_info.text,
            alignment=Alignment(
                horizontal="general", vertical="top",
                wrap_text=True))

        xt.add_column("Anzahl", lambda enr: enr.places)
        xt.add_column("Start", lambda enr: enr.start_date)
        xt.add_column("End", lambda enr: enr.end_date)
        xt.add_column("Invoicing", lambda enr: enr.invoicing_info.text)
        xt.add_column("Payment", lambda enr: enr.payment_info)

        for i, evt in enumerate(events):
            lbl = day_and_month(evt.start_date)

            def func(enr):
                qs = rt.models.cal.Guest.objects.filter(
                    event=evt, partner=enr.pupil)
                n = qs.count()
                if n == 0:
                    return ''
                return n
                
            xt.add_column(
                lbl, func, alignment=Alignment(
                    vertical="center", text_rotation=90), width=4)
        xt.add_column("...", lambda enr: "")
        xt.add_column("...", lambda enr: "")
        xt.add_column("...", lambda enr: "")

        wb = Workbook()
        # sheet = wb.add_sheet(str(obj))
        ws = wb.active
        ws.title = str(obj)
        # ws.page_setup.orientation = ws.ORIENTATION_LANDSCAPE
        # print(type(six.text_type('100')))
        ws.column_dimensions["A"].width = 40
        ws.row_dimensions[1].height = 30
        xt.write_to_sheet(ws, obj.enrolments)
        wb.save(target)
Beispiel #4
0
 def events_text(self, ar=None):
     return ', '.join([
         day_and_month(e.start_date)
         for e in self.events_by_order().order_by('start_date')])
Beispiel #5
0
 def events_text(self, ar=None):
     return ', '.join([
         day_and_month(e.start_date)
         for e in self.events_by_order().order_by('start_date')])
Beispiel #6
0
 def events_text(self, ar=None):
     if cal is not None:
         return ', '.join([
             day_and_month(e.start_date)
             for e in self.events_by_course().order_by('start_date')
         ])
Beispiel #7
0
 def fmt(ev, ar=None):
     txt = day_and_month(ev.start_date)
     if ar is None:
         return txt
     return ar.obj2html(ev, txt)