Bernd Wurst commited on 2008-01-23 18:11:21
Zeige 3 geänderte Dateien mit 25 Einfügungen und 12 Löschungen.
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
|
3 | 3 |
import datetime |
4 | 4 |
|
5 |
-class InvoiceText(object): |
|
5 |
+class Text(object): |
|
6 | 6 |
def __init__(self, content, urgent=False, headline=None): |
7 | 7 |
self.paragraphs = [content] |
8 | 8 |
self.urgent = urgent |
... | ... |
@@ -12,7 +12,7 @@ class InvoiceText(object): |
12 | 12 |
self.paragraphs.append(content) |
13 | 13 |
|
14 | 14 |
|
15 |
-class InvoiceTable(object): |
|
15 |
+class Table(object): |
|
16 | 16 |
def __init__(self, vatType = 'gross', tender = False, summary = True): |
17 | 17 |
self.entries = [] |
18 | 18 |
self.vat = {} |
... | ... |
@@ -58,12 +58,14 @@ class InvoiceTable(object): |
58 | 58 |
|
59 | 59 |
|
60 | 60 |
class Invoice(object): |
61 |
- def __init__(self, tender = False): |
|
61 |
+ tender = False |
|
62 |
+ caption = 'Rechnung' |
|
63 |
+ |
|
64 |
+ def __init__(self): |
|
62 | 65 |
self.customerno = None |
63 | 66 |
self.addresslines = ['', ] |
64 | 67 |
self.salutation = 'Sehr geehte Damen und Herren,' |
65 | 68 |
self.id = None |
66 |
- self.tender = tender |
|
67 | 69 |
self.parts = [] |
68 | 70 |
self.pagecount = 0 |
69 | 71 |
self.date = datetime.date.today() |
... | ... |
@@ -72,3 +74,14 @@ class Invoice(object): |
72 | 74 |
if type(date) != datetime.date: |
73 | 75 |
raise ValueError('date must be of type »datetime.date«') |
74 | 76 |
self.date = date |
77 |
+ |
|
78 |
+ |
|
79 |
+class Tender(Invoice): |
|
80 |
+ tender = True |
|
81 |
+ caption = 'Angebot' |
|
82 |
+ |
|
83 |
+ |
|
84 |
+class Generic(Invoice): |
|
85 |
+ tender = False |
|
86 |
+ caption = '' |
|
87 |
+ |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
# -* coding: utf8 *- |
2 | 2 |
|
3 |
-from InvoiceObjects import * |
|
3 |
+from Invoice import * |
|
4 | 4 |
import re |
5 | 5 |
|
6 | 6 |
# reportlab imports |
... | ... |
@@ -123,7 +123,7 @@ def InvoiceToPDF(iv): |
123 | 123 |
|
124 | 124 |
def _partHeight(part): |
125 | 125 |
height = 0 |
126 |
- if type(part) == InvoiceText: |
|
126 |
+ if type(part) == Text: |
|
127 | 127 |
left, right = leftcontent, rightcontent |
128 | 128 |
if part.urgent: |
129 | 129 |
left += 1.5*cm |
... | ... |
@@ -133,7 +133,7 @@ def InvoiceToPDF(iv): |
133 | 133 |
height += (len(_splitToWidth(canvas, part.headline, right-left, font+'-Bold', default_font_size+1)) * line_height) + line_padding |
134 | 134 |
for para in part.paragraphs: |
135 | 135 |
height += (len(_splitToWidth(canvas, para, right-left, font, default_font_size)) * line_height) + line_padding |
136 |
- elif type(part) == InvoiceTable: |
|
136 |
+ elif type(part) == Table: |
|
137 | 137 |
## FIXME: Das ist dreckig |
138 | 138 |
height = len(part.entries) * 1.1*cm |
139 | 139 |
height += 3*cm |
... | ... |
@@ -250,7 +250,7 @@ def InvoiceToPDF(iv): |
250 | 250 |
canvas.setFont(font, font_size-2) |
251 | 251 |
canvas.drawCentredString(leftcontent + (rightcontent - leftcontent) / 2, y, '- Seite %i -' % num_pages) |
252 | 252 |
y -= line_padding*3 |
253 |
- if type(part) == InvoiceTable: |
|
253 |
+ if type(part) == Table: |
|
254 | 254 |
|
255 | 255 |
left = leftcontent |
256 | 256 |
right = rightcontent |
... | ... |
@@ -377,7 +377,7 @@ def InvoiceToPDF(iv): |
377 | 377 |
canvas.drawRightString(left + 16.8*cm, y-font_height, _formatPrice(sum)) |
378 | 378 |
canvas.setFont(font, font_size) |
379 | 379 |
y -= line_height + line_padding |
380 |
- elif type(part) == InvoiceText: |
|
380 |
+ elif type(part) == Text: |
|
381 | 381 |
my_font_size = font_size |
382 | 382 |
canvas.setFont(font, my_font_size) |
383 | 383 |
left, right = leftcontent, rightcontent |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
# -* coding: utf8 *- |
2 | 2 |
|
3 |
-from InvoiceObjects import * |
|
3 |
+from Invoice import Text, Table |
|
4 | 4 |
from utils import format_price, split_to_width |
5 | 5 |
|
6 | 6 |
|
... | ... |
@@ -31,9 +31,9 @@ def InvoiceToText(iv): |
31 | 31 |
|
32 | 32 |
ret.append('') |
33 | 33 |
for part in iv.parts: |
34 |
- if type(part) == InvoiceTable: |
|
34 |
+ if type(part) == Table: |
|
35 | 35 |
ret.append(InvoiceTableToText(part)) |
36 |
- elif type(part) == InvoiceText: |
|
36 |
+ elif type(part) == Text: |
|
37 | 37 |
ret.append(InvoiceTextToText(part)) |
38 | 38 |
else: |
39 | 39 |
raise NotImplementedError("Cannot handle part of type %s" % type(part)) |
40 | 40 |