Renamed file and black runned.

This commit is contained in:
Trullemans Gregory 2020-02-29 14:21:56 +01:00
parent 7482d5a74b
commit 2b06b07b7a
4 changed files with 24 additions and 23 deletions

View File

@ -1,5 +0,0 @@
# Questions/TODO
## QUESTION 1
Comment gérer l'upload du fichier CSV et son traitement automatique ?

View File

@ -60,6 +60,7 @@ def prestation_listing(request):
context = {"prestation_list": prestation_list}
return render(request, "prestation_listing.html", context)
def contract_export(request, contract_id):
""" Génere un fichier PDF pour fournir au client.

View File

@ -46,7 +46,7 @@ ROOT_URLCONF = "comptaClub.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates"), ],
"DIRS": [os.path.join(BASE_DIR, "templates"),],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [

View File

@ -216,7 +216,9 @@ class PDFDocument(object):
self.add_vspace()
height = 40
self.document.rect(X, self.y - height, RIGHT_X - X, height, fill=0)
self.add_new_line(INDENTED_X, "N° Entreprise : " + self.club_infos["BCE_NUMBER"])
self.add_new_line(
INDENTED_X, "N° Entreprise : " + self.club_infos["BCE_NUMBER"]
)
if contract.client.company_number:
self.document.drawRightString(
@ -333,8 +335,13 @@ class PDFDocument(object):
self.add_new_line(INDENTED_X, "Merci de bien vouloir payer la somme de ")
self.add_string(INDENTED_X + 184, str(self.amount), font_decoration="Bold")
self.add_string(INDENTED_X + 215, "€ sur le compte ")
self.add_string(INDENTED_X + 290, self.club_infos["IBAN"], font_decoration="Bold")
self.add_string(INDENTED_X + 390, " (" + self.club_infos["BIC"] + " - " + self.club_infos["BANK"] + ")")
self.add_string(
INDENTED_X + 290, self.club_infos["IBAN"], font_decoration="Bold"
)
self.add_string(
INDENTED_X + 390,
" (" + self.club_infos["BIC"] + " - " + self.club_infos["BANK"] + ")",
)
self.add_vspace(COMMON_LINE_HEIGHT)
if not contract.is_paid:
@ -410,12 +417,8 @@ class PDFDocument(object):
Args:
accounting_year (int): année comptable
"""
extenses = get_transactiontype_and_sum_for_spf_export(
accounting_year, EXTENSES
)
recettes = get_transactiontype_and_sum_for_spf_export(
accounting_year, RECETTES
)
extenses = get_transactiontype_and_sum_for_spf_export(accounting_year, EXTENSES)
recettes = get_transactiontype_and_sum_for_spf_export(accounting_year, RECETTES)
self.__display_table_header("DEPENSES", "RECETTES")
self.__display_transactiontype_table_body(
@ -423,7 +426,7 @@ class PDFDocument(object):
recettes,
int(extenses["sum_total_transaction"]),
int(recettes["sum_total_transaction"]),
)
)
def __display_table_header(self, title_left, title_right):
self.add_vspace()
@ -451,7 +454,13 @@ class PDFDocument(object):
MIDDLE, self.y - 5, MIDDLE, 5 * -COMMON_LINE_HEIGHT
) # Séparation descriptif et montant recettes
self.y -= COMMON_LINE_HEIGHT
self.__display_table_line("Total des dépenses", totalexpenses, "Total des recettes", totalrecettes, font_decoration="Bold")
self.__display_table_line(
"Total des dépenses",
totalexpenses,
"Total des recettes",
totalrecettes,
font_decoration="Bold",
)
def __display_key_part(self, column_number, key, font_decoration=None):
""" Ajoute dans la colonne d'un tableau (à deux colonnes) la clef d'un couple clef/valeur.
@ -465,9 +474,7 @@ class PDFDocument(object):
space = INDENTED_X
else:
space = MIDDLE + INDENTED_X
self.add_string(
space, key, font_decoration=font_decoration, font_size=9
)
self.add_string(space, key, font_decoration=font_decoration, font_size=9)
def __display_value_part(self, column_number, value):
""" Ajoute dans la colonne d'un tableau (à deux colonnes) la valeur d'un couple clef/valeur
@ -482,9 +489,7 @@ class PDFDocument(object):
space = INDENTED_RIGHT_X
self.document.drawRightString(
space,
self.y,
str(locale.format("%d", int(value), grouping=True)),
space, self.y, str(locale.format("%d", int(value), grouping=True)),
)
def __display_column(self, column_number, key, value, font_decoration):