1b81f7f0614695819140d5b5bc218cb5196c882a
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 In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py       4) 
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py       5) from . import _formatPrice, split_to_width
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py       6) 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   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 5 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 Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      24) def InvoiceToText(invoice: Invoice):
Invoice/InvoiceToText.py      25)     ret = [u'Rechnungsempfänger:',
Invoice/InvoiceToText.py      26)            ]
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      27)     addresslines = filter(None, [
Invoice/InvoiceToText.py      28)         invoice.customer['name'].strip(),
Invoice/InvoiceToText.py      29)         invoice.customer['address']['line1'] or '',
Invoice/InvoiceToText.py      30)         invoice.customer['address']['line2'] or '',
Invoice/InvoiceToText.py      31)         invoice.customer['address']['line3'] or '',
Invoice/InvoiceToText.py      32)         ((invoice.customer['address']['postcode'] or '') + ' ' + (
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      33)                 invoice.customer['address']['city_name'] or '')).strip(),
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      34)     ])
Invoice/InvoiceToText.py      35)     for line in addresslines:
Invoice/InvoiceToText.py      36)         ret.append(f'  {line}')
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  37)     ret.append('')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      38)     ret.append(f'Kundennummer:    {invoice.customerno}')
Bernd Wurst allow for type=None (genera...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      39)     if invoice.id:
Invoice/InvoiceToText.py      40)         ret.append(f'Rechnungsnummer: {invoice.id}')
Invoice/InvoiceToText.py      41)     if invoice.type:
Invoice/InvoiceToText.py      42)         ret.append(f'Rechnungsdatum:  {invoice.date.strftime("%d.%m.%Y")}')
Invoice/InvoiceToText.py      43)     else:
Invoice/InvoiceToText.py      44)         ret.append(f'Datum:           {invoice.date.strftime("%d.%m.%Y")}')
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py  45) 
Bernd Wurst Referenznummern auf allen A...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      46)     if invoice.leitweg_id:
Invoice/InvoiceToText.py      47)         ret.append(f'Leitweg-ID:      {invoice.leitweg_id}')
Invoice/InvoiceToText.py      48)     if invoice.buyer_reference:
Invoice/InvoiceToText.py      49)         ret.append(f'Kunden-Referenz: {invoice.buyer_reference}')
Invoice/InvoiceToText.py      50)     if invoice.contract_number:
Invoice/InvoiceToText.py      51)         ret.append(f'Vertragsnummer:  {invoice.contract_number}')
Invoice/InvoiceToText.py      52)     if invoice.order_number:
Invoice/InvoiceToText.py      53)         ret.append(f'Ihre Bestellnummer: {invoice.order_number}')
Invoice/InvoiceToText.py      54) 
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  55)     ret.append('')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      56)     for part in invoice.parts:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      57)         if isinstance(part, InvoiceTable):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  58)             ret.append(InvoiceTableToText(part))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      59)         elif isinstance(part, InvoiceText):
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  60)             ret.append(InvoiceTextToText(part))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      61)         elif isinstance(part, InvoiceImage):
Bernd Wurst GiroCode auf den Rechnungen

Bernd Wurst authored 7 months ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  64)         else:
src/rechnung/Invoice/text.py  65)             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  66) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  68)         ret.append('-' * 72)
src/rechnung/Invoice/text.py  69)         ret.append('Unsere Bankverbindung:')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      70)         ret.append(f'{invoice.seller_bank_data["bankname"]}')
Invoice/InvoiceToText.py      71)         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  72) 
Bernd Wurst Python-3-anpassungen

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py  74) 
src/rechnung/Invoice/text.py  75) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 12 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  82)         ret.append(u'Anz       Beschreibung                                Preis       Gesamt')
src/rechnung/Invoice/text.py  83)         ret.append(u'-' * 72)
src/rechnung/Invoice/text.py  84) 
src/rechnung/Invoice/text.py  85)     for el in invoiceTable.entries:
Bernd Wurst Zwischenüberschriften in de...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      86)         if el['type'] == 'title':
Invoice/InvoiceToText.py      87)             ret.append('\n'.join(_breakLine(el['title'])))
Invoice/InvoiceToText.py      88)             continue
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  89)         unit = ''
src/rechnung/Invoice/text.py  90)         if el['unit']:
src/rechnung/Invoice/text.py  91)             unit = ' %s' % el['unit']
src/rechnung/Invoice/text.py  92)         if len(invoiceTable.vat) < 2:
src/rechnung/Invoice/text.py  93)             subject = _breakLine(el['subject'], width=39)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      94)             ret.append(u'%5.2f %-3s %-39s  %10s %10s' % (
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py      95)                 el['count'], unit, subject[0], _formatPrice(el['price']), _formatPrice(el['total'])))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py  96)             for i in range(1, len(subject)):
src/rechnung/Invoice/text.py  97)                 ret.append(u'          %s' % subject[i])
src/rechnung/Invoice/text.py  98)         else:
src/rechnung/Invoice/text.py  99)             subject = _breakLine(el['subject'], width=41)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     100)             ret.append(u'%5.2f %-3s %-37s  %10s %s %10s' % (
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     101)                 el['count'], unit, subject[0], _formatPrice(el['price']), invoiceTable.vat[el['vat']][1],
Invoice/InvoiceToText.py     102)                 _formatPrice(el['total'])))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 103)             for i in range(1, len(subject)):
src/rechnung/Invoice/text.py 104)                 ret.append(u'          %s' % subject[i])
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     105)         if 'period_start' in el and el['period_start']:
Invoice/InvoiceToText.py     106)             if 'period_end' in el and el['period_end']:
Invoice/InvoiceToText.py     107)                 desc = _breakLine('(%s - %s)' %
Invoice/InvoiceToText.py     108)                                                (el['period_start'].strftime('%d.%m.%Y'),
Invoice/InvoiceToText.py     109)                                                 el['period_end'].strftime('%d.%m.%Y')))
Invoice/InvoiceToText.py     110)             else:
Invoice/InvoiceToText.py     111)                 desc = _breakLine('Leistungsdatum: %s' %
Invoice/InvoiceToText.py     112)                                                (el['period_start'].strftime('%d.%m.%Y')))
Invoice/InvoiceToText.py     113)             for line in desc:
Invoice/InvoiceToText.py     114)                 ret.append(u'          %s' % line)
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 115)         if 'desc' in el and el['desc']:
src/rechnung/Invoice/text.py 116)             desc = _breakLine(el['desc'], 39)
src/rechnung/Invoice/text.py 117)             for line in desc:
src/rechnung/Invoice/text.py 118)                 ret.append(u'          %s' % line)
src/rechnung/Invoice/text.py 119)     ret.append('-' * 72)
src/rechnung/Invoice/text.py 120)     if invoiceTable.vatType == 'gross':
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     121)         ret.append((u'Rechnungsbetrag:  %11s' % _formatPrice(invoiceTable.sum)).rjust(72))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 122)         ret.append('')
src/rechnung/Invoice/text.py 123)         summaries = []
src/rechnung/Invoice/text.py 124)         if len(invoiceTable.vat) == 1:
src/rechnung/Invoice/text.py 125)             vat = list(invoiceTable.vat.keys())[0]
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     126)             summaries.append(u'      Im Rechnungsbetrag sind %.1f%% MwSt enthalten (%s)' % (
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     127)                 vat * 100, _formatPrice((invoiceTable.sum / (vat + 1)) * vat)))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 128)         else:
Bernd Wurst Python-3-Migration

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 129)             for vat, vatdata in list(invoiceTable.vat.items()):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     130)                 summaries.append(u'    %s: Im Teilbetrag von %s sind %.1f%% MwSt enthalten (%s)' % (
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     131)                     vatdata[1], _formatPrice(vatdata[0]), vat * 100, _formatPrice((vatdata[0] / (vat + 1)) * vat)))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 132)         summaries.sort()
src/rechnung/Invoice/text.py 133)         for line in summaries:
src/rechnung/Invoice/text.py 134)             ret.append(line)
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py 135)     else:
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     136)         ret.append((u'Nettobetrag: %11s' % _formatPrice(invoiceTable.sum)).rjust(72))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 137)         summaries = []
src/rechnung/Invoice/text.py 138)         if len(invoiceTable.vat) == 1:
src/rechnung/Invoice/text.py 139)             vat = list(invoiceTable.vat.keys())[0]
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     140)             summaries.append((u'zzgl. %.1f%% MwSt: %11s' % (vat * 100, _formatPrice(vat * invoiceTable.sum))).rjust(72))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 141)         elif len(invoiceTable.vat) > 1:
Bernd Wurst Python-3-Migration

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 142)             for vat, vatdata in list(invoiceTable.vat.items()):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     143)                 summaries.append(
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     144)                     (u'zzgl. %4.1f%% MwSt (%s): %11s' % (vat * 100, vatdata[1], _formatPrice(vat * vatdata[0]))).rjust(
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     145)                         72))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 146)         summaries.sort()
src/rechnung/Invoice/text.py 147)         for line in summaries:
src/rechnung/Invoice/text.py 148)             ret.append(line)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     149)         tablesum = invoiceTable.sum
Bernd Wurst Python-3-Migration

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 150)         for vat, vatdata in list(invoiceTable.vat.items()):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     151)             tablesum += vat * vatdata[0]
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     152)         ret.append((u'Rechnungsbetrag: %11s' % _formatPrice(tablesum)).rjust(72))
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 153)     ret.append('')
Bernd Wurst Python-3-anpassungen

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 16 years ago

src/rechnung/Invoice/text.py 155) 
src/rechnung/Invoice/text.py 156) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

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

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 158)     ret = []
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     159)     if invoiceText.headline:
Invoice/InvoiceToText.py     160)         for line in split_to_width(invoiceText.headline, 72):
Invoice/InvoiceToText.py     161)             ret.append(line)
Invoice/InvoiceToText.py     162)     indent = 0
Invoice/InvoiceToText.py     163)     if invoiceText.indent:
Invoice/InvoiceToText.py     164)         if isinstance(invoiceText.indent, bool):
Invoice/InvoiceToText.py     165)             indent = 2
Invoice/InvoiceToText.py     166)         else:
Invoice/InvoiceToText.py     167)             indent = invoiceText.indent
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

src/rechnung/Invoice/text.py 168)     for par in invoiceText.paragraphs:
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

Invoice/InvoiceToText.py     169)         for s in split_to_width(par, 72 - indent):
Invoice/InvoiceToText.py     170)             ret.append(' ' * indent + s)
Bernd Wurst automatische code-style-fixes

Bernd Wurst authored 5 years ago

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