From 0ea90b704c358920d76f3426a3500fc9bd64d744 Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Tue, 20 Sep 2022 14:16:37 +0200 Subject: [PATCH] refactor bill pdf code --- tools/pdf_generator.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/pdf_generator.py b/tools/pdf_generator.py index fff9f24..0a9fc11 100644 --- a/tools/pdf_generator.py +++ b/tools/pdf_generator.py @@ -504,7 +504,6 @@ class BillPaper(PDFDocument): self.style = self.styles["BodyText"] self.add_header(contract) - self.y = Y - 125 self.add_bill_title(contract) self.add_prestations(contract) self.add_conclusion(contract) @@ -520,20 +519,20 @@ class BillPaper(PDFDocument): Returns: ne retourne rien """ + self.y = 650 text = (("" + contract.client.name + "") if contract.client.is_company else "") + "
" + "A l'attention de " + contract.client.contact + "
" + contract.client.address + "
" + str(contract.client.postal_code) + " " + contract.client.city + "

Concernant la/le " + contract.title + "" paragraph = Paragraph(text, self.style) - width, height = paragraph.wrap(10*cm, 10*cm) - paragraph.drawOn(self.document, TITLED_X, self.y - height) - self.add_vspace(-height * 1.25) + paragraph.drawOn(self.document, TITLED_X, self.y) + self.add_vspace(BIG_LINE_HEIGHT) def __add_section_title(self, title_text): """ Ajout le titre d'une section """ text = "" + title_text + "" paragraph = Paragraph(text, self.style) - width, height = paragraph.wrap(8*cm, self.y) - paragraph.drawOn(self.document, INDENTED_X, self.y - height) + width, height = paragraph.wrap(8*cm, 8*cm) + paragraph.drawOn(self.document, INDENTED_X, self.y) self.add_vspace(-height) def add_prestations(self, contract): @@ -580,8 +579,8 @@ class BillPaper(PDFDocument): ) table = Table(data, [2.6*cm, 8.2*cm, 2.6*cm, 2.6*cm, 2.6*cm]) table.setStyle(style) - width, height = table.wrapOn(self.document, X, self.y) - self.add_vspace(-height - 5) + width, height = table.wrapOn(self.document, 19*cm, 15*cm) + self.add_vspace(-(9 * height / 10)) table.drawOn(self.document, X, self.y) self.add_vspace(-height / 3) @@ -653,7 +652,6 @@ class BillPaper(PDFDocument): """ Ajoute les conditions générales de payement au bas de la facture """ self.y = 125 self.__add_section_title("Conditions générales de paiement") - self.add_vspace() lines = [ "Facture payable au comptant.",