e7bd56c75a8fa692b2edb24f94071c76ecfe020b
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

1) # -*- coding: utf-8 -*-
2) 
3) import os.path
4) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

5) from reportlab.lib.pagesizes import A4
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

6) from reportlab.lib.units import cm, inch
7) from reportlab.pdfbase import pdfmetrics
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

8) from reportlab.pdfbase.ttfonts import TTFont, TTFError
9) from reportlab.pdfgen import canvas
10) 
Bernd Wurst Alter Copyright-Hinweis ent...

Bernd Wurst authored 4 months ago

11) from . import _formatPrice
Bernd Wurst Intro-Text auch bei Korrekt...

Bernd Wurst authored 2 weeks ago

12) from .InvoiceObjects import InvoiceTable, InvoiceText, InvoiceImage, GUTSCHRIFT, KORREKTUR
Bernd Wurst Test-Script lauffähig

Bernd Wurst authored 4 months ago

13) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

14) 
15) def find_font_file(filename):
16)     for n in range(4):
17)         candidate = os.path.abspath(os.path.join(os.path.dirname(__file__), '../' * n, 'ressource/fonts', filename))
18)         if os.path.exists(candidate):
19)             return candidate
20) 
21) 
22) def _registerFonts():
23)     fonts = [
24)         ("DejaVu", "DejaVuSans.ttf"),
25)         ("DejaVu-Bold", "DejaVuSans-Bold.ttf"),
26)         ("DejaVu-Italic", "DejaVuSans-Oblique.ttf"),
27)         ("DejaVu-BoldItalic", "DejaVuSans-BoldOblique.ttf")
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

28)     ]
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

29)     for fontname, fontfile in fonts:
30)         found = False
31)         try:
32)             pdfmetrics.registerFont(TTFont(fontname, fontfile))
33)             found = True
34)         except TTFError:
35)             pass
36)         if not found:
37)             f = find_font_file(fontfile)
38)             if f:
39)                 pdfmetrics.registerFont(TTFont(fontname, f))
40) 
41) 
42) class PDF(object):
43)     # Set default font size
44)     default_font_size = 8
45)     font = 'DejaVu'
46)     # set margins
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

47)     topmargin = 2 * cm
48)     bottommargin = 2.2 * cm
49)     leftmargin = 2 * cm
50)     rightmargin = 2 * cm
51)     rightcolumn = 13 * cm
52) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

53)     canvas = None
54)     num_pages = 1
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

55)     font_height = 0.3 * cm
56)     line_padding = 0.1 * cm
57)     line_height = font_height + 0.1 * cm
58) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

59)     invoice = None
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

60) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

61)     def __init__(self, invoice):
62)         _registerFonts()
63)         from io import BytesIO
64)         self.fd = BytesIO()
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

65)         self.canvas = canvas.Canvas(self.fd, pagesize=A4)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

66) 
67)         self.invoice = invoice
68) 
69)         self.topcontent = -self.topmargin
70)         self.leftcontent = self.leftmargin
71)         self.rightcontent = A4[0] - self.rightmargin
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

72)         self.bottomcontent = -(A4[1] - self.bottommargin)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

73) 
74)         self.font_size = 8
75)         self.x = 2.0 * cm
76)         self.y = -4.8 * cm - self.font_size - 1
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

77) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

78)         self.canvas.setFont(self.font, self.font_size)
79) 
80)     def _splitToWidth(self, text, width, font, size):
81)         '''_splitToWidth(canvas, text, width, font, size)
82)         Split a string to several lines of a given width.'''
83)         lines = []
84)         paras = text.split('\n')
85)         for para in paras:
86)             words = para.split(' ')
87)             while len(words) > 0:
88)                 mywords = [words[0], ]
89)                 del words[0]
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

90)                 while len(words) > 0 and self.canvas.stringWidth(' '.join(mywords) + ' ' + words[0], font,
91)                                                                  size) <= width:
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

92)                     mywords.append(words[0])
93)                     del words[0]
94)                 lines.append(' '.join(mywords))
95)         return lines
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

96) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

97)     def _PageMarkers(self):
98)         """Setzt Falzmarken"""
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

99)         self.canvas.setStrokeColor((0, 0, 0))
100)         self.canvas.setLineWidth(0.01 * cm)
101)         self.canvas.lines([(0.3 * cm, -10.5 * cm, 0.65 * cm, -10.5 * cm),
102)                            (0.3 * cm, -21.0 * cm, 0.65 * cm, -21.0 * cm),
103)                            (0.3 * cm, -14.85 * cm, 0.7 * cm, -14.85 * cm)])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

104) 
105)     def _lineHeight(self, fontsize=None, font=None):
106)         if not fontsize:
107)             fontsize = self.default_font_size
108)         if not font:
109)             font = self.font
110)         face = pdfmetrics.getFont(font).face
111)         string_height = (face.ascent - face.descent) / 1000 * fontsize
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

112)         return string_height + 0.1 * cm
113) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

114)     def _partHeight(self, part):
115)         height = 0
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

116)         if isinstance(part, InvoiceText):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

117)             left, right = self.leftcontent, self.rightcontent
118)             if part.urgent:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

119)                 left += 1.5 * cm
120)                 right -= 1.5 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

121)                 height += len(part.paragraphs) * 3 * self.line_padding
122)                 # Rechne eine Zeile mehr für den Rahmen
123)                 height += self.line_height
124)             if part.headline:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

125)                 height += (len(self._splitToWidth(part.headline, right - left, self.font + '-Bold',
126)                                                   self.default_font_size + 1)) * self.line_height) + self.line_padding
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

127)             for para in part.paragraphs:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

128)                 height += (len(self._splitToWidth(para, right - left, self.font,
129)                                                   self.default_font_size)) * self.line_height) + self.line_padding
130)         elif isinstance(part, InvoiceTable):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

131)             # Eine Zeile plus 2 mal line_padding für Tabellenkopf
132)             height = self.line_height + 2 * self.line_padding
133)             # Wenn nur ein Element (plus Summen) hin passt, reicht uns das
134)             el = part.entries[0]
135)             # Die Abstände oben und unten
136)             height += 2 * self.line_padding
137)             # Die Breite ist konservativ
138)             if el['type'] == 'title':
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

139)                 height += self.line_height + 0.2 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

140)             else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

141)                 height += self.line_height * len(self._splitToWidth(el['subject'], 9.3 * cm, self.font, self.font_size))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

142)             if 'desc' in el and el['desc'] != '':
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

143)                 height += self.line_height * len(self._splitToWidth(el['desc'], 11 * cm, self.font, self.font_size))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

144)             if part.vatType == 'net':
145)                 # Eine Zeile mehr
146)                 height += self.line_height + self.line_padding
147)             # Für die MwSt-Summen
148)             height += (self.line_height + self.line_padding) * len(part.vat)
149)             # Für den Rechnungsbetrag
150)             height += self.line_height + self.line_padding
151)         return height
152) 
153)     def _tableHead(self, part):
154)         self.canvas.setFont(self.font, self.font_size)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

155)         self.canvas.drawString(self.leftcontent + (0.1 * cm), self.y - self.line_height + self.line_padding, 'Anz.')
156)         self.canvas.drawString(self.leftcontent + (2.1 * cm), self.y - self.line_height + self.line_padding,
157)                                'Beschreibung')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

158)         if len(part.vat) == 1:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

159)             self.canvas.drawRightString(self.leftcontent + (14.3 * cm), self.y - self.line_height + self.line_padding,
160)                                         'Einzelpreis')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

161)         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

162)             self.canvas.drawRightString(self.leftcontent + (13.3 * cm), self.y - self.line_height + self.line_padding,
163)                                         'Einzelpreis')
164)         self.canvas.drawRightString(self.leftcontent + (16.8 * cm), self.y - self.line_height + self.line_padding,
165)                                     'Gesamtpreis')
166)         self.canvas.setLineWidth(0.01 * cm)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

167)         self.canvas.line(self.leftcontent, self.y - self.line_height, self.rightcontent, self.y - self.line_height)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

168)         self.y -= self.line_height + 0.02 * cm
169) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

170)     def _PageWrap(self):
171)         '''Seitenumbruch'''
172)         self.num_pages += 1
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

173)         self.canvas.setFont(self.font, self.default_font_size - 2)
174)         self.canvas.drawRightString(self.rightcontent, self.bottomcontent + self.line_padding,
175)                                     'Fortsetzung auf Seite %i' % self.num_pages)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

176)         self.canvas.showPage()
177)         self.basicPage()
178)         self.y = self.topcontent - self.font_size
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

179)         self.canvas.setFillColor((0, 0, 0))
180)         self.canvas.setFont(self.font, self.font_size - 2)
181)         self.canvas.drawCentredString(self.leftcontent + (self.rightcontent - self.leftcontent) / 2, self.y,
182)                                       '- Seite %i -' % self.num_pages)
183) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

184)     def _Footer(self):
185)         self.canvas.setStrokeColor((0, 0, 0))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

186)         self.canvas.setFillColor((0, 0, 0))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

187)         self.canvas.line(self.leftcontent, self.bottomcontent, self.rightcontent, self.bottomcontent)
188)         self.canvas.setFont(self.font, 7)
189)         lines = list(filter(None, [
190)             self.invoice.seller['trade_name'],
191)             self.invoice.seller['name'] if self.invoice.seller['trade_name'] else None,
192)             self.invoice.seller['website'],
193)             self.invoice.seller['email'],
194)         ]))
195)         c = 0
196)         for line in lines:
197)             c += 10
198)             self.canvas.drawString(self.leftcontent, self.bottomcontent - c, line)
199) 
200)         if self.invoice.seller_vat_id:
201)             lines = list(filter(None, [
202)                 "USt-ID: " + self.invoice.seller_vat_id
203)             ]))
204)             c = 0
205)             for line in lines:
206)                 c += 10
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

207)                 self.canvas.drawString(self.leftcontent + ((self.rightcontent - self.leftcontent) // 3),
208)                                        self.bottomcontent - c, line)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

209) 
Bernd Wurst allow for IBAN to be not set

Bernd Wurst authored 4 months ago

210)         if self.invoice.seller_bank_data['iban'] and not self.invoice.debit:
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

211)             iban = self.invoice.seller_bank_data['iban']
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

212)             iban = ' '.join([iban[i:i + 4] for i in range(0, len(iban), 4)])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

213)             lines = [
214)                 f"IBAN: {iban}",
215)                 self.invoice.seller_bank_data['bankname'],
Bernd Wurst Kleine Korrekturen, mache B...

Bernd Wurst authored 4 months ago

216)                 f"BIC: {self.invoice.seller_bank_data['bic']}" if self.invoice.seller_bank_data['bic'] else None,
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

217)             ]
218)             c = 0
219)             for line in lines:
220)                 c += 10
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

221)                 self.canvas.drawString(self.leftcontent + ((self.rightcontent - self.leftcontent) // 3) * 2,
222)                                        self.bottomcontent - c, line)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

223) 
224)     def basicPage(self):
225)         # Set marker to top.
226)         self.canvas.translate(0, A4[1])
227) 
228)         self._PageMarkers()
229)         self._Footer()
230) 
231)     def addressBox(self):
232)         lines = [
233)             self.invoice.seller['trade_name'],
234)             self.invoice.seller['address']['line1'],
235)             self.invoice.seller['address']['line2'],
236)             self.invoice.seller['address']['line3'],
237)             self.invoice.seller['address']['postcode'] + ' ' + self.invoice.seller['address']['city_name'],
238)         ]
239)         address = ' · '.join(filter(None, lines))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

240)         self.canvas.drawString(self.x, self.y + 0.1 * cm, f' {address}')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

241)         self.canvas.line(self.x, self.y, self.x + (8.5 * cm), self.y)
242)         self.y = self.y - self.font_size - 3
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

243) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

244)         font_size = 11
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

245)         x = self.x + 0.5 * cm
246)         self.y -= 0.5 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

247)         self.canvas.setFont(self.font, font_size)
248)         addresslines = filter(None, [
249)             self.invoice.customer['name'].strip(),
250)             self.invoice.customer['address']['line1'] or '',
251)             self.invoice.customer['address']['line2'] or '',
252)             self.invoice.customer['address']['line3'] or '',
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

253)             ((self.invoice.customer['address']['postcode'] or '') + ' ' + (
254)                     self.invoice.customer['address']['city_name'] or '')).strip(),
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

255)         ])
256)         for line in addresslines:
257)             self.canvas.drawString(x, self.y, line)
258)             self.y -= font_size * 0.03527 * cm * 1.2
259) 
260)     def firstPage(self):
261)         self.basicPage()
262)         self.addressBox()
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

263) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

264)         self.y = self.topcontent
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

265)         self.canvas.drawImage(self.invoice.logo_image_file, self.rightcolumn, self.topcontent - (2 * cm),
266)                               height=2 * cm, preserveAspectRatio=True, anchor='nw')
267)         self.y -= (2.5 * cm)
268)         self.canvas.setFont(self.font + "-Bold", self.font_size)
269)         self.canvas.drawString(self.rightcolumn, self.y,
270)                                self.invoice.seller['trade_name'] or self.invoice.seller['name'])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

271)         self.y -= (self.font_size + 5)
272)         self.canvas.setFont(self.font, self.font_size)
273)         lines = [
274)             self.invoice.seller['name'] if self.invoice.seller['trade_name'] else None,
275)             self.invoice.seller['address']['line1'],
276)             self.invoice.seller['address']['line2'],
277)             self.invoice.seller['address']['line3'],
278)             self.invoice.seller['address']['postcode'] + ' ' + self.invoice.seller['address']['city_name'],
279)             self.invoice.seller['website'],
280)         ]
281)         address = filter(None, lines)
282)         for line in address:
283)             self.canvas.drawString(self.rightcolumn, self.y, line)
284)             self.y -= (self.font_size + 5)
285)         self.y -= 5
Bernd Wurst WiP

Bernd Wurst authored 4 months ago

286)         if self.invoice.seller['phone']:
287)             self.canvas.drawString(self.rightcolumn, self.y, f"Tel: {self.invoice.seller['phone']}")
288)             self.y -= (self.font_size + 5)
289)         if self.invoice.seller['email']:
290)             self.canvas.drawString(self.rightcolumn, self.y, f"E-Mail: {self.invoice.seller['email']}")
291)             self.y -= (self.font_size + 10)
Bernd Wurst Überschrift unter Datum und...

Bernd Wurst authored 4 months ago

292)         self.y = -8.5 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

293) 
294)     def title(self, title):
295)         self.canvas.setTitle(title)
296)         self.canvas.drawString(self.leftcontent, self.y, title)
297) 
298)     def renderRechnung(self):
299)         self.firstPage()
300)         if self.invoice.tender:
301)             self.canvas.setFont(self.font, self.font_size)
302)             self.canvas.drawString(self.rightcolumn, self.y, "Erstellungsdatum:")
303)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.date.strftime('%d. %m. %Y'))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

304)             self.y -= (self.font_size + 0.1 * cm)
Bernd Wurst allow for type=None (genera...

Bernd Wurst authored 4 months ago

305)         elif self.invoice.type:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

306)             self.canvas.setFont(self.font + '-Bold', self.font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

307)             self.canvas.drawString(self.rightcolumn, self.y, "Bei Fragen bitte immer angeben:")
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

308)             self.y -= (self.font_size + 0.2 * cm)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

309)             self.canvas.setFont(self.font, self.font_size)
310)             self.canvas.drawString(self.rightcolumn, self.y, "Rechnungsdatum:")
311)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.date.strftime('%d. %m. %Y'))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

312)             self.y -= (self.font_size + 0.1 * cm)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

313)             self.canvas.drawString(self.rightcolumn, self.y, "Rechnungsnummer:")
314)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.id)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

315)             self.y -= (self.font_size + 0.1 * cm)
Bernd Wurst allow for type=None (genera...

Bernd Wurst authored 4 months ago

316)         else:
Bernd Wurst allow for type=None (genera...

Bernd Wurst authored 4 months ago

317)             self.canvas.setFont(self.font, self.font_size)
Bernd Wurst allow for type=None (genera...

Bernd Wurst authored 4 months ago

318)             self.canvas.drawString(self.rightcolumn, self.y, "Datum:")
319)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.date.strftime('%d. %m. %Y'))
320)             self.y -= (self.font_size + 0.1 * cm)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

321)         if self.invoice.customerno:
322)             self.canvas.drawString(self.rightcolumn, self.y, "Kundennummer:")
323)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.customerno)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

324)             self.y -= (self.font_size + 0.5 * cm)
Bernd Wurst Referenznummern auf allen A...

Bernd Wurst authored 4 months ago

325)         if self.invoice.leitweg_id:
326)             self.canvas.drawString(self.rightcolumn, self.y, "Leitweg-ID:")
327)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.leitweg_id)
328)             self.y -= (self.font_size + 0.1 * cm)
329)         if self.invoice.buyer_reference:
330)             self.canvas.drawString(self.rightcolumn, self.y, "Kunden-Referenz:")
331)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.buyer_reference)
332)             self.y -= (self.font_size + 0.1 * cm)
333)         if self.invoice.contract_number:
334)             self.canvas.drawString(self.rightcolumn, self.y, "Vertragsnummer:")
335)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.contract_number)
336)             self.y -= (self.font_size + 0.1 * cm)
337)         if self.invoice.order_number:
338)             self.canvas.drawString(self.rightcolumn, self.y, "Ihre Bestellnummer:")
339)             self.canvas.drawRightString(self.rightcontent, self.y, "%s" % self.invoice.order_number)
340)             self.y -= (self.font_size + 0.1 * cm)
Bernd Wurst Überschrift unter Datum und...

Bernd Wurst authored 4 months ago

341)         self.canvas.setFont(self.font + '-Bold', self.font_size + 3)
342)         self.title(self.invoice.title)
343)         self.y -= self.font_size + 3 + 0.3 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

344)         self.canvas.setFont(self.font, self.font_size)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

345) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

346)         if self.invoice.salutation:
347)             self.canvas.drawString(self.leftcontent, self.y, self.invoice.salutation)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

348)             self.y -= self.font_size + 0.2 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

349)             introText = 'hiermit stellen wir Ihnen die nachfolgend genannten Leistungen in Rechnung.'
350)             if self.invoice.tender:
351)                 introText = 'hiermit unterbreiten wir Ihnen folgendes Angebot.'
Bernd Wurst Intro-Text auch bei Korrekt...

Bernd Wurst authored 2 weeks ago

352)             if self.invoice.type in (GUTSCHRIFT, KORREKTUR):
Bernd Wurst WiP

Bernd Wurst authored 4 months ago

353)                 introText = 'nach unserer Berechnung entsteht für Sie folgende Gutschrift.'
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

354)             intro = self._splitToWidth(introText, self.rightcontent - self.leftcontent, self.font, self.font_size)
355)             for line in intro:
356)                 self.canvas.drawString(self.leftcontent, self.y, line)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

357)                 self.y -= self.font_size + 0.1 * cm
358)             self.y -= self.font_size + 0.1 * cm
359) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

360)         font_size = self.default_font_size
361)         for part in self.invoice.parts:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

362)             if self.y - self._partHeight(part) < (self.bottomcontent + (0.5 * cm)):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

363)                 self._PageWrap()
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

364)                 self.y = self.topcontent - self.font_size - self.line_padding * 3
365)             if isinstance(part, InvoiceTable):
366) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

367)                 left = self.leftcontent
368)                 right = self.rightcontent
369)                 self._tableHead(part)
370)                 temp_sum = 0.0
371)                 odd = True
372)                 for el in part.entries:
373)                     if el['type'] == 'title':
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

374)                         self.y -= self.line_padding + 0.2 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

375)                         self.canvas.setFillColorRGB(0, 0, 0)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

376)                         self.canvas.setFont(self.font + '-Italic', font_size)
377)                         self.canvas.drawString(left, self.y - self.font_height, el['title'])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

378)                         self.canvas.setFont(self.font, font_size)
379)                         self.y -= self.line_height + self.line_padding
380)                     else:
381)                         if len(part.vat) == 1:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

382)                             subject = self._splitToWidth(el['subject'], 9.8 * cm, self.font, font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

383)                         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

384)                             subject = self._splitToWidth(el['subject'], 8.8 * cm, self.font, font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

385)                         desc = []
386)                         if 'desc' in el and el['desc'] != '':
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

387)                             desc = self._splitToWidth(el['desc'], 14.0 * cm, self.font, font_size)
Bernd Wurst Neuer Parameter 'print_date...

Bernd Wurst authored 1 month ago

388)                         if 'print_date' in el and el['print_date']:
389)                             if 'period_start' in el and el['period_start']:
390)                                 if 'period_end' in el and el['period_end']:
391)                                     desc.extend(self._splitToWidth('Leistungszeitraum: %s - %s' %
392)                                                                    (el['period_start'].strftime('%d.%m.%Y'),
393)                                                                     el['period_end'].strftime('%d.%m.%Y')),
394)                                                                    14.0 * cm, self.font, font_size))
395)                                 else:
396)                                     desc.extend(self._splitToWidth('Leistungsdatum: %s' %
397)                                                                    (el['period_start'].strftime('%d.%m.%Y'),),
398)                                                                    14.0 * cm, self.font, font_size))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

399)                         need_lines = len(subject) + len(desc)
400)                         # need page wrap?
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

401)                         if self.y - (need_lines + 1 * (self.line_height + self.line_padding)) < (
402)                                 self.bottomcontent + 1 * cm):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

403)                             self.canvas.setFont(self.font + '-Italic', font_size)
404)                             # Zwischensumme
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

405)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Zwischensumme:')
406)                             self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height,
407)                                                         _formatPrice(temp_sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

408)                             # page wrap
409)                             self._PageWrap()
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

410)                             self.y = self.topcontent - font_size - self.line_padding * 3
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

411)                             # header
412)                             self._tableHead(part)
413)                             self.y -= self.line_padding * 3
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

414)                             odd = True
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

415)                             # übertrag
416)                             self.canvas.setFont(self.font + '-Italic', font_size)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

417)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Übertrag:')
418)                             self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height,
419)                                                         _formatPrice(temp_sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

420)                             self.y -= self.font_height + self.line_padding * 3
421)                             self.canvas.setFont(self.font, self.default_font_size)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

422) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

423)                         # Zwischensumme (inkl. aktueller Posten)
424)                         temp_sum += el['total']
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

425) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

426)                         # draw the background
427)                         if not odd:
428)                             self.canvas.setFillColorRGB(0.9, 0.9, 0.9)
429)                         else:
430)                             self.canvas.setFillColorRGB(1, 1, 1)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

431)                         self.canvas.rect(left, self.y - (need_lines * self.line_height) - (2 * self.line_padding),
432)                                          height=(need_lines * self.line_height) + (2 * self.line_padding),
433)                                          width=right - left, fill=1, stroke=0)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

434)                         self.canvas.setFillColorRGB(0, 0, 0)
435)                         self.y -= self.line_padding
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

436)                         self.canvas.drawRightString(left + 1.1 * cm, self.y - self.font_height, '%.0f' % el['count'])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

437)                         if el['unit']:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

438)                             self.canvas.drawString(left + 1.2 * cm, self.y - self.font_height, el['unit'])
439)                         self.canvas.drawString(left + 2.2 * cm, self.y - self.font_height, subject[0])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

440)                         if len(part.vat) == 1:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

441)                             self.canvas.drawRightString(left + 14.3 * cm, self.y - self.font_height,
442)                                                         _formatPrice(el['price']))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

443)                         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

444)                             self.canvas.drawRightString(left + 13.3 * cm, self.y - self.font_height,
445)                                                         _formatPrice(el['price']))
446)                             self.canvas.drawString(left + 13.7 * cm, self.y - self.font_height,
447)                                                    str(part.vat[el['vat']][1]))
448)                         if el['tender']:
449)                             self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, 'eventual')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

450)                         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

451)                             self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height,
452)                                                         _formatPrice(el['total']))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

453)                         subject = subject[1:]
454)                         x = 1
455)                         for line in subject:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

456)                             self.canvas.drawString(left + 2.2 * cm, self.y - (x * self.line_height) - self.font_height,
457)                                                    line)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

458)                             x += 1
459)                         for line in desc:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

460)                             self.canvas.drawString(left + 2.2 * cm, self.y - (x * self.line_height) - self.font_height,
461)                                                    line)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

462)                             x += 1
463)                         odd = not odd
464)                         self.y -= (need_lines * self.line_height) + self.line_padding
465)                 if part.summary:
466)                     need_lines = 5
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

467)                     if self.y - (need_lines + 1 * (self.line_height + self.line_padding)) < (
468)                             self.bottomcontent + 1 * cm):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

469)                         self.canvas.setFont(self.font + '-Italic', font_size)
470)                         # Zwischensumme
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

471)                         self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Zwischensumme:')
472)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, _formatPrice(temp_sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

473)                         # page wrap
474)                         self._PageWrap()
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

475)                         self.y = self.topcontent - font_size - self.line_padding * 3
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

476)                         # header
477)                         self._tableHead(part)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

478)                         odd = True
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

479)                         # übertrag
480)                         self.canvas.setFont(self.font + '-Italic', font_size)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

481)                         self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Übertrag:')
482)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, _formatPrice(temp_sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

483)                         self.y -= self.font_height + self.line_padding
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

484)                     self.y -= (0.3 * cm)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

485)                     if part.vatType == 'gross':
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

486)                         self.canvas.setFont(self.font + '-Bold', font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

487)                         if self.invoice.tender or not self.invoice.official:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

488)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Gesamtbetrag:')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

489)                         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

490)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Rechnungsbetrag:')
491)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, _formatPrice(part.sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

492)                         if self.invoice.official:
493)                             self.canvas.setFont(self.font, font_size)
494)                             self.y -= self.line_height + self.line_padding
495)                             summaries = []
496)                             vat = 0.0
497)                             if len(part.vat) == 1 and list(part.vat.keys())[0] == 0.0:
498)                                 self.canvas.drawString(left, self.y - self.font_height,
499)                                                        'Dieser Beleg wurde ohne Ausweis von MwSt erstellt.')
500)                                 self.y -= self.line_height
501)                             else:
502)                                 if len(part.vat) == 1:
503)                                     vat = list(part.vat.keys())[0]
504)                                     if self.invoice.tender:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

505)                                         summaries.append(('Im Gesamtbetrag sind %.1f%% MwSt enthalten:' % (vat * 100),
506)                                                           _formatPrice((part.sum / (vat + 1)) * vat)))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

507)                                     else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

508)                                         summaries.append((
509)                                             'Im Rechnungsbetrag sind %.1f%% MwSt enthalten:' % (vat * 100),
510)                                             _formatPrice((part.sum / (vat + 1)) * vat)))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

511)                                 else:
512)                                     for vat, vatdata in part.vat.items():
513)                                         if vat > 0:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

514)                                             summaries.append(('%s: Im Teilbetrag von %s sind %.1f%% MwSt enthalten:' % (
515)                                                 vatdata[1], _formatPrice(vatdata[0]), vat * 100),
516)                                                               _formatPrice((vatdata[0] / (vat + 1)) * vat)))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

517)                                         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

518)                                             summaries.append(('%s: Durchlaufende Posten ohne Berechnung von MwSt.' % (
519)                                                 vatdata[1]), 0.0))
520)                             summaries.append(('Nettobetrag:', _formatPrice(part.sum - (part.sum / (vat + 1)) * vat)))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

521)                             summaries.sort()
522)                             for line in summaries:
Bernd Wurst Unwichtige Summen etwas nac...

Bernd Wurst authored 1 week ago

523)                                 self.canvas.drawRightString(left + 11.5 * cm, self.y - self.font_height, '('+line[0])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

524)                                 if line[1]:
Bernd Wurst Unwichtige Summen etwas nac...

Bernd Wurst authored 1 week ago

525)                                     self.canvas.drawRightString(left + 13.8 * cm, self.y - self.font_height, line[1]+')')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

526)                                 self.y -= self.line_height
527)                     elif len(part.vat) == 1 and part.vatType == 'net':
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

528)                         self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Nettobetrag:')
529)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, _formatPrice(part.sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

530)                         self.y -= self.line_height
531)                         summaries = []
532)                         if list(part.vat.keys())[0] == 0.0:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

533)                             self.canvas.drawString(left, self.y - self.font_height,
534)                                                    'Dieser Beleg wurde ohne Ausweis von MwSt erstellt.')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

535)                             self.y -= self.line_height
536)                         else:
537)                             if len(part.vat) == 1:
538)                                 vat = list(part.vat.keys())[0]
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

539)                                 summaries.append(('zzgl. %.1f%% MwSt:' % (vat * 100), _formatPrice(vat * part.sum)))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

540)                             else:
541)                                 for vat, vatdata in part.vat.items():
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

542)                                     summaries.append(('zzgl. %.1f%% MwSt (%s):' % (vat * 100, vatdata[1]),
543)                                                       _formatPrice(vat * vatdata[0])))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

544)                         summaries.sort()
545)                         for line in summaries:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

546)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, line[0])
547)                             self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, line[1])
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

548)                             self.y -= self.line_height
549)                         sum = 0
550)                         for vat, vatdata in part.vat.items():
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

551)                             sum += (vat + 1) * vatdata[0]
552)                         self.canvas.setFont(self.font + '-Bold', font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

553)                         if self.invoice.tender:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

554)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Gesamtbetrag:')
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

555)                         else:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

556)                             self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, 'Rechnungsbetrag:')
557)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, _formatPrice(sum))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

558)                         self.canvas.setFont(self.font, font_size)
559)                         self.y -= self.line_height + self.line_padding
560)                     paysum = 0.0
561)                     for pay in part.payments:
562)                         paysum += pay['amount']
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

563)                         descr = 'Zahlung'
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

564)                         if pay['type'] == 'cash':
565)                             descr = 'gegeben'
566)                         elif pay['type'] == 'return':
567)                             descr = 'zurück'
568)                         elif pay['type'] == 'ec':
569)                             descr = 'Kartenzahlung (EC)'
570)                         elif pay['type'] == 'gutschein':
571)                             descr = 'Einlösung Gutschein'
572)                         if pay['date'] != self.invoice.date:
573)                             descr += ' am %s' % (pay['date'].strftime('%d. %m. %Y'))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

574)                         self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height, descr + ':')
575)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height,
576)                                                     _formatPrice(pay['amount']))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

577)                         self.y -= self.line_height
578)                     sum = part.sum
579)                     if part.vatType == 'net':
580)                         sum = 0
581)                         for vat, vatdata in part.vat.items():
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

582)                             sum += (vat + 1) * vatdata[0]
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

583)                     rest = sum - paysum
584)                     if part.payments and rest > 0:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

585)                         self.canvas.setFont(self.font + '-Bold', font_size)
586)                         self.canvas.drawRightString(left + 14.5 * cm, self.y - self.font_height,
587)                                                     'Offener Rechnungsbetrag:')
588)                         self.canvas.drawRightString(left + 16.8 * cm, self.y - self.font_height, _formatPrice(rest))
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

589)                         self.canvas.setFont(self.font, font_size)
590)                         self.y -= self.line_height + self.line_padding
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

591) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

592)                     self.y -= self.line_padding
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

593)             elif isinstance(part, InvoiceText):
594)                 my_font_size = font_size + part.fontsize  # Relative Schriftgröße beachten
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

595)                 self.canvas.setFont(self.font, my_font_size)
596)                 left, right = self.leftcontent, self.rightcontent
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

597)                 indent = 0
598)                 if part.indent:
599)                     if isinstance(part.indent, bool):
600)                         indent = 2 * cm
601)                     else:
602)                         indent = part.indent * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

603)                 firsttime = True
604)                 headlines = []
605)                 if part.urgent:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

606)                     left += 1.5 * cm
607)                     right -= 1.5 * cm
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

608)                 if part.headline:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

609)                     headlines = self._splitToWidth(part.headline, right - left, self.font, my_font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

610)                 for para in part.paragraphs:
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

611)                     lines = self._splitToWidth(para, right - left - indent, self.font, my_font_size)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

612)                     if part.urgent:
613)                         need_height = len(lines) * self._lineHeight(my_font_size)
614)                         if len(headlines) > 0:
615)                             need_height += len(headlines) * (self._lineHeight(my_font_size) + 1) + self.line_padding
616)                         self.canvas.setFillColorRGB(0.95, 0.95, 0.95)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

617)                         self.canvas.rect(left - 0.5 * cm, self.y - (need_height + (6 * self.line_padding)),
618)                                          height=need_height + (6 * self.line_padding), width=right - left + 1 * cm,
619)                                          fill=1, stroke=1)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

620)                         self.canvas.setFillColorRGB(0, 0, 0)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

621)                         self.y -= self.line_padding * 3
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

622)                     if part.headline and firsttime:
623)                         firsttime = False
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

624)                         self.canvas.setFont(self.font + '-Bold', my_font_size + 1)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

625)                         for line in headlines:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

626)                             self.canvas.drawString(left, self.y - (self.font_height + 1), line)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

627)                             self.y -= self._lineHeight(my_font_size) + 1
628)                         self.y -= self.line_padding
629)                         self.canvas.setFont(self.font, my_font_size)
630)                     for line in lines:
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

631)                         self.canvas.drawString(left + indent, self.y - self.font_height, line)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

632)                         self.y -= self._lineHeight(my_font_size)
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

633)                     self.y -= self.line_padding * 3
634)             elif isinstance(part, InvoiceImage):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

635)                 width = (part.imagedata.width / part.dpi) * inch
636)                 height = width * (part.imagedata.height / part.imagedata.width)
637)                 x = self.leftcontent
638)                 if part.alignment == "center":
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

639)                     x = self.leftcontent + (self.rightcontent - self.leftcontent) / 2 - width / 2
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

640)                 elif part.alignment == "right":
641)                     x = self.rightcontent - width
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

642)                 self.canvas.drawInlineImage(part.imagedata, x, self.y - height, width=width, height=height)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

643)                 self.y -= self.line_padding + height
644)                 if part.caption:
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

645)                     self.canvas.drawString(x, self.y - self.font_height, part.caption)
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

646)                     self.y -= self._lineHeight()
647)             else:
648)                 raise NotImplementedError("Cannot handle part of type %s" % type(part))
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

649)             self.y -= (0.5 * cm)
650)