From 6c120b4da7246da2af037e2e4aeedc1af4b56f16 Mon Sep 17 00:00:00 2001 From: Isaak Buslovich Date: Fri, 2 Feb 2024 19:21:07 +0100 Subject: [PATCH] lexoffice.py added --- app/data/invoices.csv | 5 ++- app/routes.py | 37 ++++++++---------- app/static/css/style.css | 41 +++++++++++++++++--- app/templates/index.html | 2 +- app/templates/partials/dashboard.html | 56 +++++++++++++++++++++++++++ run.py | 20 +++++++++- 6 files changed, 129 insertions(+), 32 deletions(-) create mode 100644 app/templates/partials/dashboard.html diff --git a/app/data/invoices.csv b/app/data/invoices.csv index 32e76ac..94980c8 100644 --- a/app/data/invoices.csv +++ b/app/data/invoices.csv @@ -1,2 +1,3 @@ -Rechnungsnummer;Email;Anrede -RE255111;fws-rs@vielhuber.eu;Sehr geehrter Herr Vielhuber +Rechnungsnummer;Email;Anrede;Betrag +RE255111;fws-rs@vielhuber.eu;Sehr geehrter Herr Vielhuber ;N/A +RE255111;fws-rs@vielhuber.eu;Sehr geehrter Herr Vielhuber; diff --git a/app/routes.py b/app/routes.py index 4da4e89..8f13e93 100644 --- a/app/routes.py +++ b/app/routes.py @@ -40,7 +40,13 @@ def render_htmx_or_full(template_partial, template_full): @app.route('/') def index(): - return render_htmx_or_full('partials/index.html', 'index.html') + dashboard_content = render_template('partials/dashboard.html') + return render_template('index.html', dashboard_content=dashboard_content) + + +@app.route('/dashboard') +def dashboard(): + return render_template('partials/dashboard.html') @app.route('/buchhaltung') @@ -51,38 +57,27 @@ def buchhaltung(): @app.route('/add-invoice', methods=['POST']) def add_invoice(): csv_file_path = os.path.join(current_app.root_path, 'data', 'invoices.csv') - - # Extract invoice data from form new_invoice = { 'Rechnungsnummer': request.form['rechnungsnummer'], 'Email': request.form['email'], 'Anrede': request.form['anrede'], - # Initialize 'Betrag' with a placeholder (to be updated) 'Betrag': 'N/A' } try: - # Fetch the total gross amount for the new invoice using LexofficeAPI - lexoffice_api = LexofficeAPI('your_access_token') # Replace with actual access token + lexoffice_api = LexofficeAPI() total_gross_amount = lexoffice_api.get_invoice_total_gross_amount(new_invoice['Rechnungsnummer']) + new_invoice['Betrag'] = total_gross_amount if total_gross_amount is not None else 'N/A' - # Update 'Betrag' in the new invoice data - if total_gross_amount is not None: - new_invoice['Betrag'] = total_gross_amount - - # Read existing data from CSV - with open(csv_file_path, 'r', newline='', encoding='utf-8') as csvfile: + with open(csv_file_path, 'r+', newline='', encoding='utf-8') as csvfile: reader = csv.DictReader(csvfile, delimiter=';') + existing_data = list(reader) fieldnames = reader.fieldnames if 'Betrag' not in fieldnames: fieldnames.append('Betrag') - existing_data = list(reader) - - # Add the new invoice at the beginning of the data - existing_data.insert(0, new_invoice) - - # Write the updated data back to the CSV file - with open(csv_file_path, 'w', newline='', encoding='utf-8') as csvfile: + existing_data.insert(0, new_invoice) + csvfile.seek(0) + csvfile.truncate() writer = csv.DictWriter(csvfile, fieldnames=fieldnames, delimiter=';') writer.writeheader() writer.writerows(existing_data) @@ -90,8 +85,8 @@ def add_invoice(): return redirect(url_for('buchhaltung')) except Exception as e: - logging.error(f"Error updating CSV file: {e}") - return "An error occurred while adding the invoice", 500 + logging.error(f"Error in add_invoice: {e}") + return "An error occurred", 500 # Other imports and routes... diff --git a/app/static/css/style.css b/app/static/css/style.css index 186760f..2f71122 100644 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -125,27 +125,56 @@ body { padding: 20px; width: calc(100% - var(--sidebar-width-collapsed)); overflow-y: auto; + overflow-x: hidden; } .card-grid { display: grid; - grid-template-columns: 1fr; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; + padding: 20px; } .card { background-color: var(--white); + border-radius: 8px; box-shadow: 0 4px 8px var(--box-shadow-color); - border-radius: 10px; overflow: hidden; - transition: transform 0.2s ease, box-shadow 0.2s ease; + transition: all 0.3s ease; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + padding: 20px; + cursor: pointer; + user-select: none; +} + +.card:hover { + box-shadow: 0 6px 12px var(--box-shadow-hover-color); + transform: translateY(-5px); +} + +.card-icon { + font-size: 40px; + color: var(--primary-color); + margin-bottom: 10px; +} + +.card-content { display: flex; flex-direction: column; } -.card:hover { - transform: translateY(-2px); - box-shadow: 0 5px 10px var(--box-shadow-hover-color); +.card-title { + font-size: 18px; + font-weight: bold; + margin-bottom: 5px; +} + +.card-description { + font-size: 14px; + color: var(--dark-grey); } .card-container { diff --git a/app/templates/index.html b/app/templates/index.html index caab5c7..0e53c59 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -62,7 +62,7 @@