Many Changes
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -25,10 +25,11 @@ def fetch_tickets_from_database():
|
||||
|
||||
# Tickets abrufen, inklusive customer_ID
|
||||
cursor.execute("""
|
||||
SELECT t.`number`, t.title, t.createdate, t.`type`, t.customer_ID, tct.firstdate, t.time, s.price, t.service_ID
|
||||
SELECT t.`number`, t.title, t.createdate, t.`type`, t.customer_ID, tct.firstdate, t.time, s.price, t.service_ID, t.tags
|
||||
FROM Kunden.tickets t
|
||||
JOIN Kunden.`tickets.customer.timerange` tct ON t.customer_ID = tct.customer_ID
|
||||
JOIN Kunden.services s ON s.service_ID = t.service_ID
|
||||
WHERE closedate >= DATE_SUB(CURDATE(), INTERVAL 32 DAY)
|
||||
ORDER by t.createdate ASC
|
||||
""")
|
||||
tickets = cursor.fetchall()
|
||||
@@ -136,7 +137,7 @@ def set_cell_border(cell, **kwargs):
|
||||
|
||||
def fill_template(doc_path, output_path, data, tickets):
|
||||
doc = Document(doc_path)
|
||||
|
||||
print("Korrekt")
|
||||
# Platzhalter in normalem Text ersetzen
|
||||
for paragraph in doc.paragraphs:
|
||||
for key, value in data.items():
|
||||
@@ -161,8 +162,15 @@ def fill_template(doc_path, output_path, data, tickets):
|
||||
second_table = doc.tables[1]
|
||||
for ticket in tickets:
|
||||
row = second_table.add_row()
|
||||
ticket_number, title, createdate, _, _, _, timerange, _, _, tags = ticket
|
||||
|
||||
print(ticket[9])
|
||||
|
||||
row.cells[0].text = ticket[0] # Ticketnummer
|
||||
row.cells[1].text = ticket[1] # Tickettitel
|
||||
if ticket[9]:
|
||||
row.cells[1].text = f"{ticket[1]} - {ticket[9]}" # Tickettitel
|
||||
else:
|
||||
row.cells[1].text = ticket[1]
|
||||
row.cells[2].text = ticket[2].strftime("%d.%m.%Y") # createdate als String formatieren
|
||||
row.cells[3].text = str(ticket[6]) # timerange (time_unit)
|
||||
|
||||
@@ -227,12 +235,16 @@ if __name__ == "__main__":
|
||||
service_ID = next(iter(set(ticket[8] for ticket in tickets)))
|
||||
price = next(iter(set(ticket[7] for ticket in tickets)))
|
||||
customer_ids = set(ticket[4] for ticket in tickets)
|
||||
|
||||
print(tickets)
|
||||
print(customer_ids)
|
||||
|
||||
for customer_id in customer_ids:
|
||||
customer_data = fetch_customer_data(customer_id)
|
||||
customer_servicetime = fetch_customer_servicetime(customer_id)
|
||||
customer_price = fetch_customer_price(price, customer_id, service_ID)
|
||||
customer_tickets = [ticket for ticket in tickets if ticket[4] == customer_id]
|
||||
print(customer_data)
|
||||
|
||||
if not customer_data:
|
||||
print(f"Keine Kundendaten für Kunden-ID {customer_id} gefunden!")
|
||||
@@ -257,22 +269,21 @@ if __name__ == "__main__":
|
||||
"city": customer_data[4],
|
||||
"customernumber": customer_data[5],
|
||||
"year": datetime.now().year,
|
||||
"ordernumber": "0001",
|
||||
"ordernumber": "1",
|
||||
"startdate": startdate.strftime("%d.%m.%Y"),
|
||||
"enddate": enddate.strftime("%d.%m.%Y"),
|
||||
"today": datetime.now().strftime("%d.%m.%Y"),
|
||||
"price_per_minute": customer_price,
|
||||
"servicetime": customer_servicetime[0],
|
||||
"gesamt_time_unit": 0,
|
||||
"price_ex_mwst": 0,
|
||||
"price_ex_mwst": "0,00",
|
||||
"sl_time_unit": 0,
|
||||
"sl_minus_unit": 0,
|
||||
"zl_time_unit": 0,
|
||||
"time_unit_sum": 0,
|
||||
"mwst_set": 0,
|
||||
"sum": 0,
|
||||
"mwst_set": "0,00",
|
||||
"sum": "0,00",
|
||||
}
|
||||
|
||||
output_path = f"apps/ticket_export/exports/RE2024.{customer_data[5]}.{data['ordernumber']}.docx"
|
||||
output_path = f"apps/ticket_export/exports/RE2025.{customer_data[5]}.{data['ordernumber']}.docx"
|
||||
fill_template('apps/ticket_export/template.docx', output_path, data, customer_tickets)
|
||||
print("True")
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user