Bernd Wurst commited on 2011-07-12 08:42:43
Zeige 3 geänderte Dateien mit 11 Einfügungen und 9 Löschungen.
... | ... |
@@ -48,10 +48,12 @@ class Table(object): |
48 | 48 |
'''Fügt eine Zeile ein. data muss ein Dict mit passenden Keys und passenden |
49 | 49 |
Typen sein''' |
50 | 50 |
d = self.validEntry(data) |
51 |
+ if d['vat'] != 0: |
|
51 | 52 |
if not d['vat'] in self.vat.keys(): |
52 | 53 |
self.vat[d['vat']] = [0, chr(65+len(self.vat))] |
53 | 54 |
if 'tender' not in data or not data['tender']: |
54 | 55 |
self.vat[d['vat']][0] += d['total'] |
56 |
+ if 'tender' not in data or not data['tender']: |
|
55 | 57 |
self.sum += d['total'] |
56 | 58 |
self.entries.append(d) |
57 | 59 |
|
... | ... |
@@ -284,7 +284,7 @@ def InvoiceToPDF(iv): |
284 | 284 |
canvas.drawRightString(left+0.8*cm, y-font_height, integer) |
285 | 285 |
if decimals: |
286 | 286 |
canvas.drawString(left+0.8*cm, y-font_height, ',%s' % decimals) |
287 |
- if len(part.vat) == 1: |
|
287 |
+ if len(part.vat) < 2: |
|
288 | 288 |
canvas.drawString(left+1.7*cm, y-font_height, subject[0]) |
289 | 289 |
canvas.drawRightString(left+14.3*cm, y-font_height, _formatPrice(el['price'])) |
290 | 290 |
if el['tender']: |
... | ... |
@@ -365,7 +365,7 @@ def InvoiceToPDF(iv): |
365 | 365 |
if decimals: |
366 | 366 |
vatstr += ',%s' % decimals |
367 | 367 |
summaries.append(('zzgl. %s%% MwSt:' % vatstr, _formatPrice(vat*part.sum))) |
368 |
- else: |
|
368 |
+ elif len(part.vat) > 1: |
|
369 | 369 |
for vat, vatdata in part.vat.iteritems(): |
370 | 370 |
(integer, decimals) = _niceCount( (vat * 100) ) |
371 | 371 |
vatstr = '%s' % integer |
... | ... |
@@ -377,9 +377,9 @@ def InvoiceToPDF(iv): |
377 | 377 |
canvas.drawRightString(left + 14.5*cm, y-font_height, line[0]) |
378 | 378 |
canvas.drawRightString(left + 16.8*cm, y-font_height, line[1]) |
379 | 379 |
y -= line_height |
380 |
- sum = 0 |
|
380 |
+ sum = part.sum |
|
381 | 381 |
for vat, vatdata in part.vat.iteritems(): |
382 |
- sum += (vat+1)*vatdata[0] |
|
382 |
+ sum += vat*vatdata[0] |
|
383 | 383 |
canvas.setFont(font+'-Bold', font_size) |
384 | 384 |
if iv.tender: |
385 | 385 |
canvas.drawRightString(left + 14.5*cm, y-font_height, 'Gesamtbetrag:') |
... | ... |
@@ -49,7 +49,7 @@ def InvoiceToText(iv): |
49 | 49 |
|
50 | 50 |
def InvoiceTableToText(invoiceTable): |
51 | 51 |
ret = [] |
52 |
- if len(invoiceTable.vat) == 1: |
|
52 |
+ if len(invoiceTable.vat) < 2: |
|
53 | 53 |
ret.append(u'Anz Beschreibung Preis Gesamt') |
54 | 54 |
ret.append(u'-'*72) |
55 | 55 |
else: |
... | ... |
@@ -57,7 +57,7 @@ def InvoiceTableToText(invoiceTable): |
57 | 57 |
ret.append(u'-'*72) |
58 | 58 |
|
59 | 59 |
for el in invoiceTable.entries: |
60 |
- if len(invoiceTable.vat) == 1: |
|
60 |
+ if len(invoiceTable.vat) < 2: |
|
61 | 61 |
subject = _breakLine(el['subject'], width=43) |
62 | 62 |
ret.append(u'%5.2f %-43s %10s %10s' % (el['count'], subject[0], format_price(el['price']), format_price(el['total']))) |
63 | 63 |
for i in range(1,len(subject)): |
... | ... |
@@ -91,15 +91,15 @@ def InvoiceTableToText(invoiceTable): |
91 | 91 |
if len(invoiceTable.vat) == 1: |
92 | 92 |
vat = invoiceTable.vat.keys()[0] |
93 | 93 |
summaries.append((u'zzgl. %.1f%% MwSt: %11s' % (vat*100, format_price(vat*invoiceTable.sum))).rjust(72)) |
94 |
- else: |
|
94 |
+ elif len(invoiceTable.vat) > 1: |
|
95 | 95 |
for vat, vatdata in invoiceTable.vat.iteritems(): |
96 | 96 |
summaries.append((u'zzgl. %4.1f%% MwSt (%s): %11s' % (vat*100, vatdata[1], format_price(vat*vatdata[0]))).rjust(72)) |
97 | 97 |
summaries.sort() |
98 | 98 |
for line in summaries: |
99 | 99 |
ret.append(line) |
100 |
- sum = 0 |
|
100 |
+ sum = invoiceTable.sum |
|
101 | 101 |
for vat, vatdata in invoiceTable.vat.iteritems(): |
102 |
- sum += (vat+1)*vatdata[0] |
|
102 |
+ sum += vat*vatdata[0] |
|
103 | 103 |
ret.append((u'Rechnungsbetrag: %11s' % format_price(sum)).rjust(72)) |
104 | 104 |
ret.append('') |
105 | 105 |
return ('\n'.join(ret)).encode('utf-8') |
106 | 106 |