filters, reports
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
||||
|
||||
def generate_pdf_report(hotel_name, reservations, start_date, end_date):
|
||||
"""Генерация PDF отчета."""
|
||||
pdf = FPDF()
|
||||
pdf = FPDF(orientation='L', unit="mm", format="A4")
|
||||
pdf.add_page()
|
||||
|
||||
# Укажите путь к шрифту
|
||||
@@ -33,7 +33,7 @@ def generate_pdf_report(hotel_name, reservations, start_date, end_date):
|
||||
|
||||
# Заголовки таблицы
|
||||
pdf.set_font("OpenSans", size=10)
|
||||
headers = ["Дата заезда", "Дата выезда", "Номер", "Тип комнаты", "Цена", "Скидка"]
|
||||
headers = ["Дата заезда", "Дата выезда", "Номер", "Тип комнаты", "Цена"]
|
||||
for width, header in zip(col_widths, headers):
|
||||
pdf.cell(width, 15, header, border=1, align="C")
|
||||
pdf.ln()
|
||||
@@ -52,14 +52,12 @@ def generate_pdf_report(hotel_name, reservations, start_date, end_date):
|
||||
pdf.cell(col_widths[2], 10, res.room_number, border=1)
|
||||
pdf.cell(col_widths[3], 10, res.room_type, border=1)
|
||||
pdf.cell(col_widths[4], 10, f"{price:.2f} р.", border=1, align="R")
|
||||
pdf.cell(col_widths[5], 10, f"{discount:.2f} р.", border=1, align="R")
|
||||
pdf.ln()
|
||||
|
||||
pdf.ln(5)
|
||||
pdf.set_font("OpenSans", size=18)
|
||||
pdf.cell(0, 10, "Итоги:", ln=True)
|
||||
pdf.cell(0, 10, f"Общая сумма цен: {total_price:.2f} руб.", ln=True)
|
||||
pdf.cell(0, 10, f"Общая сумма скидок: {total_discount:.2f} руб. ", ln=True)
|
||||
|
||||
file_path = os.path.join("reports", f"{hotel_name}_report.pdf")
|
||||
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user