예제 #1
0
def create_datalist(memberid=None):
    # TODO: template variable names in English
    # TODO: use Django SHORT_DATE_FORMAT
    # TODO: do LaTeX-specific escaping utilities belong into an application-wide latex_utils.py?
    datalist = []
    for cycle in get_data(memberid).all():
        # check if paper reminder already sent
        cont = False
        for bill in cycle.bill_set.all():
            if bill.type == 'P':
                cont=True
                break
        if cont:
            continue

        membercontact = cycle.membership.get_billing_contact()
        data = {
            'DATE'      : datetime.now().strftime("%d.%m.%Y"),
            'JASENNRO'  : cycle.membership.id,
            'NIMI'      : tex_sanitize(cycle.membership.name()),
            'SUMMA'     : cycle.sum,
            'VIITENRO'  : cycle.reference_number,
            'MAKSUDATA' : prettyname(cycle),
            'EMAIL'     : tex_sanitize(membercontact.email.replace("_", "\_")),
            'OSOITE'    : tex_sanitize(membercontact.street_address),
            'POSTI'     : tex_sanitize("%s %s" % (membercontact.postal_code, membercontact.post_office)),
            'BARCODE'   : barcode_4(settings.IBAN_ACCOUNT_NUMBER,cycle.reference_number,None,cycle.sum)
        }
        datalist.append(data)
    return datalist
예제 #2
0
파일: models.py 프로젝트: ripesal/sikteeri
 def render_as_text(self):
     """
     Renders the object as text suitable for sending as e-mail.
     """
     membership = self.billingcycle.membership
     vat = Decimal(self.billingcycle.get_vat_percentage()) / Decimal(100)
     if not self.is_reminder():
         non_vat_amount = (self.billingcycle.sum / (Decimal(1) + vat))
         return render_to_string('membership/bill.txt', {
             'membership_type' : MEMBER_TYPES_DICT[membership.type],
             'membership_type_raw' : membership.type,
             'bill_id': self.id,
             'member_id': membership.id,
             'member_name': membership.name(),
             'billing_contact': membership.billing_contact,
             'billing_name': unicode(membership.get_billing_contact()),
             'street_address': membership.get_billing_contact().street_address,
             'postal_code': membership.get_billing_contact().postal_code,
             'post_office': membership.get_billing_contact().post_office,
             'billingcycle': self.billingcycle,
             'iban_account_number': settings.IBAN_ACCOUNT_NUMBER,
             'bic_code': settings.BIC_CODE,
             'due_date': self.due_date,
             'today': datetime.now(),
             'reference_number': group_right(self.billingcycle.reference_number),
             'sum': self.billingcycle.sum,
             'vat_amount': vat * non_vat_amount,
             'non_vat_amount': non_vat_amount,
             'vat_percentage': self.billingcycle.get_vat_percentage(),
             'barcode': barcode_4(iban = settings.IBAN_ACCOUNT_NUMBER,
                                  refnum = self.billingcycle.reference_number,
                                  duedate = self.due_date,
                                  euros = self.billingcycle.sum)
             })
     else:
         amount_paid = self.billingcycle.amount_paid()
         sum = self.billingcycle.sum - amount_paid
         non_vat_amount = sum / (Decimal(1) + vat)
         return render_to_string('membership/reminder.txt', {
             'membership_type' : MEMBER_TYPES_DICT[membership.type],
             'membership_type_raw' : membership.type,
             'bill_id': self.id,
             'member_id': membership.id,
             'member_name': membership.name(),
             'billing_contact': membership.billing_contact,
             'billing_name': unicode(membership.get_billing_contact()),
             'street_address': membership.get_billing_contact().street_address,
             'postal_code': membership.get_billing_contact().postal_code,
             'post_office': membership.get_billing_contact().post_office,
             'municipality': membership.municipality,
             'billing_email': membership.get_billing_contact().email,
             'email': membership.primary_contact().email,
             'billingcycle': self.billingcycle,
             'iban_account_number': settings.IBAN_ACCOUNT_NUMBER,
             'bic_code': settings.BIC_CODE,
             'today': datetime.now(),
             'latest_recorded_payment': Payment.latest_payment_date(),
             'reference_number': group_right(self.billingcycle.reference_number),
             'original_sum': self.billingcycle.sum,
             'amount_paid': amount_paid,
             'sum': sum,
             'vat_amount': vat * non_vat_amount,
             'non_vat_amount':   non_vat_amount,
             'vat_percentage': self.billingcycle.get_vat_percentage(),
             'barcode': barcode_4(iban = settings.IBAN_ACCOUNT_NUMBER,
                                  refnum = self.billingcycle.reference_number,
                                  duedate = None,
                                  euros = sum)
             })
예제 #3
0
파일: models.py 프로젝트: ptMuta/sikteeri
 def render_as_text(self):
     """
     Renders the object as text suitable for sending as e-mail.
     """
     membership = self.billingcycle.membership
     vat = Decimal(self.billingcycle.get_vat_percentage()) / Decimal(100)
     if not self.is_reminder():
         non_vat_amount = (self.billingcycle.sum / (Decimal(1) + vat))
         return render_to_string(
             'membership/bill.txt', {
                 'membership_type':
                 MEMBER_TYPES_DICT[membership.type],
                 'membership_type_raw':
                 membership.type,
                 'bill_id':
                 self.id,
                 'member_id':
                 membership.id,
                 'member_name':
                 membership.name(),
                 'billing_contact':
                 membership.billing_contact,
                 'billing_name':
                 unicode(membership.get_billing_contact()),
                 'street_address':
                 membership.get_billing_contact().street_address,
                 'postal_code':
                 membership.get_billing_contact().postal_code,
                 'post_office':
                 membership.get_billing_contact().post_office,
                 'billingcycle':
                 self.billingcycle,
                 'iban_account_number':
                 settings.IBAN_ACCOUNT_NUMBER,
                 'bic_code':
                 settings.BIC_CODE,
                 'due_date':
                 self.due_date,
                 'today':
                 datetime.now(),
                 'reference_number':
                 group_right(self.billingcycle.reference_number),
                 'sum':
                 self.billingcycle.sum,
                 'vat_amount':
                 vat * non_vat_amount,
                 'non_vat_amount':
                 non_vat_amount,
                 'vat_percentage':
                 self.billingcycle.get_vat_percentage(),
                 'barcode':
                 barcode_4(iban=settings.IBAN_ACCOUNT_NUMBER,
                           refnum=self.billingcycle.reference_number,
                           duedate=self.due_date,
                           euros=self.billingcycle.sum)
             })
     else:
         amount_paid = self.billingcycle.amount_paid()
         sum = self.billingcycle.sum - amount_paid
         non_vat_amount = sum / (Decimal(1) + vat)
         return render_to_string(
             'membership/reminder.txt', {
                 'membership_type':
                 MEMBER_TYPES_DICT[membership.type],
                 'membership_type_raw':
                 membership.type,
                 'bill_id':
                 self.id,
                 'member_id':
                 membership.id,
                 'member_name':
                 membership.name(),
                 'billing_contact':
                 membership.billing_contact,
                 'billing_name':
                 unicode(membership.get_billing_contact()),
                 'street_address':
                 membership.get_billing_contact().street_address,
                 'postal_code':
                 membership.get_billing_contact().postal_code,
                 'post_office':
                 membership.get_billing_contact().post_office,
                 'municipality':
                 membership.municipality,
                 'billing_email':
                 membership.get_billing_contact().email,
                 'email':
                 membership.primary_contact().email,
                 'billingcycle':
                 self.billingcycle,
                 'iban_account_number':
                 settings.IBAN_ACCOUNT_NUMBER,
                 'bic_code':
                 settings.BIC_CODE,
                 'today':
                 datetime.now(),
                 'latest_recorded_payment':
                 Payment.latest_payment_date(),
                 'reference_number':
                 group_right(self.billingcycle.reference_number),
                 'original_sum':
                 self.billingcycle.sum,
                 'amount_paid':
                 amount_paid,
                 'sum':
                 sum,
                 'vat_amount':
                 vat * non_vat_amount,
                 'non_vat_amount':
                 non_vat_amount,
                 'vat_percentage':
                 self.billingcycle.get_vat_percentage(),
                 'barcode':
                 barcode_4(iban=settings.IBAN_ACCOUNT_NUMBER,
                           refnum=self.billingcycle.reference_number,
                           duedate=None,
                           euros=sum)
             })
예제 #4
0
파일: pdf.py 프로젝트: kahihia/sikteeri
    def addTemplate(self):
        # Logo to upper left corner
        self.drawImage(0.2, 0, 5, 2.5, LOGO)
        self.drawString(10.5,
                        3,
                        u"%(date)s" % self.data,
                        alignment="center",
                        size=12)
        self.drawString(1.5,
                        3,
                        u"Kapsi Internet-käyttäjät ry, PL 11, 90571 OULU",
                        size=8)
        # Address block
        self.drawText(
            1.5,
            4,
            u"%(name)s\n%(address)s\n%(postal_code)s %(postal_office)s" %
            self.data,
            size=12)
        #self.drawHorizontalStroke()

        self.drawBox(14.5, 3.5, 5, 1.7)
        self.drawTable(
            14.7,
            4, [[u'Jäsennumero:', '%(member_id)s' % self.data],
                [u'Eräpäivä:', '%(due_date)s' % self.data],
                [u'Huomautusaika:',
                 '%(notify_period)s' % self.data]],
            size=10)

        xtable = [1, 1.5, 7, 12, 13.5, 15, 17]
        self.drawString(xtable[1], 6.5, u"Selite", size=9)
        self.drawString(xtable[2], 6.5, u"Aikaväli", size=9)
        self.drawString(xtable[3], 6.5, u"ilman alv", size=9)
        self.drawString(xtable[4], 6.5, u"alv", size=9)
        self.drawString(xtable[5], 6.5, u"alv osuus", size=9)
        self.drawString(xtable[6], 6.5, u"Yhteensä", size=9)
        self.drawHorizontalStroke(1, 6.6, 18.5)

        y = 7
        for line in self.data['lineitems']:
            for i in range(len(xtable)):
                self.drawString(xtable[i], y, line[i], size=10)
            y += 0.4

        y -= 0.3
        self.drawHorizontalStroke(1, y, 18.5)
        y += 0.4
        self.drawString(xtable[3],
                        y,
                        u"Maksettavaa yhteensä:" % self.data,
                        size=10)
        self.drawString(xtable[6],
                        y,
                        u"<b>%(pretty_sum)s €</b>" % self.data,
                        size=10)

        self.drawHorizontalStroke(1, 18, 18.5)

        self.drawText(1,
                      18.5,
                      u"<b>Kapsi Internet-käyttäjät ry</b>\nPL 11\n90571 Oulu",
                      size=7)
        self.drawText(5.5,
                      18.5,
                      u"Kotipaikka Oulu\nhttps://www.kapsi.fi/",
                      size=7)
        self.drawText(
            9.5,
            18.5,
            u"Sähköposti: %s\nY-tunnus: %s\nYhdistysrekisterinumero: %s" %
            (get_billing_email(), settings.BUSINESS_ID,
             settings.ORGANIZATION_REG_ID),
            size=7)
        self.drawText(
            14,
            18.5,
            u"Tilinumero: %s\nBIC: %s" %
            (group_iban(settings.IBAN_ACCOUNT_NUMBER), settings.BIC_CODE),
            size=7)

        # Bill part

        self.drawString(2.3, 20, u"Saajan", size=6, alignment="right")
        self.drawString(2.3, 20.2, u"tilinumero", size=6, alignment="right")
        self.drawString(2.3, 20.5, u"Mottagarens", size=6, alignment="right")
        self.drawString(2.3, 20.7, u"kontonummer", size=6, alignment="right")

        self.drawText(
            3.0,
            20.6,
            u"%s   %s   %s" %
            (settings.BANK_NAME, group_iban(
                settings.IBAN_ACCOUNT_NUMBER), settings.BIC_CODE),
            size=9)

        self.drawString(2.3, 21.7, u"Saaja", size=6, alignment="right")
        self.drawString(2.3, 22.0, u"Mottagaren", size=6, alignment="right")

        self.drawText(3.0,
                      21.5,
                      u"Kapsi Internet-käyttäjät ry\nPL 11\n90571 Oulu",
                      size=9)

        self.drawString(2.4, 23, u"Maksajan", size=6, alignment="right")
        self.drawString(2.4, 23.2, u"nimi ja", size=6, alignment="right")
        self.drawString(2.4, 23.4, u"osoite", size=6, alignment="right")
        self.drawString(2.4, 23.7, u"Betalarens", size=6, alignment="right")
        self.drawString(2.4, 23.9, u"namn och", size=6, alignment="right")
        self.drawString(2.4, 24.1, u"adress", size=6, alignment="right")

        self.drawText(
            3.0,
            23.5,
            u"%(name)s\n%(address)s\n%(postal_code)s %(postal_office)s\n%(email)s"
            % self.data,
            size=9)

        self.drawString(2.4, 25.6, u"Allekirjoitus", size=6, alignment="right")
        #self.drawString(2.3, 25.6, u"", size=6, alignment="right")
        self.drawString(2.4, 25.9, u"Ynderskrift", size=6, alignment="right")

        self.drawString(2.3, 26.5, u"Tililtä", size=6, alignment="right")
        self.drawString(2.3,
                        26.75,
                        u"Från konto nr",
                        size=6,
                        alignment="right")

        self.drawString(3.75,
                        1.4,
                        u"<b>TILISIIRTO GIRERING</b>",
                        size=8,
                        flip=True)

        self.drawText(3.0, 20, u"IBAN", size=7)

        self.drawText(11.15, 25.6, u"Viitenro\nRef.nr", size=7)
        self.drawText(13.15, 25.7, u"%(reference_number)s" % self.data, size=9)
        self.drawText(11.15, 26.5, u"Eräpäivä\nFörf.dag", size=7)
        self.drawText(13.15, 26.65, u"%(due_date)s" % self.data, size=9)
        self.drawText(15.9, 26.4, u"Euro", size=7)
        self.drawText(16.9, 26.65, u"%(pretty_sum)s" % self.data, size=9)

        # Lines on bottom part
        self.drawHorizontalStroke(1, 21, 10, width=6)
        self.drawHorizontalStroke(1, 22.5, 10, width=6)
        self.drawVerticalStroke(2.5, 22.5, 2.8, width=6)
        self.drawVerticalStroke(11, 27, 7.3, width=6)
        self.drawVerticalStroke(2.5, 27, 0.9, width=6)
        self.drawHorizontalStroke(11, 25.2, 8.5, width=6)
        self.drawHorizontalStroke(1, 26.1, 18.5, width=6)
        self.drawHorizontalStroke(3, 25.8, 7.5, width=2)
        self.drawVerticalStroke(12.3, 27, 1.8, width=6)
        self.drawVerticalStroke(15.8, 27, 0.9, width=6)
        self.drawHorizontalStroke(1, 27, 18.5, width=6)

        self.drawText(
            14,
            27.6,
            u"Maksu välitetään saajalle vain Suomessa Kotimaan maksujenvälityksen\nyleisten ehtojen mukaisesti ja vain maksajan ilmoittaman tilinumeron\nperusteella.",
            size=5)
        self.drawText(
            14,
            28.3,
            u"Betalningen förmedlas till mottagare endast i Finland enligt Allmänna\nvillkor för inrikes betalningsförmedling och endast till det\nkontonummer betalaren angivit.",
            size=5)
        self.drawText(17.8, 29.1, u"PANKKI BANKEN", size=6)

        due_date = None
        if self.__type__ != 'reminder':
            due_date = datetime.now() + timedelta(
                days=settings.BILL_DAYS_TO_DUE)
        barcode_string = barcode_4(settings.IBAN_ACCOUNT_NUMBER,
                                   self.data['reference_number'], due_date,
                                   self.data['sum'])
        barcode = code128.Code128(str(barcode_string),
                                  barWidth=0.12 * cm,
                                  barHeight=4.5 * cm)
        barcode.drawOn(self.c, self.real_x(2), self.real_y(28.7))
예제 #5
0
파일: pdf.py 프로젝트: ripesal/sikteeri
    def addTemplate(self):
        # Logo to upper left corner
        self.drawImage(0.2, 0, 5, 2.5, LOGO)
        self.drawString(10.5, 3, u"%(date)s" % self.data, alignment="center", size=12)
        self.drawString(1.5, 3, u"Kapsi Internet-käyttäjät ry, PL 11, 90571 OULU",
                      size=8)
        # Address block
        self.drawText(1.5, 4, u"%(name)s\n%(address)s\n%(postal_code)s %(postal_office)s" % self.data, size=12)
        #self.drawHorizontalStroke()

        self.drawBox(14.5, 3.5, 5, 1.7)
        self.drawTable(14.7, 4, [[u'Jäsennumero:', '%(member_id)s' % self.data],
                              [u'Eräpäivä:', '%(due_date)s' % self.data],
                              [u'Huomautusaika:','%(notify_period)s' % self.data]
                              ], size=10)

        xtable = [1,1.5,7,12,13.5,15,17]
        self.drawString(xtable[1],6.5, u"Selite", size=9)
        self.drawString(xtable[2],6.5, u"Aikaväli", size=9)
        self.drawString(xtable[3],6.5, u"ilman alv", size=9)
        self.drawString(xtable[4],6.5, u"alv", size=9)
        self.drawString(xtable[5],6.5, u"alv osuus", size=9)
        self.drawString(xtable[6],6.5, u"Yhteensä", size=9)
        self.drawHorizontalStroke(1,6.6, 18.5)

        y = 7
        for line in self.data['lineitems']:
            for i in range(len(xtable)):
                self.drawString(xtable[i],y, line[i], size=10)
            y += 0.4

        y -= 0.3
        self.drawHorizontalStroke(1,y, 18.5)
        y += 0.4
        self.drawString(xtable[3],y, u"Maksettavaa yhteensä:" % self.data, size=10)
        self.drawString(xtable[6],y, u"<b>%(pretty_sum)s €</b>" % self.data, size=10)



        self.drawHorizontalStroke(1,18, 18.5)

        self.drawText(1,18.5, u"<b>Kapsi Internet-käyttäjät ry</b>\nPL 11\n90571 Oulu", size=7)
        self.drawText(5.5,18.5, u"Kotipaikka Oulu\nhttps://www.kapsi.fi/", size=7)
        self.drawText(9.5,18.5, u"Sähköposti: %s\nY-tunnus: %s\nYhdistysrekisterinumero: %s" % (get_billing_email(),
            settings.BUSINESS_ID, settings.ORGANIZATION_REG_ID), size=7)
        self.drawText(14,18.5, u"Tilinumero: %s\nBIC: %s" % (group_iban(settings.IBAN_ACCOUNT_NUMBER),
                                                            settings.BIC_CODE), size=7)

        # Bill part

        self.drawString(2.3, 20, u"Saajan", size=6, alignment="right")
        self.drawString(2.3, 20.2, u"tilinumero", size=6, alignment="right")
        self.drawString(2.3, 20.5, u"Mottagarens", size=6, alignment="right")
        self.drawString(2.3, 20.7, u"kontonummer", size=6, alignment="right")

        self.drawText(3.0, 20.6, u"%s   %s   %s" % (settings.BANK_NAME, group_iban(settings.IBAN_ACCOUNT_NUMBER),
                                                   settings.BIC_CODE), size=9)


        self.drawString(2.3, 21.7, u"Saaja", size=6, alignment="right")
        self.drawString(2.3, 22.0, u"Mottagaren", size=6, alignment="right")

        self.drawText(3.0, 21.5, u"Kapsi Internet-käyttäjät ry\nPL 11\n90571 Oulu", size=9)

        self.drawString(2.4, 23, u"Maksajan", size=6, alignment="right")
        self.drawString(2.4, 23.2, u"nimi ja", size=6, alignment="right")
        self.drawString(2.4, 23.4, u"osoite", size=6, alignment="right")
        self.drawString(2.4, 23.7, u"Betalarens", size=6, alignment="right")
        self.drawString(2.4, 23.9, u"namn och", size=6, alignment="right")
        self.drawString(2.4, 24.1, u"adress", size=6, alignment="right")

        self.drawText(3.0, 23.5, u"%(name)s\n%(address)s\n%(postal_code)s %(postal_office)s\n%(email)s" % self.data, size=9)


        self.drawString(2.4, 25.6, u"Allekirjoitus", size=6, alignment="right")
        #self.drawString(2.3, 25.6, u"", size=6, alignment="right")
        self.drawString(2.4, 25.9, u"Ynderskrift", size=6, alignment="right")

        self.drawString(2.3, 26.5, u"Tililtä", size=6, alignment="right")
        self.drawString(2.3, 26.75, u"Från konto nr", size=6, alignment="right")

        self.drawString(3.75, 1.4, u"<b>TILISIIRTO GIRERING</b>", size=8, flip=True)

        self.drawText(3.0,20, u"IBAN", size=7)

        self.drawText(11.15,25.6, u"Viitenro\nRef.nr", size=7)
        self.drawText(13.15,25.7, u"%(reference_number)s" % self.data, size=9)
        self.drawText(11.15,26.5, u"Eräpäivä\nFörf.dag", size=7)
        self.drawText(13.15,26.65, u"%(due_date)s" % self.data, size=9)
        self.drawText(15.9,26.4, u"Euro", size=7)
        self.drawText(16.9,26.65, u"%(pretty_sum)s" % self.data, size=9)




        # Lines on bottom part
        self.drawHorizontalStroke(1,21, 10, width=6)
        self.drawHorizontalStroke(1,22.5, 10, width=6)
        self.drawVerticalStroke(2.5,22.5, 2.8, width=6)
        self.drawVerticalStroke(11,27, 7.3, width=6)
        self.drawVerticalStroke(2.5,27, 0.9, width=6)
        self.drawHorizontalStroke(11,25.2, 8.5, width=6)
        self.drawHorizontalStroke(1,26.1, 18.5, width=6)
        self.drawHorizontalStroke(3,25.8, 7.5, width=2)
        self.drawVerticalStroke(12.3,27, 1.8, width=6)
        self.drawVerticalStroke(15.8,27, 0.9, width=6)
        self.drawHorizontalStroke(1,27, 18.5, width=6)

        self.drawText(14, 27.6, u"Maksu välitetään saajalle vain Suomessa Kotimaan maksujenvälityksen\nyleisten ehtojen mukaisesti ja vain maksajan ilmoittaman tilinumeron\nperusteella.", size=5)
        self.drawText(14, 28.3, u"Betalningen förmedlas till mottagare endast i Finland enligt Allmänna\nvillkor för inrikes betalningsförmedling och endast till det\nkontonummer betalaren angivit.", size=5)
        self.drawText(17.8, 29.1, u"PANKKI BANKEN", size=6)

        due_date = None
        if self.__type__ != 'reminder':
            due_date = datetime.now() + timedelta(days=settings.BILL_DAYS_TO_DUE)
        barcode_string = barcode_4(settings.IBAN_ACCOUNT_NUMBER, self.data['reference_number'], due_date, self.data['sum'])
        barcode = code128.Code128(str(barcode_string), barWidth=0.12*cm, barHeight=4.5*cm)
        barcode.drawOn(self.c, self.real_x(2), self.real_y(28.7))