25674c26838edf0a577e53f168789aa3ec6f7fb3
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 5 years ago

src/rechnung/Invoice/text.py   3) from __future__ import division
Bernd Wurst GiroCode auf den Rechnungen

Bernd Wurst authored 7 months ago

src/rechnung/Invoice/text.py   4) from Invoice import Text, Table, Image
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  23) def InvoiceToText(iv, bankdata=True):
src/rechnung/Invoice/text.py  24)     ret = []
src/rechnung/Invoice/text.py  25)     ret.append(u'Rechnungsempfänger:')
src/rechnung/Invoice/text.py  26)     for line in iv.addresslines:
src/rechnung/Invoice/text.py  27)         ret.append('  %s' % line)
src/rechnung/Invoice/text.py  28)     ret.append('')
src/rechnung/Invoice/text.py  29)     ret.append('Kundennummer:    %4i' % iv.customerno)
src/rechnung/Invoice/text.py  30)     ret.append('Rechnungsnummer: %4i    Rechnungsdatum:  %s' % (iv.id, iv.date.strftime('%d.%m.%Y')))
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  32)     ret.append('')
src/rechnung/Invoice/text.py  33)     for part in iv.parts:
src/rechnung/Invoice/text.py  34)         if type(part) == Table:
src/rechnung/Invoice/text.py  35)             ret.append(InvoiceTableToText(part))
src/rechnung/Invoice/text.py  36)         elif type(part) == Text:
src/rechnung/Invoice/text.py  37)             ret.append(InvoiceTextToText(part))
Bernd Wurst GiroCode auf den Rechnungen

Bernd Wurst authored 7 months ago

src/rechnung/Invoice/text.py  38)         elif type(part) == Image:
src/rechnung/Invoice/text.py  39)             # ignore images
src/rechnung/Invoice/text.py  40)             pass
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  41)         else:
src/rechnung/Invoice/text.py  42)             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  43) 
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  44)     if bankdata:
src/rechnung/Invoice/text.py  45)         ret.append('-' * 72)
src/rechnung/Invoice/text.py  46)         ret.append('Unsere Bankverbindung:')
src/rechnung/Invoice/text.py  47)         ret.append('Volksbank Backnang, BLZ 602 911 20, Konto-Nr. 41512 006')
src/rechnung/Invoice/text.py  48)         ret.append('IBAN: DE91602911200041512006, BIC: GENODES1VBK')
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py  51) 
src/rechnung/Invoice/text.py  52) 
src/rechnung/Invoice/text.py  53) def InvoiceTableToText(invoiceTable):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 12 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  59)         ret.append(u'Anz       Beschreibung                                Preis       Gesamt')
src/rechnung/Invoice/text.py  60)         ret.append(u'-' * 72)
src/rechnung/Invoice/text.py  61) 
src/rechnung/Invoice/text.py  62)     for el in invoiceTable.entries:
src/rechnung/Invoice/text.py  63)         unit = ''
src/rechnung/Invoice/text.py  64)         if el['unit']:
src/rechnung/Invoice/text.py  65)             unit = ' %s' % el['unit']
src/rechnung/Invoice/text.py  66)         if len(invoiceTable.vat) < 2:
src/rechnung/Invoice/text.py  67)             subject = _breakLine(el['subject'], width=39)
src/rechnung/Invoice/text.py  68)             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  69)             for i in range(1, len(subject)):
src/rechnung/Invoice/text.py  70)                 ret.append(u'          %s' % subject[i])
src/rechnung/Invoice/text.py  71)         else:
src/rechnung/Invoice/text.py  72)             subject = _breakLine(el['subject'], width=41)
src/rechnung/Invoice/text.py  73)             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  74)             for i in range(1, len(subject)):
src/rechnung/Invoice/text.py  75)                 ret.append(u'          %s' % subject[i])
src/rechnung/Invoice/text.py  76)         if 'desc' in el and el['desc']:
src/rechnung/Invoice/text.py  77)             desc = _breakLine(el['desc'], 39)
src/rechnung/Invoice/text.py  78)             for line in desc:
src/rechnung/Invoice/text.py  79)                 ret.append(u'          %s' % line)
src/rechnung/Invoice/text.py  80)     ret.append('-' * 72)
src/rechnung/Invoice/text.py  81)     if invoiceTable.vatType == 'gross':
src/rechnung/Invoice/text.py  82)         ret.append((u'Rechnungsbetrag:  %11s' % format_price(invoiceTable.sum)).rjust(72))
src/rechnung/Invoice/text.py  83)         ret.append('')
src/rechnung/Invoice/text.py  84)         summaries = []
src/rechnung/Invoice/text.py  85)         if len(invoiceTable.vat) == 1:
src/rechnung/Invoice/text.py  86)             vat = list(invoiceTable.vat.keys())[0]
src/rechnung/Invoice/text.py  87)             summaries.append(u'      Im Rechnungsbetrag sind %.1f%% MwSt enthalten (%s)' % (vat * 100, format_price((invoiceTable.sum / (vat + 1)) * vat)))
src/rechnung/Invoice/text.py  88)         else:
Bernd Wurst Python-3-Migration

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  90)                 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  91)         summaries.sort()
src/rechnung/Invoice/text.py  92)         for line in summaries:
src/rechnung/Invoice/text.py  93)             ret.append(line)
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 102)                 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 103)         summaries.sort()
src/rechnung/Invoice/text.py 104)         for line in summaries:
src/rechnung/Invoice/text.py 105)             ret.append(line)
src/rechnung/Invoice/text.py 106)         sum = invoiceTable.sum
Bernd Wurst Python-3-Migration

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py 112) 
src/rechnung/Invoice/text.py 113) 
src/rechnung/Invoice/text.py 114) def InvoiceTextToText(invoiceText):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 5 years ago

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