b6f819fa1ff5f5f4832dcbb82688f6548584c444
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py            1) # -* coding: utf8 *-
src/rechnung/Invoice/text.py            2) 
Bernd Wurst Python-3-Migration

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py            3) from __future__ import division
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py   4) 
src/rechnung/Invoice/InvoiceToText.py   5) from .InvoiceObjects import Invoice, InvoiceTable, InvoiceText, InvoiceImage, PAYMENT_UEBERWEISUNG
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py            6) from utils import format_price, split_to_width
src/rechnung/Invoice/text.py            7) 
src/rechnung/Invoice/text.py            8) 
src/rechnung/Invoice/text.py            9) def _breakLine(text, width=72):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           10)     lines = []
src/rechnung/Invoice/text.py           11)     paras = text.split('\n')
src/rechnung/Invoice/text.py           12)     for para in paras:
src/rechnung/Invoice/text.py           13)         words = para.split(' ')
src/rechnung/Invoice/text.py           14)         while len(words) > 0:
src/rechnung/Invoice/text.py           15)             mywords = [words[0], ]
src/rechnung/Invoice/text.py           16)             del words[0]
src/rechnung/Invoice/text.py           17)             while len(words) > 0 and len(u' '.join(mywords) + ' ' + words[0]) <= width:
src/rechnung/Invoice/text.py           18)                 mywords.append(words[0])
src/rechnung/Invoice/text.py           19)                 del words[0]
src/rechnung/Invoice/text.py           20)             lines.append(' '.join(mywords))
src/rechnung/Invoice/text.py           21)     return lines
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py           22) 
src/rechnung/Invoice/text.py           23) 
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  24) def InvoiceToText(invoice : Invoice, bankdata=True):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           25)     ret = []
src/rechnung/Invoice/text.py           26)     ret.append(u'Rechnungsempfänger:')
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  27)     addresslines = filter(None, [
src/rechnung/Invoice/InvoiceToText.py  28)         invoice.customer['name'].strip(),
src/rechnung/Invoice/InvoiceToText.py  29)         invoice.customer['address']['line1'] or '',
src/rechnung/Invoice/InvoiceToText.py  30)         invoice.customer['address']['line2'] or '',
src/rechnung/Invoice/InvoiceToText.py  31)         invoice.customer['address']['line3'] or '',
src/rechnung/Invoice/InvoiceToText.py  32)         ((invoice.customer['address']['postcode'] or '') + ' ' + (
src/rechnung/Invoice/InvoiceToText.py  33)                     invoice.customer['address']['city_name'] or '')).strip(),
src/rechnung/Invoice/InvoiceToText.py  34)     ])
src/rechnung/Invoice/InvoiceToText.py  35)     for line in addresslines:
src/rechnung/Invoice/InvoiceToText.py  36)         ret.append(f'  {line}')
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           37)     ret.append('')
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  38)     ret.append(f'Kundennummer:    {invoice.customerno}')
src/rechnung/Invoice/InvoiceToText.py  39)     ret.append(f'Rechnungsnummer: {invoice.id}')
src/rechnung/Invoice/InvoiceToText.py  40)     ret.append(f'Rechnungsdatum:  {invoice.date.strftime("%d.%m.%Y")}')
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py           41) 
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           42)     ret.append('')
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  43)     for part in invoice.parts:
src/rechnung/Invoice/InvoiceToText.py  44)         if type(part) == InvoiceTable:
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           45)             ret.append(InvoiceTableToText(part))
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  46)         elif type(part) == InvoiceText:
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           47)             ret.append(InvoiceTextToText(part))
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  48)         elif type(part) == InvoiceImage:
Bernd Wurst GiroCode auf den Rechnungen

Bernd Wurst authored 10 months ago

src/rechnung/Invoice/text.py           49)             # ignore images
src/rechnung/Invoice/text.py           50)             pass
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           51)         else:
src/rechnung/Invoice/text.py           52)             raise NotImplementedError("Cannot handle part of type %s" % type(part))
Bernd Wurst Verstecke Bankdaten bei Rec...

Bernd Wurst authored 7 years ago

src/rechnung/Invoice/text.py           53) 
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  54)     if invoice.payment_type == PAYMENT_UEBERWEISUNG:
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           55)         ret.append('-' * 72)
src/rechnung/Invoice/text.py           56)         ret.append('Unsere Bankverbindung:')
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  57)         ret.append(f'{invoice.seller_bank_data["bankname"]}')
src/rechnung/Invoice/InvoiceToText.py  58)         ret.append(f'IBAN: {invoice.seller_bank_data["iban"]}')
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py           59) 
Bernd Wurst Python-3-anpassungen

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           60)     return '\n'.join(ret)
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py           61) 
src/rechnung/Invoice/text.py           62) 
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py  63) def InvoiceTableToText(invoiceTable : InvoiceTable):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           64)     ret = []
Bernd Wurst Innergemeinschaftliche Leis...

Bernd Wurst authored 13 years ago

src/rechnung/Invoice/text.py           65)     if len(invoiceTable.vat) < 2:
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           66)         ret.append(u'Anz       Beschreibung                                  Preis     Gesamt')
src/rechnung/Invoice/text.py           67)         ret.append(u'-' * 72)
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py           68)     else:
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           69)         ret.append(u'Anz       Beschreibung                                Preis       Gesamt')
src/rechnung/Invoice/text.py           70)         ret.append(u'-' * 72)
src/rechnung/Invoice/text.py           71) 
src/rechnung/Invoice/text.py           72)     for el in invoiceTable.entries:
src/rechnung/Invoice/text.py           73)         unit = ''
src/rechnung/Invoice/text.py           74)         if el['unit']:
src/rechnung/Invoice/text.py           75)             unit = ' %s' % el['unit']
src/rechnung/Invoice/text.py           76)         if len(invoiceTable.vat) < 2:
src/rechnung/Invoice/text.py           77)             subject = _breakLine(el['subject'], width=39)
src/rechnung/Invoice/text.py           78)             ret.append(u'%5.2f %-3s %-39s  %10s %10s' % (el['count'], unit, subject[0], format_price(el['price']), format_price(el['total'])))
src/rechnung/Invoice/text.py           79)             for i in range(1, len(subject)):
src/rechnung/Invoice/text.py           80)                 ret.append(u'          %s' % subject[i])
src/rechnung/Invoice/text.py           81)         else:
src/rechnung/Invoice/text.py           82)             subject = _breakLine(el['subject'], width=41)
src/rechnung/Invoice/text.py           83)             ret.append(u'%5.2f %-3s %-37s  %10s %s %10s' % (el['count'], unit, subject[0], format_price(el['price']), invoiceTable.vat[el['vat']][1], format_price(el['total'])))
src/rechnung/Invoice/text.py           84)             for i in range(1, len(subject)):
src/rechnung/Invoice/text.py           85)                 ret.append(u'          %s' % subject[i])
src/rechnung/Invoice/text.py           86)         if 'desc' in el and el['desc']:
src/rechnung/Invoice/text.py           87)             desc = _breakLine(el['desc'], 39)
src/rechnung/Invoice/text.py           88)             for line in desc:
src/rechnung/Invoice/text.py           89)                 ret.append(u'          %s' % line)
src/rechnung/Invoice/text.py           90)     ret.append('-' * 72)
src/rechnung/Invoice/text.py           91)     if invoiceTable.vatType == 'gross':
src/rechnung/Invoice/text.py           92)         ret.append((u'Rechnungsbetrag:  %11s' % format_price(invoiceTable.sum)).rjust(72))
src/rechnung/Invoice/text.py           93)         ret.append('')
src/rechnung/Invoice/text.py           94)         summaries = []
src/rechnung/Invoice/text.py           95)         if len(invoiceTable.vat) == 1:
src/rechnung/Invoice/text.py           96)             vat = list(invoiceTable.vat.keys())[0]
src/rechnung/Invoice/text.py           97)             summaries.append(u'      Im Rechnungsbetrag sind %.1f%% MwSt enthalten (%s)' % (vat * 100, format_price((invoiceTable.sum / (vat + 1)) * vat)))
src/rechnung/Invoice/text.py           98)         else:
Bernd Wurst Python-3-Migration

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py           99)             for vat, vatdata in list(invoiceTable.vat.items()):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          100)                 summaries.append(u'    %s: Im Teilbetrag von %s sind %.1f%% MwSt enthalten (%s)' % (vatdata[1], format_price(vatdata[0]), vat * 100, format_price((vatdata[0] / (vat + 1)) * vat)))
src/rechnung/Invoice/text.py          101)         summaries.sort()
src/rechnung/Invoice/text.py          102)         for line in summaries:
src/rechnung/Invoice/text.py          103)             ret.append(line)
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py          104)     else:
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          105)         ret.append((u'Nettobetrag: %11s' % format_price(invoiceTable.sum)).rjust(72))
src/rechnung/Invoice/text.py          106)         summaries = []
src/rechnung/Invoice/text.py          107)         if len(invoiceTable.vat) == 1:
src/rechnung/Invoice/text.py          108)             vat = list(invoiceTable.vat.keys())[0]
src/rechnung/Invoice/text.py          109)             summaries.append((u'zzgl. %.1f%% MwSt: %11s' % (vat * 100, format_price(vat * invoiceTable.sum))).rjust(72))
src/rechnung/Invoice/text.py          110)         elif len(invoiceTable.vat) > 1:
Bernd Wurst Python-3-Migration

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          111)             for vat, vatdata in list(invoiceTable.vat.items()):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          112)                 summaries.append((u'zzgl. %4.1f%% MwSt (%s): %11s' % (vat * 100, vatdata[1], format_price(vat * vatdata[0]))).rjust(72))
src/rechnung/Invoice/text.py          113)         summaries.sort()
src/rechnung/Invoice/text.py          114)         for line in summaries:
src/rechnung/Invoice/text.py          115)             ret.append(line)
src/rechnung/Invoice/text.py          116)         sum = invoiceTable.sum
Bernd Wurst Python-3-Migration

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          117)         for vat, vatdata in list(invoiceTable.vat.items()):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          118)             sum += vat * vatdata[0]
src/rechnung/Invoice/text.py          119)         ret.append((u'Rechnungsbetrag: %11s' % format_price(sum)).rjust(72))
src/rechnung/Invoice/text.py          120)     ret.append('')
Bernd Wurst Python-3-anpassungen

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          121)     return '\n'.join(ret)
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py          122) 
src/rechnung/Invoice/text.py          123) 
Bernd Wurst WiP

Bernd Wurst authored 8 months ago

src/rechnung/Invoice/InvoiceToText.py 124) def InvoiceTextToText(invoiceText : InvoiceText):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          125)     ret = []
src/rechnung/Invoice/text.py          126)     for par in invoiceText.paragraphs:
Bernd Wurst Python-3-anpassungen

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          127)         for s in split_to_width(par, 72):
src/rechnung/Invoice/text.py          128)             ret.append(s)
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 6 years ago

src/rechnung/Invoice/text.py          129)         ret.append('')