ea094b035c2cf728d4659501b60dd37ddfbf0206
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

1) # -* coding: utf8 *-
2) 
Bernd Wurst Umbenannt aber wieder in ko...

Bernd Wurst authored 16 years ago

3) from Invoice import Text, Table
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

4) from utils import format_price, split_to_width
5) 
6) 
7) 
8) def _breakLine(text, width=72):
9)   lines = []
10)   paras = text.split('\n')
11)   for para in paras:
12)     words = para.split(' ')
13)     while len(words) > 0:
14)       mywords = [words[0], ]
15)       del words[0]
16)       while len(words) > 0 and len(u' '.join(mywords) + ' ' + words[0]) <= width:
17)         mywords.append(words[0])
18)         del words[0]
19)       lines.append(' '.join(mywords))
20)   return lines
21)   
22) 
23) def InvoiceToText(iv):
24)   ret = []
25)   ret.append(u'Rechnungsempfänger:')
26)   for line in iv.addresslines:
27)     ret.append('  %s' % line)
28)   ret.append('')
29)   ret.append('Kundennummer:    %4i' % iv.customerno)
30)   ret.append('Rechnungsnummer: %4i    Rechnungsdatum:  %s' % (iv.id, iv.date.strftime('%d.%m.%Y')))
31) 
32)   ret.append('')
33)   for part in iv.parts:
Bernd Wurst Umbenannt aber wieder in ko...

Bernd Wurst authored 16 years ago

34)     if type(part) == Table:
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

35)       ret.append(InvoiceTableToText(part))
Bernd Wurst Umbenannt aber wieder in ko...

Bernd Wurst authored 16 years ago

36)     elif type(part) == Text:
Bernd Wurst Struktur verändern (broken!)

Bernd Wurst authored 16 years ago

37)       ret.append(InvoiceTextToText(part))
38)     else:
39)       raise NotImplementedError("Cannot handle part of type %s" % type(part))
40) 
41) 
42)   ret.append('-'*72)
43)   ret.append('Unsere Bankverbindung:')
Bernd Wurst Neue Bankverbindung

Bernd Wurst authored 14 years ago

44)   ret.append('Volksbank Backnang, BLZ 602 911 20, Konto-Nr. 41512 006')
45)   ret.append('IBAN: DE91602911200041512006, BIC: GENODES1VBK')