Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 1) # -* coding: utf8 *-
src/rechnung/Invoice/pdf.py 2)
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 3) from __future__ import division
|
Generisch
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 4) import Invoice
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 5) import re
src/rechnung/Invoice/pdf.py 6)
|
Trennung von Firmen-spezifi...
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 7) # our page size and margins
|
Mache die Invoice-Library f...
Bernd Wurst authored 7 years ago
|
src/rechnung/Invoice/pdf.py 8) from .metrics import *
|
Trennung von Firmen-spezifi...
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 9) # our custom page style
|
Mache die Invoice-Library f...
Bernd Wurst authored 7 years ago
|
src/rechnung/Invoice/pdf.py 10) from .custom_elements import basicPage, firstPage, address_header
|
Trennung von Firmen-spezifi...
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 11)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 12) # reportlab imports
|
GiroCode auf den Rechnungen
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/pdf.py 13) from reportlab.lib.units import cm, inch
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 14) from reportlab.pdfgen import canvas as Canvas
|
Verstecke Bankdaten bei Rec...
Bernd Wurst authored 7 years ago
|
src/rechnung/Invoice/pdf.py 15) from reportlab.lib.colors import Color
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 16)
|
Teile Tabelle auch mittendr...
Bernd Wurst authored 11 years ago
|
src/rechnung/Invoice/pdf.py 17)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 18) def _formatPrice(price, symbol='€'):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 19) '''_formatPrice(price, symbol='€'):
src/rechnung/Invoice/pdf.py 20) Gets a floating point value and returns a formatted price, suffixed by 'symbol'. '''
src/rechnung/Invoice/pdf.py 21) s = ("%.2f" % price).replace('.', ',')
src/rechnung/Invoice/pdf.py 22) pat = re.compile(r'([0-9])([0-9]{3}[.,])')
src/rechnung/Invoice/pdf.py 23) while pat.search(s):
src/rechnung/Invoice/pdf.py 24) s = pat.sub(r'\1.\2', s)
src/rechnung/Invoice/pdf.py 25) return s + ' ' + symbol
src/rechnung/Invoice/pdf.py 26)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 27)
src/rechnung/Invoice/pdf.py 28) def _niceCount(value):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 29) '''_niceCount(value):
src/rechnung/Invoice/pdf.py 30) Returns a tuple (integer , decimals) where decimals can be None'''
src/rechnung/Invoice/pdf.py 31) if type(value) == int:
src/rechnung/Invoice/pdf.py 32) return ('%i' % value, None)
src/rechnung/Invoice/pdf.py 33) if round(value, 2) == int(value):
src/rechnung/Invoice/pdf.py 34) return ('%i' % int(value), None)
src/rechnung/Invoice/pdf.py 35) s = '%.2f' % value
src/rechnung/Invoice/pdf.py 36) (integer, decimals) = s.split('.', 1)
src/rechnung/Invoice/pdf.py 37) if decimals[-1] == '0':
src/rechnung/Invoice/pdf.py 38) decimals = decimals[:-1]
src/rechnung/Invoice/pdf.py 39) return (integer, decimals)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 40)
src/rechnung/Invoice/pdf.py 41)
src/rechnung/Invoice/pdf.py 42) def _splitToWidth(canvas, text, width, font, size):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 43) '''_splitToWidth(canvas, text, width, font, size)
src/rechnung/Invoice/pdf.py 44) Split a string to several lines of a given width.'''
src/rechnung/Invoice/pdf.py 45) lines = []
src/rechnung/Invoice/pdf.py 46) paras = text.split('\n')
src/rechnung/Invoice/pdf.py 47) for para in paras:
src/rechnung/Invoice/pdf.py 48) words = para.split(' ')
src/rechnung/Invoice/pdf.py 49) while len(words) > 0:
src/rechnung/Invoice/pdf.py 50) mywords = [words[0], ]
src/rechnung/Invoice/pdf.py 51) del words[0]
src/rechnung/Invoice/pdf.py 52) while len(words) > 0 and canvas.stringWidth(' '.join(mywords) + ' ' + words[0], font, size) <= width:
src/rechnung/Invoice/pdf.py 53) mywords.append(words[0])
src/rechnung/Invoice/pdf.py 54) del words[0]
src/rechnung/Invoice/pdf.py 55) lines.append(' '.join(mywords))
src/rechnung/Invoice/pdf.py 56) return lines
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 57)
src/rechnung/Invoice/pdf.py 58)
|
InvoiceText als Blocksatz d...
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 59) def _drawJustifiedString(x, y, text, canvas, width, font, size):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 60) text = text.strip()
src/rechnung/Invoice/pdf.py 61) if canvas.stringWidth(text, font, size) > width:
src/rechnung/Invoice/pdf.py 62) canvas.drawString(x, y, text)
src/rechnung/Invoice/pdf.py 63) # too long line, I cannot handle this
src/rechnung/Invoice/pdf.py 64) return
src/rechnung/Invoice/pdf.py 65) if ' ' not in text:
src/rechnung/Invoice/pdf.py 66) canvas.drawString(x, y, text)
src/rechnung/Invoice/pdf.py 67) # no space in there, nothing to justify
src/rechnung/Invoice/pdf.py 68) return
src/rechnung/Invoice/pdf.py 69)
src/rechnung/Invoice/pdf.py 70) words = ['%s' % w for w in text.split(' ')]
src/rechnung/Invoice/pdf.py 71) words_width = 0.0
src/rechnung/Invoice/pdf.py 72) for word in words:
src/rechnung/Invoice/pdf.py 73) words_width += canvas.stringWidth(word, font, size)
src/rechnung/Invoice/pdf.py 74)
src/rechnung/Invoice/pdf.py 75) available_space = width - words_width
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 76) available_each = available_space // float((len(words) - 1))
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 77)
src/rechnung/Invoice/pdf.py 78) my_x = x
src/rechnung/Invoice/pdf.py 79) for idx in range(len(words)):
src/rechnung/Invoice/pdf.py 80) word = words[idx]
src/rechnung/Invoice/pdf.py 81) canvas.drawString(my_x, y, word)
src/rechnung/Invoice/pdf.py 82) my_x += canvas.stringWidth(word, font, size) + available_each
|
InvoiceText als Blocksatz d...
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 83) return
src/rechnung/Invoice/pdf.py 84)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 85)
|
Break long address-lines
Bernd Wurst authored 15 years ago
|
src/rechnung/Invoice/pdf.py 86) def address(canvas, lines):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 87) x = 2.0 * cm
src/rechnung/Invoice/pdf.py 88) y = page_height - 5.0 * cm
src/rechnung/Invoice/pdf.py 89) canvas.setFont(font, 8)
src/rechnung/Invoice/pdf.py 90) canvas.drawString(x + 0.5 * cm, y + 0.1 * cm, 'schokokeks.org · Köchersberg 32 · 71540 Murrhardt')
src/rechnung/Invoice/pdf.py 91) canvas.setLineWidth(1)
src/rechnung/Invoice/pdf.py 92) canvas.line(x + 0.4 * cm, y, x + address_width, y)
src/rechnung/Invoice/pdf.py 93) y = y - 0.2 * cm
src/rechnung/Invoice/pdf.py 94)
src/rechnung/Invoice/pdf.py 95) line_height = 11 + 0.1 * cm
src/rechnung/Invoice/pdf.py 96) y -= line_height
src/rechnung/Invoice/pdf.py 97)
src/rechnung/Invoice/pdf.py 98) fontsize = 11
src/rechnung/Invoice/pdf.py 99) for line in lines:
src/rechnung/Invoice/pdf.py 100) if canvas.stringWidth(line, font, fontsize) > address_width:
src/rechnung/Invoice/pdf.py 101) # Wenn es in zwei Zeilen passt, dann ist alles okay, ansonsten verkleinern
src/rechnung/Invoice/pdf.py 102) if len(lines) > 4 or canvas.stringWidth(line, font, fontsize) > 2 * address_width:
src/rechnung/Invoice/pdf.py 103) for candidate in [10.5, 10, 9.5, 9, 8.5, 8]:
src/rechnung/Invoice/pdf.py 104) fontsize = candidate
src/rechnung/Invoice/pdf.py 105) if (len(lines) <= 4 and canvas.stringWidth(line, font, fontsize) <= 2 * address_width) or canvas.stringWidth(line, font, fontsize) <= address_width:
src/rechnung/Invoice/pdf.py 106) break
src/rechnung/Invoice/pdf.py 107) for line in lines:
src/rechnung/Invoice/pdf.py 108) if canvas.stringWidth(line, font, fontsize) > address_width:
src/rechnung/Invoice/pdf.py 109) mylines = _splitToWidth(canvas, line, address_width, font, fontsize)
src/rechnung/Invoice/pdf.py 110) for l in mylines:
src/rechnung/Invoice/pdf.py 111) canvas.setFont(font, fontsize)
src/rechnung/Invoice/pdf.py 112) canvas.drawString(x + 0.5 * cm, y, l)
src/rechnung/Invoice/pdf.py 113) y -= line_height
src/rechnung/Invoice/pdf.py 114) else:
src/rechnung/Invoice/pdf.py 115) canvas.setFont(font, fontsize)
src/rechnung/Invoice/pdf.py 116) canvas.drawString(x + 0.5 * cm, y, line)
src/rechnung/Invoice/pdf.py 117) y -= line_height
|
Break long address-lines
Bernd Wurst authored 15 years ago
|
src/rechnung/Invoice/pdf.py 118)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 119)
|
Verstecke Bankdaten bei Rec...
Bernd Wurst authored 7 years ago
|
src/rechnung/Invoice/pdf.py 120) def InvoiceToPDF(iv, bankdata=True):
|
Python-3-anpassungen
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 121) from io import BytesIO
src/rechnung/Invoice/pdf.py 122) fd = BytesIO()
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 123) canvas = Canvas.Canvas(fd, pagesize=A4)
src/rechnung/Invoice/pdf.py 124)
src/rechnung/Invoice/pdf.py 125) if iv.tender:
src/rechnung/Invoice/pdf.py 126) canvas.setTitle("Angebot von schokokeks.org")
|
Teile Tabelle auch mittendr...
Bernd Wurst authored 11 years ago
|
src/rechnung/Invoice/pdf.py 127) else:
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 128) canvas.setTitle("Rechnung von schokokeks.org")
src/rechnung/Invoice/pdf.py 129)
src/rechnung/Invoice/pdf.py 130) canvas.setFont(font, 12)
src/rechnung/Invoice/pdf.py 131)
|
syntaxfehler behoben und Gu...
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 132) num_pages = 1
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 133) # Waehrungssysmbol
src/rechnung/Invoice/pdf.py 134) symbol = '€'
src/rechnung/Invoice/pdf.py 135) y = topcontent
src/rechnung/Invoice/pdf.py 136) font_size = default_font_size
src/rechnung/Invoice/pdf.py 137) font_height = 0.35 * cm
src/rechnung/Invoice/pdf.py 138) line_padding = 0.1 * cm
src/rechnung/Invoice/pdf.py 139) line_height = font_height + 0.1 * cm
src/rechnung/Invoice/pdf.py 140)
src/rechnung/Invoice/pdf.py 141) def _partHeight(part):
src/rechnung/Invoice/pdf.py 142) height = 0
src/rechnung/Invoice/pdf.py 143) if type(part) == Invoice.Text:
src/rechnung/Invoice/pdf.py 144) left, right = leftcontent, rightcontent
src/rechnung/Invoice/pdf.py 145) if part.urgent:
src/rechnung/Invoice/pdf.py 146) left += 1.5 * cm
src/rechnung/Invoice/pdf.py 147) right -= 1.5 * cm
src/rechnung/Invoice/pdf.py 148) height += len(part.paragraphs) * 3 * line_padding
src/rechnung/Invoice/pdf.py 149) # Rechne eine Zeile mehr für den Rahmen
src/rechnung/Invoice/pdf.py 150) height += line_height
src/rechnung/Invoice/pdf.py 151) if part.headline:
src/rechnung/Invoice/pdf.py 152) height += (len(_splitToWidth(canvas, part.headline, right - left, font + '-Bold', default_font_size + 1)) * line_height) + line_padding
src/rechnung/Invoice/pdf.py 153) for para in part.paragraphs:
src/rechnung/Invoice/pdf.py 154) height += (len(_splitToWidth(canvas, para, right - left, font, default_font_size)) * line_height) + line_padding
src/rechnung/Invoice/pdf.py 155) elif type(part) == Invoice.Table:
src/rechnung/Invoice/pdf.py 156) # Eine Zeile plus 2 mal line_padding für Tabellenkopf
src/rechnung/Invoice/pdf.py 157) height = line_height + 2 * line_padding
src/rechnung/Invoice/pdf.py 158) # Wenn nur ein Element (plus Summen) hin passt, reicht uns das
src/rechnung/Invoice/pdf.py 159) el = part.entries[0]
src/rechnung/Invoice/pdf.py 160) # Die Abstände oben und unten
src/rechnung/Invoice/pdf.py 161) height += 2 * line_padding
src/rechnung/Invoice/pdf.py 162) # Die Breite ist konservativ
src/rechnung/Invoice/pdf.py 163) height += line_height * len(_splitToWidth(canvas, el['subject'], 9.3 * cm, font, font_size))
src/rechnung/Invoice/pdf.py 164) if 'desc' in el and el['desc'] != '':
src/rechnung/Invoice/pdf.py 165) height += line_height * len(_splitToWidth(canvas, el['desc'], 11 * cm, font, font_size))
src/rechnung/Invoice/pdf.py 166) if part.vatType == 'net':
src/rechnung/Invoice/pdf.py 167) # Eine Zeile mehr
src/rechnung/Invoice/pdf.py 168) height += line_height + line_padding
src/rechnung/Invoice/pdf.py 169) # Für die MwSt-Summen
src/rechnung/Invoice/pdf.py 170) height += (line_height + line_padding) * len(part.vat)
src/rechnung/Invoice/pdf.py 171) # Für den Rechnungsbetrag
src/rechnung/Invoice/pdf.py 172) height += line_height + line_padding
src/rechnung/Invoice/pdf.py 173) return height
src/rechnung/Invoice/pdf.py 174)
src/rechnung/Invoice/pdf.py 175) def _tableHead(y):
src/rechnung/Invoice/pdf.py 176) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 177) canvas.drawString(left + (0.1 * cm), y - line_height + line_padding, 'Anz.')
src/rechnung/Invoice/pdf.py 178) canvas.drawString(left + (2.6 * cm), y - line_height + line_padding, 'Beschreibung')
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 179) if len(part.vat) == 1:
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 180) canvas.drawRightString(left + (14.3 * cm), y - line_height + line_padding, 'Einzelpreis')
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 181) else:
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 182) canvas.drawRightString(left + (13.7 * cm), y - line_height + line_padding, 'Einzelpreis')
src/rechnung/Invoice/pdf.py 183) canvas.drawRightString(left + (16.8 * cm), y - line_height + line_padding, 'Gesamtpreis')
src/rechnung/Invoice/pdf.py 184) canvas.setLineWidth(0.01 * cm)
src/rechnung/Invoice/pdf.py 185) canvas.line(left, y - line_height, right, y - line_height)
src/rechnung/Invoice/pdf.py 186) y -= line_height + 0.02 * cm
src/rechnung/Invoice/pdf.py 187) return y
src/rechnung/Invoice/pdf.py 188)
src/rechnung/Invoice/pdf.py 189) def _PageWrap(canvas):
src/rechnung/Invoice/pdf.py 190) '''Seitenumbruch'''
|
syntaxfehler behoben und Gu...
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 191) nonlocal num_pages
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 192) num_pages += 1
src/rechnung/Invoice/pdf.py 193) canvas.setFont(font, default_font_size - 2)
src/rechnung/Invoice/pdf.py 194) canvas.drawRightString(rightcontent, bottomcontent + line_padding, 'Fortsetzung auf Seite %i' % num_pages)
src/rechnung/Invoice/pdf.py 195) canvas.showPage()
src/rechnung/Invoice/pdf.py 196) basicPage(canvas)
src/rechnung/Invoice/pdf.py 197) y = topcontent - font_size
src/rechnung/Invoice/pdf.py 198) canvas.setFillColor((0, 0, 0))
src/rechnung/Invoice/pdf.py 199) canvas.setFont(font, font_size - 2)
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 200) canvas.drawCentredString(leftcontent + (rightcontent - leftcontent) // 2, y, '- Seite %i -' % num_pages)
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 201)
src/rechnung/Invoice/pdf.py 202) address(canvas, iv.addresslines)
src/rechnung/Invoice/pdf.py 203)
src/rechnung/Invoice/pdf.py 204) font_size = default_font_size
src/rechnung/Invoice/pdf.py 205) y = firstPage(canvas)
src/rechnung/Invoice/pdf.py 206) if not bankdata:
src/rechnung/Invoice/pdf.py 207) # Bankdaten überschreiben wenn Lastschrift
src/rechnung/Invoice/pdf.py 208) canvas.setFillColor(Color(255, 255, 255, alpha=0.8))
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 209) canvas.rect(leftcontent + ((rightcontent - leftcontent) // 3) * 2 - 2, bottomcontent - 2, (rightcontent - leftcontent) // 3, -40, fill=True, stroke=False)
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 210) canvas.setFillColor(Color(0, 0, 0, alpha=1))
src/rechnung/Invoice/pdf.py 211) canvas.saveState()
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 212) canvas.translate(leftcontent + ((rightcontent - leftcontent) // 3) * 2 + 2, bottomcontent - 40)
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 213) canvas.rotate(15)
src/rechnung/Invoice/pdf.py 214) canvas.drawString(0, 0, "Bitte nicht überweisen")
src/rechnung/Invoice/pdf.py 215) canvas.restoreState()
src/rechnung/Invoice/pdf.py 216) # canvas.drawString(leftcontent+((rightcontent-leftcontent)/3)*2 + 2, bottomcontent - 20, "Bitte nicht überweisen")
src/rechnung/Invoice/pdf.py 217)
src/rechnung/Invoice/pdf.py 218) canvas.setFont(font + '-Bold', font_size + 3)
src/rechnung/Invoice/pdf.py 219) min_y = y
src/rechnung/Invoice/pdf.py 220) if iv.caption:
src/rechnung/Invoice/pdf.py 221) canvas.drawString(leftcontent, y, iv.caption)
src/rechnung/Invoice/pdf.py 222) min_y -= (font_size + 3) + 0.5 * cm
src/rechnung/Invoice/pdf.py 223)
src/rechnung/Invoice/pdf.py 224) if type(iv) == Invoice.Tender:
src/rechnung/Invoice/pdf.py 225) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 226) canvas.drawString(rightcolumn, y, "Erstellungsdatum:")
src/rechnung/Invoice/pdf.py 227) canvas.drawRightString(rightcontent, y, "%s" % iv.date.strftime('%d. %m. %Y'))
src/rechnung/Invoice/pdf.py 228) y -= (font_size + 0.1 * cm)
src/rechnung/Invoice/pdf.py 229) elif type(iv) == Invoice.Generic:
src/rechnung/Invoice/pdf.py 230) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 231) canvas.drawString(rightcolumn, y, "Datum:")
src/rechnung/Invoice/pdf.py 232) canvas.drawRightString(rightcontent, y, "%s" % iv.date.strftime('%d. %m. %Y'))
src/rechnung/Invoice/pdf.py 233) y -= (font_size + 0.1 * cm)
src/rechnung/Invoice/pdf.py 234) elif type(iv) == Invoice.Invoice:
src/rechnung/Invoice/pdf.py 235) canvas.setFont(font + '-Bold', font_size)
src/rechnung/Invoice/pdf.py 236) canvas.drawString(rightcolumn, y, "Bei Fragen bitte immer angeben:")
src/rechnung/Invoice/pdf.py 237) y -= (font_size + 0.2 * cm)
src/rechnung/Invoice/pdf.py 238) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 239) canvas.drawString(rightcolumn, y, "Rechnungsdatum:")
src/rechnung/Invoice/pdf.py 240) canvas.drawRightString(rightcontent, y, "%s" % iv.date.strftime('%d. %m. %Y'))
src/rechnung/Invoice/pdf.py 241) y -= (font_size + 0.1 * cm)
src/rechnung/Invoice/pdf.py 242) canvas.drawString(rightcolumn, y, "Rechnungsnummer:")
src/rechnung/Invoice/pdf.py 243) canvas.drawRightString(rightcontent, y, "%i" % iv.id)
src/rechnung/Invoice/pdf.py 244) y -= (font_size + 0.1 * cm)
src/rechnung/Invoice/pdf.py 245) if iv.customerno:
src/rechnung/Invoice/pdf.py 246) canvas.drawString(rightcolumn, y, "Kundennummer:")
src/rechnung/Invoice/pdf.py 247) canvas.drawRightString(rightcontent, y, "%s" % iv.customerno)
src/rechnung/Invoice/pdf.py 248) y -= (font_size + 0.5 * cm)
src/rechnung/Invoice/pdf.py 249) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 250) y = min(min_y, y)
src/rechnung/Invoice/pdf.py 251)
src/rechnung/Invoice/pdf.py 252) if iv.salutation:
src/rechnung/Invoice/pdf.py 253) canvas.drawString(leftcontent, y, iv.salutation)
src/rechnung/Invoice/pdf.py 254) y -= font_size + 0.2 * cm
src/rechnung/Invoice/pdf.py 255) if type(iv) in [Invoice.Tender, Invoice.Invoice]:
src/rechnung/Invoice/pdf.py 256) introText = 'hiermit stellen wir Ihnen die nachfolgend genannten Leistungen in Rechnung.'
src/rechnung/Invoice/pdf.py 257) if type(iv) == Invoice.Tender:
src/rechnung/Invoice/pdf.py 258) introText = 'hiermit unterbreiten wir Ihnen folgendes Angebot.'
src/rechnung/Invoice/pdf.py 259) intro = _splitToWidth(canvas, introText, rightcontent - leftcontent, font, font_size)
src/rechnung/Invoice/pdf.py 260) for line in intro:
src/rechnung/Invoice/pdf.py 261) canvas.drawString(leftcontent, y, line)
src/rechnung/Invoice/pdf.py 262) y -= font_size + 0.1 * cm
src/rechnung/Invoice/pdf.py 263) y -= font_size + 0.1 * cm
src/rechnung/Invoice/pdf.py 264)
src/rechnung/Invoice/pdf.py 265) font_size = default_font_size
src/rechnung/Invoice/pdf.py 266) for part in iv.parts:
src/rechnung/Invoice/pdf.py 267) if y - _partHeight(part) < (bottomcontent + (0.5 * cm)):
src/rechnung/Invoice/pdf.py 268) _PageWrap(canvas)
src/rechnung/Invoice/pdf.py 269) y = topcontent - font_size - line_padding * 3
src/rechnung/Invoice/pdf.py 270) # Debug: Was hat die Höhenbestimmung für diesen Teil als Höhe herausgefunden?
src/rechnung/Invoice/pdf.py 271) # canvas.line(leftcontent, y-_partHeight(part), rightcontent, y-_partHeight(part))
src/rechnung/Invoice/pdf.py 272)
src/rechnung/Invoice/pdf.py 273) if type(part) == Invoice.Table:
src/rechnung/Invoice/pdf.py 274)
src/rechnung/Invoice/pdf.py 275) left = leftcontent
src/rechnung/Invoice/pdf.py 276) right = rightcontent
src/rechnung/Invoice/pdf.py 277) top = topcontent
src/rechnung/Invoice/pdf.py 278) bottom = bottomcontent
src/rechnung/Invoice/pdf.py 279) temp_sum = 0.0
src/rechnung/Invoice/pdf.py 280) y = _tableHead(y)
src/rechnung/Invoice/pdf.py 281) odd = True
src/rechnung/Invoice/pdf.py 282) for el in part.entries:
src/rechnung/Invoice/pdf.py 283) subject = []
src/rechnung/Invoice/pdf.py 284) if len(part.vat) == 1:
src/rechnung/Invoice/pdf.py 285) subject = _splitToWidth(canvas, el['subject'], 10.3 * cm, font, font_size)
src/rechnung/Invoice/pdf.py 286) else:
src/rechnung/Invoice/pdf.py 287) subject = _splitToWidth(canvas, el['subject'], 9.3 * cm, font, font_size)
src/rechnung/Invoice/pdf.py 288) desc = []
src/rechnung/Invoice/pdf.py 289) if 'desc' in el and el['desc'] != '':
src/rechnung/Invoice/pdf.py 290) desc = _splitToWidth(canvas, el['desc'], 11 * cm, font, font_size)
src/rechnung/Invoice/pdf.py 291) need_lines = len(subject) + len(desc)
src/rechnung/Invoice/pdf.py 292)
src/rechnung/Invoice/pdf.py 293) # need page wrap?
src/rechnung/Invoice/pdf.py 294) if y - (need_lines + 2 * font_size) < (bottomcontent + 2 * cm):
src/rechnung/Invoice/pdf.py 295) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 296) # Zwischensumme
src/rechnung/Invoice/pdf.py 297) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Zwischensumme:')
src/rechnung/Invoice/pdf.py 298) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(temp_sum))
src/rechnung/Invoice/pdf.py 299) # page wrap
src/rechnung/Invoice/pdf.py 300) _PageWrap(canvas)
src/rechnung/Invoice/pdf.py 301) y = topcontent - font_size - line_padding * 3
src/rechnung/Invoice/pdf.py 302) # header
src/rechnung/Invoice/pdf.py 303) y = _tableHead(y)
src/rechnung/Invoice/pdf.py 304) odd = True
src/rechnung/Invoice/pdf.py 305) # übertrag
src/rechnung/Invoice/pdf.py 306) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 307) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Übertrag:')
src/rechnung/Invoice/pdf.py 308) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(temp_sum))
src/rechnung/Invoice/pdf.py 309) y -= font_height + line_padding
src/rechnung/Invoice/pdf.py 310)
src/rechnung/Invoice/pdf.py 311) # Zwischensumme (inkl. aktueller Posten)
src/rechnung/Invoice/pdf.py 312) temp_sum += el['total']
src/rechnung/Invoice/pdf.py 313) # draw the background
src/rechnung/Invoice/pdf.py 314) if not odd:
src/rechnung/Invoice/pdf.py 315) canvas.setFillColorRGB(0.9, 0.9, 0.9)
src/rechnung/Invoice/pdf.py 316) else:
src/rechnung/Invoice/pdf.py 317) canvas.setFillColorRGB(1, 1, 1)
src/rechnung/Invoice/pdf.py 318) canvas.rect(left, y - (need_lines * line_height) - (2 * line_padding), height=(need_lines * line_height) + (2 * line_padding), width=right - left, fill=1, stroke=0)
src/rechnung/Invoice/pdf.py 319) canvas.setFillColorRGB(0, 0, 0)
src/rechnung/Invoice/pdf.py 320) y -= line_padding
src/rechnung/Invoice/pdf.py 321) (integer, decimals) = _niceCount(el['count'])
src/rechnung/Invoice/pdf.py 322) canvas.drawRightString(left + 0.8 * cm, y - font_height, integer)
src/rechnung/Invoice/pdf.py 323) suffix = ''
src/rechnung/Invoice/pdf.py 324) if decimals:
src/rechnung/Invoice/pdf.py 325) suffix = ',%s' % decimals
src/rechnung/Invoice/pdf.py 326) if el['unit']:
src/rechnung/Invoice/pdf.py 327) suffix = suffix + ' ' + el['unit']
src/rechnung/Invoice/pdf.py 328) if suffix:
src/rechnung/Invoice/pdf.py 329) canvas.drawString(left + 0.8 * cm, y - font_height, '%s' % suffix)
src/rechnung/Invoice/pdf.py 330)
src/rechnung/Invoice/pdf.py 331) if len(part.vat) < 2:
src/rechnung/Invoice/pdf.py 332) canvas.drawString(left + 2.7 * cm, y - font_height, subject[0])
src/rechnung/Invoice/pdf.py 333) canvas.drawRightString(left + 14.3 * cm, y - font_height, _formatPrice(el['price']))
src/rechnung/Invoice/pdf.py 334) if el['tender']:
src/rechnung/Invoice/pdf.py 335) canvas.drawRightString(left + 16.8 * cm, y - font_height, 'eventual')
src/rechnung/Invoice/pdf.py 336) else:
src/rechnung/Invoice/pdf.py 337) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(el['total']))
src/rechnung/Invoice/pdf.py 338) subject = subject[1:]
src/rechnung/Invoice/pdf.py 339) x = 1
src/rechnung/Invoice/pdf.py 340) for line in subject:
src/rechnung/Invoice/pdf.py 341) canvas.drawString(left + 2.7 * cm, y - (x * line_height) - font_height, line)
src/rechnung/Invoice/pdf.py 342) x += 1
src/rechnung/Invoice/pdf.py 343) for line in desc[:-1]:
src/rechnung/Invoice/pdf.py 344) _drawJustifiedString(left + 2.7 * cm, y - (x * line_height) - font_height, line, canvas, 11 * cm, font, font_size)
src/rechnung/Invoice/pdf.py 345) x += 1
src/rechnung/Invoice/pdf.py 346) canvas.drawString(left + 2.7 * cm, y - (x * line_height) - font_height, desc[-1])
src/rechnung/Invoice/pdf.py 347) x += 1
src/rechnung/Invoice/pdf.py 348) else:
src/rechnung/Invoice/pdf.py 349) canvas.drawString(left + 2.7 * cm, y - font_height, subject[0])
src/rechnung/Invoice/pdf.py 350) canvas.drawRightString(left + 13.3 * cm, y - font_height, _formatPrice(el['price']))
src/rechnung/Invoice/pdf.py 351) canvas.drawString(left + 13.7 * cm, y - font_height, str(part.vat[el['vat']][1]))
src/rechnung/Invoice/pdf.py 352) if el['tender']:
src/rechnung/Invoice/pdf.py 353) canvas.drawRightString(left + 16.8 * cm, y - font_height, 'eventual')
src/rechnung/Invoice/pdf.py 354) else:
src/rechnung/Invoice/pdf.py 355) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(el['total']))
src/rechnung/Invoice/pdf.py 356) subject = subject[1:]
src/rechnung/Invoice/pdf.py 357) x = 1
src/rechnung/Invoice/pdf.py 358) for line in subject:
src/rechnung/Invoice/pdf.py 359) canvas.drawString(left + 2.7 * cm, y - (x * line_height) - font_height, line)
src/rechnung/Invoice/pdf.py 360) x += 1
src/rechnung/Invoice/pdf.py 361) for line in desc:
src/rechnung/Invoice/pdf.py 362) canvas.drawString(left + 2.7 * cm, y - (x * line_height) - font_height, line)
src/rechnung/Invoice/pdf.py 363) x += 1
src/rechnung/Invoice/pdf.py 364) odd = not odd
src/rechnung/Invoice/pdf.py 365) y -= (need_lines * line_height) + line_padding
src/rechnung/Invoice/pdf.py 366) if part.summary:
src/rechnung/Invoice/pdf.py 367) y -= (0.3 * cm)
src/rechnung/Invoice/pdf.py 368) if part.vatType == 'gross':
src/rechnung/Invoice/pdf.py 369) summaries = []
src/rechnung/Invoice/pdf.py 370) if len(part.vat) == 1:
src/rechnung/Invoice/pdf.py 371) vat = list(part.vat.keys())[0]
src/rechnung/Invoice/pdf.py 372) (integer, decimals) = _niceCount((vat * 100))
src/rechnung/Invoice/pdf.py 373) vatstr = '%s' % integer
src/rechnung/Invoice/pdf.py 374) if decimals:
src/rechnung/Invoice/pdf.py 375) vatstr += ',%s' % decimals
src/rechnung/Invoice/pdf.py 376) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Nettobetrag:')
src/rechnung/Invoice/pdf.py 377) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(part.sum - (part.sum / (vat + 1)) * vat))
src/rechnung/Invoice/pdf.py 378) y -= line_height
src/rechnung/Invoice/pdf.py 379) summaries.append(('%s%% MwSt:' % vatstr, _formatPrice((part.sum / (vat + 1)) * vat)))
src/rechnung/Invoice/pdf.py 380) else:
src/rechnung/Invoice/pdf.py 381) net = 0.0
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 382) for vat, vatdata in list(part.vat.items()):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 383) (integer, decimals) = _niceCount((vat * 100))
src/rechnung/Invoice/pdf.py 384) vatstr = '%s' % integer
src/rechnung/Invoice/pdf.py 385) if decimals:
src/rechnung/Invoice/pdf.py 386) vatstr += ',%s' % decimals
|
Details beim Rechnungssystem
Bernd Wurst authored 3 years ago
|
src/rechnung/Invoice/pdf.py 387) _gross = vatdata[0]
src/rechnung/Invoice/pdf.py 388) _net = _gross / (1+vat)
src/rechnung/Invoice/pdf.py 389) _vat = _net * vat
src/rechnung/Invoice/pdf.py 390) summaries.append(('%s: Teilbetrag %s: Nettobetrag %s zzgl. %s%% MwSt:' % (vatdata[1], _formatPrice(_gross), _formatPrice(_net), vatstr), _formatPrice(_vat)))
src/rechnung/Invoice/pdf.py 391) net += _net
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 392) summaries.append(('Nettobetrag gesamt:', _formatPrice(net)))
src/rechnung/Invoice/pdf.py 393) summaries.sort()
src/rechnung/Invoice/pdf.py 394) for line in summaries:
src/rechnung/Invoice/pdf.py 395) canvas.drawRightString(left + 14.5 * cm, y - font_height, line[0])
src/rechnung/Invoice/pdf.py 396) canvas.drawRightString(left + 16.8 * cm, y - font_height, line[1])
src/rechnung/Invoice/pdf.py 397) y -= line_height
src/rechnung/Invoice/pdf.py 398) canvas.setFont(font + '-Bold', font_size)
src/rechnung/Invoice/pdf.py 399) if iv.tender:
src/rechnung/Invoice/pdf.py 400) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Gesamtbetrag:')
src/rechnung/Invoice/pdf.py 401) else:
src/rechnung/Invoice/pdf.py 402) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Rechnungsbetrag:')
src/rechnung/Invoice/pdf.py 403) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(part.sum))
src/rechnung/Invoice/pdf.py 404) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 405) y -= line_height + line_padding
src/rechnung/Invoice/pdf.py 406) else:
src/rechnung/Invoice/pdf.py 407) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Nettobetrag:')
src/rechnung/Invoice/pdf.py 408) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(part.sum))
src/rechnung/Invoice/pdf.py 409) y -= line_height
src/rechnung/Invoice/pdf.py 410) summaries = []
src/rechnung/Invoice/pdf.py 411) if len(part.vat) == 1:
src/rechnung/Invoice/pdf.py 412) vat = list(part.vat.keys())[0]
src/rechnung/Invoice/pdf.py 413) (integer, decimals) = _niceCount((vat * 100))
src/rechnung/Invoice/pdf.py 414) vatstr = '%s' % integer
src/rechnung/Invoice/pdf.py 415) if decimals:
src/rechnung/Invoice/pdf.py 416) vatstr += ',%s' % decimals
src/rechnung/Invoice/pdf.py 417) summaries.append(('zzgl. %s%% MwSt:' % vatstr, _formatPrice(vat * part.sum)))
src/rechnung/Invoice/pdf.py 418) elif len(part.vat) > 1:
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 419) for vat, vatdata in list(part.vat.items()):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 420) (integer, decimals) = _niceCount((vat * 100))
src/rechnung/Invoice/pdf.py 421) vatstr = '%s' % integer
src/rechnung/Invoice/pdf.py 422) if decimals:
src/rechnung/Invoice/pdf.py 423) vatstr += ',%s' % decimals
src/rechnung/Invoice/pdf.py 424) summaries.append(('zzgl. %s%% MwSt (%s):' % (vatstr, vatdata[1]), _formatPrice(vat * vatdata[0])))
src/rechnung/Invoice/pdf.py 425) summaries.sort()
src/rechnung/Invoice/pdf.py 426) for line in summaries:
src/rechnung/Invoice/pdf.py 427) canvas.drawRightString(left + 14.5 * cm, y - font_height, line[0])
src/rechnung/Invoice/pdf.py 428) canvas.drawRightString(left + 16.8 * cm, y - font_height, line[1])
src/rechnung/Invoice/pdf.py 429) y -= line_height
src/rechnung/Invoice/pdf.py 430) sum = part.sum
|
Python-3-Migration
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 431) for vat, vatdata in list(part.vat.items()):
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 432) sum += vat * vatdata[0]
src/rechnung/Invoice/pdf.py 433) canvas.setFont(font + '-Bold', font_size)
src/rechnung/Invoice/pdf.py 434) if iv.tender:
src/rechnung/Invoice/pdf.py 435) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Gesamtbetrag:')
src/rechnung/Invoice/pdf.py 436) else:
src/rechnung/Invoice/pdf.py 437) canvas.drawRightString(left + 14.5 * cm, y - font_height, 'Rechnungsbetrag:')
src/rechnung/Invoice/pdf.py 438) canvas.drawRightString(left + 16.8 * cm, y - font_height, _formatPrice(sum))
src/rechnung/Invoice/pdf.py 439) canvas.setFont(font, font_size)
src/rechnung/Invoice/pdf.py 440) y -= line_height + line_padding
src/rechnung/Invoice/pdf.py 441) elif type(part) == Invoice.Text:
src/rechnung/Invoice/pdf.py 442) my_font_size = font_size
src/rechnung/Invoice/pdf.py 443) canvas.setFont(font, my_font_size)
src/rechnung/Invoice/pdf.py 444) left, right = leftcontent, rightcontent
src/rechnung/Invoice/pdf.py 445) firsttime = True
src/rechnung/Invoice/pdf.py 446) headlines = []
src/rechnung/Invoice/pdf.py 447) if part.urgent:
src/rechnung/Invoice/pdf.py 448) left += 1.5 * cm
src/rechnung/Invoice/pdf.py 449) right -= 1.5 * cm
src/rechnung/Invoice/pdf.py 450) if part.headline:
src/rechnung/Invoice/pdf.py 451) headlines = _splitToWidth(canvas, part.headline, right - left, font, my_font_size)
src/rechnung/Invoice/pdf.py 452) for para in part.paragraphs:
src/rechnung/Invoice/pdf.py 453) lines = _splitToWidth(canvas, para, right - left, font, my_font_size)
src/rechnung/Invoice/pdf.py 454) if part.urgent:
src/rechnung/Invoice/pdf.py 455) need_height = len(lines) * line_height
src/rechnung/Invoice/pdf.py 456) if len(headlines) > 0:
src/rechnung/Invoice/pdf.py 457) need_height += len(headlines) * (line_height + 1) + line_padding
src/rechnung/Invoice/pdf.py 458) canvas.setFillColorRGB(0.95, 0.95, 0.95)
src/rechnung/Invoice/pdf.py 459) canvas.rect(left - 0.5 * cm, y - (need_height + (6 * line_padding)), height=need_height + (6 * line_padding), width=right - left + 1 * cm, fill=1, stroke=1)
src/rechnung/Invoice/pdf.py 460) canvas.setFillColorRGB(0, 0, 0)
src/rechnung/Invoice/pdf.py 461) y -= line_padding * 3
src/rechnung/Invoice/pdf.py 462) if part.headline and firsttime:
src/rechnung/Invoice/pdf.py 463) firsttime = False
src/rechnung/Invoice/pdf.py 464) canvas.setFont(font + '-Bold', my_font_size + 1)
src/rechnung/Invoice/pdf.py 465) for line in headlines:
src/rechnung/Invoice/pdf.py 466) canvas.drawString(left, y - (font_height + 1), line)
src/rechnung/Invoice/pdf.py 467) y -= line_height + 1
src/rechnung/Invoice/pdf.py 468) y -= line_padding
src/rechnung/Invoice/pdf.py 469) canvas.setFont(font, my_font_size)
src/rechnung/Invoice/pdf.py 470) for line in lines[:-1]:
src/rechnung/Invoice/pdf.py 471) _drawJustifiedString(left, y - font_height, line, canvas, right - left, font, my_font_size)
src/rechnung/Invoice/pdf.py 472) y -= line_height
src/rechnung/Invoice/pdf.py 473) canvas.drawString(left, y - font_height, lines[-1])
src/rechnung/Invoice/pdf.py 474) y -= line_height
src/rechnung/Invoice/pdf.py 475)
src/rechnung/Invoice/pdf.py 476) y -= line_padding * 3
src/rechnung/Invoice/pdf.py 477) left, right = leftcontent, rightcontent
|
GiroCode auf den Rechnungen
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/pdf.py 478) elif type(part) == Invoice.Image:
src/rechnung/Invoice/pdf.py 479) width = (part.imagedata.width / part.dpi) * inch
src/rechnung/Invoice/pdf.py 480) height = width * (part.imagedata.height / part.imagedata.width)
src/rechnung/Invoice/pdf.py 481) x = leftcontent
src/rechnung/Invoice/pdf.py 482) if part.alignment == "center":
src/rechnung/Invoice/pdf.py 483) x = leftcontent + (rightcontent - leftcontent)/2 - width/2
src/rechnung/Invoice/pdf.py 484) elif part.alignment == "right":
src/rechnung/Invoice/pdf.py 485) x = rightcontent - width
src/rechnung/Invoice/pdf.py 486) canvas.drawInlineImage(part.imagedata, x, y-height, width=width, height=height)
src/rechnung/Invoice/pdf.py 487) y -= line_padding + height
src/rechnung/Invoice/pdf.py 488) if part.caption:
src/rechnung/Invoice/pdf.py 489) canvas.drawString(x, y-font_height, part.caption)
src/rechnung/Invoice/pdf.py 490) y -= line_height
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 491) else:
|
automatische code-style-fixes
Bernd Wurst authored 5 years ago
|
src/rechnung/Invoice/pdf.py 492) raise NotImplementedError("Cannot handle part of type %s" % type(part))
src/rechnung/Invoice/pdf.py 493) y -= (0.5 * cm)
|
Struktur verändern (broken!)
Bernd Wurst authored 16 years ago
|
src/rechnung/Invoice/pdf.py 494)
|