Update bill factory
This commit is contained in:
parent
3eceee4a65
commit
de004043c3
|
@ -504,13 +504,13 @@ class BillPaper(PDFDocument):
|
|||
self.style = self.styles["BodyText"]
|
||||
|
||||
self.add_header(contract)
|
||||
self.add_title(contract)
|
||||
self.add_bill_title(contract)
|
||||
self.add_prestations(contract)
|
||||
self.add_conclusion(contract)
|
||||
self.add_signature()
|
||||
self.add_footer()
|
||||
self.add_terms_of_sales()
|
||||
|
||||
def add_title(self, contract):
|
||||
def add_bill_title(self, contract):
|
||||
""" Génère le titre de la facture.
|
||||
|
||||
Args:
|
||||
|
@ -519,7 +519,9 @@ class BillPaper(PDFDocument):
|
|||
Returns:
|
||||
ne retourne rien
|
||||
"""
|
||||
text = "A l'attention de <b>" + contract.client.contact + "</b><br />" + (("Pour <b>" + contract.client.name + "</b>") if contract.client.is_company else "") + "<br />" + contract.client.address + "<br />" + str(contract.client.postal_code) + " " + contract.client.city + "<br /><br />Concernant la/le <b>" + contract.title + "</b>"
|
||||
# text = "A l'attention de <b>" + contract.client.contact + "</b><br />" + (contract.client.name if contract.client.is_company else "") + "<br />" + contract.client.address + "<br />" + str(contract.client.postal_code) + " " + contract.client.city + "<br /><br />Concernant la/le <b>" + contract.title + "</b>"
|
||||
|
||||
text = (("<b>" + contract.client.name + "</b>") if contract.client.is_company else "") + "<br />" + "A l'attention de <b>" + contract.client.contact + "</b><br />" + contract.client.address + "<br />" + str(contract.client.postal_code) + " " + contract.client.city + "<br /><br />Concernant la/le <b>" + contract.title + "</b>"
|
||||
|
||||
paragraph = Paragraph(text, self.style)
|
||||
|
||||
|
@ -527,6 +529,14 @@ class BillPaper(PDFDocument):
|
|||
paragraph.drawOn(self.document, 6*cm, self.y - height)
|
||||
self.add_vspace(-height * 1.25)
|
||||
|
||||
def __add_section_title(self, title_text):
|
||||
""" Ajout le titre d'une section """
|
||||
text = "<b>" + title_text + "</b>"
|
||||
paragraph = Paragraph(text, self.style)
|
||||
width, height = paragraph.wrap(6*cm, self.y)
|
||||
paragraph.drawOn(self.document, INDENTED_X, self.y - height)
|
||||
self.add_vspace(-height)
|
||||
|
||||
def add_prestations(self, contract):
|
||||
""" Génère l'affichage des prestations : tableau, liste des prestations, …
|
||||
|
||||
|
@ -536,11 +546,7 @@ class BillPaper(PDFDocument):
|
|||
Returns:
|
||||
ne retourne rien.
|
||||
"""
|
||||
text = "<b>Prestations</b>"
|
||||
paragraph = Paragraph(text, self.style)
|
||||
width, height = paragraph.wrap(6*cm, self.y)
|
||||
paragraph.drawOn(self.document, INDENTED_X, self.y - height)
|
||||
self.add_vspace(-height)
|
||||
self.__add_section_title("Prestations")
|
||||
|
||||
total = 0
|
||||
elements = []
|
||||
|
@ -616,7 +622,7 @@ class BillPaper(PDFDocument):
|
|||
|
||||
if not contract.is_paid:
|
||||
the_date = datetime.now()
|
||||
pay_date = the_date + timedelta(days=15)
|
||||
pay_date = the_date + timedelta(days=25)
|
||||
self.add_string(INDENTED_X, "Pour le ")
|
||||
space = len("Pour le ")
|
||||
date = str(pay_date.day) + "/" + str(pay_date.month) + "/" + str(pay_date.year)
|
||||
|
@ -643,14 +649,11 @@ class BillPaper(PDFDocument):
|
|||
self.add_vspace(DOUBLE_LINE_HEIGHT)
|
||||
self.document.drawImage(url, INDENTED_X + 340, self.y, width=180, height=39)
|
||||
|
||||
def add_footer(self):
|
||||
def add_terms_of_sales(self):
|
||||
""" Ajoute les conditions générales de payement au bas de la facture """
|
||||
self.y = 125
|
||||
text = "<b>Conditions générales de paiement</b>"
|
||||
paragraph = Paragraph(text, self.style)
|
||||
width, height = paragraph.wrap(6*cm, self.y)
|
||||
paragraph.drawOn(self.document, INDENTED_X, self.y)
|
||||
self.add_vspace(-height)
|
||||
self.__add_section_title("Conditions générales de paiement")
|
||||
self.add_vspace()
|
||||
|
||||
lines = [
|
||||
"Facture payable au comptant.",
|
||||
|
|
Loading…
Reference in New Issue