Bernd Wurst commited on 2018-07-05 23:01:26
Zeige 4 geänderte Dateien mit 25 Einfügungen und 22 Löschungen.
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
import datetime |
4 | 4 |
|
5 | 5 |
|
6 |
-class Text(object): |
|
6 |
+class Text: |
|
7 | 7 |
def __init__(self, content, urgent=False, headline=None): |
8 | 8 |
self.paragraphs = [content] |
9 | 9 |
self.urgent = urgent |
... | ... |
@@ -13,7 +13,7 @@ class Text(object): |
13 | 13 |
self.paragraphs.append(content) |
14 | 14 |
|
15 | 15 |
|
16 |
-class Table(object): |
|
16 |
+class Table: |
|
17 | 17 |
def __init__(self, vatType='gross', tender=False, summary=True): |
18 | 18 |
self.entries = [] |
19 | 19 |
self.vat = {} |
... | ... |
@@ -61,7 +61,7 @@ class Table(object): |
61 | 61 |
self.entries.append(d) |
62 | 62 |
|
63 | 63 |
|
64 |
-class Invoice(object): |
|
64 |
+class Invoice: |
|
65 | 65 |
tender = False |
66 | 66 |
caption = 'Rechnung' |
67 | 67 |
|
... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
# -* coding: utf8 *- |
2 |
+from __future__ import division |
|
2 | 3 |
from .metrics import * |
3 | 4 |
|
4 | 5 |
|
... | ... |
@@ -24,15 +25,15 @@ def Footer(canvas): |
24 | 25 |
canvas.drawString(leftcontent, bottomcontent - 30, 'www.schokokeks.org') |
25 | 26 |
canvas.drawString(leftcontent, bottomcontent - 40, 'root@schokokeks.org') |
26 | 27 |
|
27 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3), bottomcontent - 10, 'Steuernummer 51072/01109') |
|
28 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3), bottomcontent - 20, 'Finanzamt Backnang') |
|
29 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3), bottomcontent - 30, 'USt-ID: DE255720588') |
|
28 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3), bottomcontent - 10, 'Steuernummer 51072/01109') |
|
29 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3), bottomcontent - 20, 'Finanzamt Backnang') |
|
30 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3), bottomcontent - 30, 'USt-ID: DE255720588') |
|
30 | 31 |
|
31 | 32 |
canvas.setFont(font, 7) |
32 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3) * 2, bottomcontent - 10, 'Volksbank Backnang') |
|
33 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3) * 2, bottomcontent - 20, 'IBAN: DE91 6029 1120 0041 5120 06') |
|
34 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3) * 2, bottomcontent - 30, 'BIC: GENODES1VBK') |
|
35 |
- canvas.drawString(leftcontent + ((rightcontent - leftcontent) / 3) * 2, bottomcontent - 40, '(Kto: 41512 006 / BLZ: 602 911 20)') |
|
33 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3) * 2, bottomcontent - 10, 'Volksbank Backnang') |
|
34 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3) * 2, bottomcontent - 20, 'IBAN: DE91 6029 1120 0041 5120 06') |
|
35 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3) * 2, bottomcontent - 30, 'BIC: GENODES1VBK') |
|
36 |
+ canvas.drawString(leftcontent + ((rightcontent - leftcontent) // 3) * 2, bottomcontent - 40, '(Kto: 41512 006 / BLZ: 602 911 20)') |
|
36 | 37 |
|
37 | 38 |
|
38 | 39 |
def basicPage(canvas): |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
# -* coding: utf8 *- |
2 | 2 |
|
3 |
+from __future__ import division |
|
3 | 4 |
import Invoice |
4 | 5 |
import re |
5 | 6 |
|
... | ... |
@@ -74,7 +75,7 @@ def _drawJustifiedString(x, y, text, canvas, width, font, size): |
74 | 75 |
words_width += canvas.stringWidth(word, font, size) |
75 | 76 |
|
76 | 77 |
available_space = width - words_width |
77 |
- available_each = available_space / float((len(words) - 1)) |
|
78 |
+ available_each = available_space // float((len(words) - 1)) |
|
78 | 79 |
|
79 | 80 |
my_x = x |
80 | 81 |
for idx in range(len(words)): |
... | ... |
@@ -120,7 +121,7 @@ def address(canvas, lines): |
120 | 121 |
|
121 | 122 |
def InvoiceToPDF(iv, bankdata=True): |
122 | 123 |
try: |
123 |
- from StringIO import StringIO |
|
124 |
+ from io import StringIO |
|
124 | 125 |
except ImportError: |
125 | 126 |
from io import StringIO |
126 | 127 |
fd = StringIO() |
... | ... |
@@ -200,7 +201,7 @@ def InvoiceToPDF(iv, bankdata=True): |
200 | 201 |
y = topcontent - font_size |
201 | 202 |
canvas.setFillColor((0, 0, 0)) |
202 | 203 |
canvas.setFont(font, font_size - 2) |
203 |
- canvas.drawCentredString(leftcontent + (rightcontent - leftcontent) / 2, y, '- Seite %i -' % num_pages) |
|
204 |
+ canvas.drawCentredString(leftcontent + (rightcontent - leftcontent) // 2, y, '- Seite %i -' % num_pages) |
|
204 | 205 |
|
205 | 206 |
address(canvas, iv.addresslines) |
206 | 207 |
|
... | ... |
@@ -209,10 +210,10 @@ def InvoiceToPDF(iv, bankdata=True): |
209 | 210 |
if not bankdata: |
210 | 211 |
# Bankdaten überschreiben wenn Lastschrift |
211 | 212 |
canvas.setFillColor(Color(255, 255, 255, alpha=0.8)) |
212 |
- canvas.rect(leftcontent + ((rightcontent - leftcontent) / 3) * 2 - 2, bottomcontent - 2, (rightcontent - leftcontent) / 3, -40, fill=True, stroke=False) |
|
213 |
+ canvas.rect(leftcontent + ((rightcontent - leftcontent) // 3) * 2 - 2, bottomcontent - 2, (rightcontent - leftcontent) // 3, -40, fill=True, stroke=False) |
|
213 | 214 |
canvas.setFillColor(Color(0, 0, 0, alpha=1)) |
214 | 215 |
canvas.saveState() |
215 |
- canvas.translate(leftcontent + ((rightcontent - leftcontent) / 3) * 2 + 2, bottomcontent - 40) |
|
216 |
+ canvas.translate(leftcontent + ((rightcontent - leftcontent) // 3) * 2 + 2, bottomcontent - 40) |
|
216 | 217 |
canvas.rotate(15) |
217 | 218 |
canvas.drawString(0, 0, "Bitte nicht überweisen") |
218 | 219 |
canvas.restoreState() |
... | ... |
@@ -382,12 +383,12 @@ def InvoiceToPDF(iv, bankdata=True): |
382 | 383 |
summaries.append(('%s%% MwSt:' % vatstr, _formatPrice((part.sum / (vat + 1)) * vat))) |
383 | 384 |
else: |
384 | 385 |
net = 0.0 |
385 |
- for vat, vatdata in part.vat.items(): |
|
386 |
+ for vat, vatdata in list(part.vat.items()): |
|
386 | 387 |
(integer, decimals) = _niceCount((vat * 100)) |
387 | 388 |
vatstr = '%s' % integer |
388 | 389 |
if decimals: |
389 | 390 |
vatstr += ',%s' % decimals |
390 |
- summaries.append(('%s: Teilbetrag %s zzgl. %s%% MwSt:' % (vatdata[1], _formatPrice(vatdata[0]), vatstr), _formatPrice((vatdata[0] / (vat + 1)) * vat))) |
|
391 |
+ summaries.append(('%s: Teilbetrag %s zzgl. %s%% MwSt:' % (vatdata[1], _formatPrice(vatdata[0]), vatstr), _formatPrice((vatdata[0] // (vat + 1)) * vat))) |
|
391 | 392 |
net += vatdata[0] |
392 | 393 |
summaries.append(('Nettobetrag gesamt:', _formatPrice(net))) |
393 | 394 |
summaries.sort() |
... | ... |
@@ -416,7 +417,7 @@ def InvoiceToPDF(iv, bankdata=True): |
416 | 417 |
vatstr += ',%s' % decimals |
417 | 418 |
summaries.append(('zzgl. %s%% MwSt:' % vatstr, _formatPrice(vat * part.sum))) |
418 | 419 |
elif len(part.vat) > 1: |
419 |
- for vat, vatdata in part.vat.items(): |
|
420 |
+ for vat, vatdata in list(part.vat.items()): |
|
420 | 421 |
(integer, decimals) = _niceCount((vat * 100)) |
421 | 422 |
vatstr = '%s' % integer |
422 | 423 |
if decimals: |
... | ... |
@@ -428,7 +429,7 @@ def InvoiceToPDF(iv, bankdata=True): |
428 | 429 |
canvas.drawRightString(left + 16.8 * cm, y - font_height, line[1]) |
429 | 430 |
y -= line_height |
430 | 431 |
sum = part.sum |
431 |
- for vat, vatdata in part.vat.items(): |
|
432 |
+ for vat, vatdata in list(part.vat.items()): |
|
432 | 433 |
sum += vat * vatdata[0] |
433 | 434 |
canvas.setFont(font + '-Bold', font_size) |
434 | 435 |
if iv.tender: |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
# -* coding: utf8 *- |
2 | 2 |
|
3 |
+from __future__ import division |
|
3 | 4 |
from Invoice import Text, Table |
4 | 5 |
from utils import format_price, split_to_width |
5 | 6 |
|
... | ... |
@@ -82,7 +83,7 @@ def InvoiceTableToText(invoiceTable): |
82 | 83 |
vat = list(invoiceTable.vat.keys())[0] |
83 | 84 |
summaries.append(u' Im Rechnungsbetrag sind %.1f%% MwSt enthalten (%s)' % (vat * 100, format_price((invoiceTable.sum / (vat + 1)) * vat))) |
84 | 85 |
else: |
85 |
- for vat, vatdata in invoiceTable.vat.items(): |
|
86 |
+ for vat, vatdata in list(invoiceTable.vat.items()): |
|
86 | 87 |
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))) |
87 | 88 |
summaries.sort() |
88 | 89 |
for line in summaries: |
... | ... |
@@ -94,13 +95,13 @@ def InvoiceTableToText(invoiceTable): |
94 | 95 |
vat = list(invoiceTable.vat.keys())[0] |
95 | 96 |
summaries.append((u'zzgl. %.1f%% MwSt: %11s' % (vat * 100, format_price(vat * invoiceTable.sum))).rjust(72)) |
96 | 97 |
elif len(invoiceTable.vat) > 1: |
97 |
- for vat, vatdata in invoiceTable.vat.items(): |
|
98 |
+ for vat, vatdata in list(invoiceTable.vat.items()): |
|
98 | 99 |
summaries.append((u'zzgl. %4.1f%% MwSt (%s): %11s' % (vat * 100, vatdata[1], format_price(vat * vatdata[0]))).rjust(72)) |
99 | 100 |
summaries.sort() |
100 | 101 |
for line in summaries: |
101 | 102 |
ret.append(line) |
102 | 103 |
sum = invoiceTable.sum |
103 |
- for vat, vatdata in invoiceTable.vat.items(): |
|
104 |
+ for vat, vatdata in list(invoiceTable.vat.items()): |
|
104 | 105 |
sum += vat * vatdata[0] |
105 | 106 |
ret.append((u'Rechnungsbetrag: %11s' % format_price(sum)).rjust(72)) |
106 | 107 |
ret.append('') |
107 | 108 |