Bernd Wurst commited on 2008-01-23 19:00:01
Zeige 1 geänderte Dateien mit 21 Einfügungen und 14 Löschungen.
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
# -* coding: utf8 *- |
| 2 | 2 |
|
| 3 |
-from Invoice import * |
|
| 3 |
+import Invoice |
|
| 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) == Text: |
|
| 126 |
+ if type(part) == Invoice.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) == Table: |
|
| 136 |
+ elif type(part) == Invoice.Table: |
|
| 137 | 137 |
## FIXME: Das ist dreckig |
| 138 | 138 |
height = len(part.entries) * 1.1*cm |
| 139 | 139 |
height += 3*cm |
| ... | ... |
@@ -158,7 +158,7 @@ def InvoiceToPDF(iv): |
| 158 | 158 |
canvas.setFont(font, font_size) |
| 159 | 159 |
|
| 160 | 160 |
|
| 161 |
- canvas.drawString(x, y+0.1*cm, ' schokokeks.org - Köchersberg 25 - 71540 Murrhardt') |
|
| 161 |
+ canvas.drawString(x, y+0.1*cm, ' schokokeks.org · Köchersberg 25 · 71540 Murrhardt') |
|
| 162 | 162 |
canvas.line(x, y, x + (8.5 * cm), y) |
| 163 | 163 |
y = y - font_size - 3 |
| 164 | 164 |
|
| ... | ... |
@@ -196,18 +196,22 @@ def InvoiceToPDF(iv): |
| 196 | 196 |
y -= (font_size + 10) |
| 197 | 197 |
y = -9.5*cm |
| 198 | 198 |
canvas.setFont(font+'-Bold', font_size+3) |
| 199 |
- if iv.tender: |
|
| 200 |
- canvas.drawString(leftcontent, y, 'Angebot') |
|
| 201 |
- else: |
|
| 202 |
- canvas.drawString(leftcontent, y, 'Rechnung') |
|
| 199 |
+ min_y = y |
|
| 200 |
+ if iv.caption: |
|
| 201 |
+ canvas.drawString(leftcontent, y, iv.caption) |
|
| 202 |
+ min_y -= (font_size + 3) + 0.5*cm |
|
| 203 | 203 |
|
| 204 |
- if iv.tender: |
|
| 204 |
+ if type(iv) == Invoice.Tender: |
|
| 205 | 205 |
canvas.setFont(font, font_size) |
| 206 | 206 |
canvas.drawString(rightcolumn, y, "Erstellungsdatum:") |
| 207 | 207 |
canvas.drawRightString(rightcontent, y, "%s" % iv.date.strftime('%d. %m. %Y'))
|
| 208 | 208 |
y -= (font_size + 0.1*cm) |
| 209 |
- |
|
| 210 |
- else: |
|
| 209 |
+ elif type(iv) == Invoice.Generic: |
|
| 210 |
+ canvas.setFont(font, font_size) |
|
| 211 |
+ canvas.drawString(rightcolumn, y, "Datum:") |
|
| 212 |
+ canvas.drawRightString(rightcontent, y, "%s" % iv.date.strftime('%d. %m. %Y'))
|
|
| 213 |
+ y -= (font_size + 0.1*cm) |
|
| 214 |
+ elif type(iv) == Invoice.Invoice: |
|
| 211 | 215 |
canvas.setFont(font+'-Bold', font_size) |
| 212 | 216 |
canvas.drawString(rightcolumn, y, "Bei Fragen bitte immer angeben:") |
| 213 | 217 |
y -= (font_size + 0.2*cm) |
| ... | ... |
@@ -223,11 +227,14 @@ def InvoiceToPDF(iv): |
| 223 | 227 |
canvas.drawRightString(rightcontent, y, "%s" % iv.customerno) |
| 224 | 228 |
y -= (font_size + 0.5*cm) |
| 225 | 229 |
canvas.setFont(font, font_size) |
| 230 |
+ y = min(min_y, y) |
|
| 226 | 231 |
|
| 232 |
+ if iv.salutation: |
|
| 227 | 233 |
canvas.drawString(leftcontent, y, iv.salutation) |
| 228 | 234 |
y -= font_size + 0.2*cm |
| 235 |
+ if type(iv) in [Invoice.Tender, Invoice.Invoice]: |
|
| 229 | 236 |
introText = 'hiermit stellen wir Ihnen die nachfolgend genannten Leistungen in Rechnung.' |
| 230 |
- if iv.tender: |
|
| 237 |
+ if type(iv) == Invoice.Tender: |
|
| 231 | 238 |
introText = 'hiermit unterbreiten wir Ihnen folgendes Angebot.' |
| 232 | 239 |
intro = _splitToWidth(canvas, introText, rightcontent - leftcontent, font, font_size) |
| 233 | 240 |
for line in intro: |
| ... | ... |
@@ -250,7 +257,7 @@ def InvoiceToPDF(iv): |
| 250 | 257 |
canvas.setFont(font, font_size-2) |
| 251 | 258 |
canvas.drawCentredString(leftcontent + (rightcontent - leftcontent) / 2, y, '- Seite %i -' % num_pages) |
| 252 | 259 |
y -= line_padding*3 |
| 253 |
- if type(part) == Table: |
|
| 260 |
+ if type(part) == Invoice.Table: |
|
| 254 | 261 |
|
| 255 | 262 |
left = leftcontent |
| 256 | 263 |
right = rightcontent |
| ... | ... |
@@ -377,7 +384,7 @@ def InvoiceToPDF(iv): |
| 377 | 384 |
canvas.drawRightString(left + 16.8*cm, y-font_height, _formatPrice(sum)) |
| 378 | 385 |
canvas.setFont(font, font_size) |
| 379 | 386 |
y -= line_height + line_padding |
| 380 |
- elif type(part) == Text: |
|
| 387 |
+ elif type(part) == Invoice.Text: |
|
| 381 | 388 |
my_font_size = font_size |
| 382 | 389 |
canvas.setFont(font, my_font_size) |
| 383 | 390 |
left, right = leftcontent, rightcontent |
| 384 | 391 |