# 3D-Druck Kostenkalkulation Web-App zur Kalkulation von 3D-Druck-Kosten mit PDF-Rechnung und TXT-Export. ## Setup ```bash source .venv/bin/activate pip install -r requirements.txt ``` ## Start ```bash python app.py ``` -> http://127.0.0.1:5001 Der Debug-Modus ist standardmaessig **aus** (der Werkzeug-Debugger erlaubt sonst Codeausfuehrung ueber das Netz). Zum Entwickeln: ```bash FLASK_DEBUG=1 python app.py ``` Mit `FLASK_DEBUG=1` lauscht die App nur auf `127.0.0.1`. Host und Port lassen sich ueber `HOST` und `PORT` ueberschreiben. ## Funktionen - **Live-Berechnung** bei jeder Eingabe (Material, Strom, Abschreibung, Arbeit, Gewinn) - **Dark Mode** (persistiert in YAML-Konfiguration) - **PDF-Rechnung** mit Logo, Kundendaten und Positionstabelle (via fpdf2) - **TXT-Export** der Kalkulation - **Auto-Save** aller Werte via AJAX (debounced 500ms) - **Einstellungsseite** für Druckerabschreibung, Arbeitskosten, Stromkosten, Firmendaten, Logo - **Besteuerung** mit drei Modi: - *Privatverkauf* — kein Unternehmer nach §2 UStG: keine MwSt., keine Steuernummer, kein §19-Hinweis, nur „Privatverkauf. Kein Ausweis von Umsatzsteuer." - *Kleinunternehmer* — §19 UStG: keine MwSt., dafür der Pflichthinweis - *Regelbesteuert* — MwSt. mit 19 % oder 7 % - **Rechnungspflichtangaben** nach §14 UStG (Steuernummer/USt-IdNr., Leistungsdatum) — nur in den beiden Unternehmer-Modi - **Logo-Upload** (PNG/JPEG/WebP) für die Rechnung ## Installation auf Proxmox (LXC-Container) Das Skript `proxmox-setup.sh` erstellt einen Ubuntu-24.04-LXC-Container, klont das Repository, installiert alle Abhangigkeiten und richtet einen systemd-Service ein. **Auf dem Proxmox-Host als root ausfuhren:** ```bash bash -c "$(curl -fsSL https://gitea.teamthiele.de/ethiele/3ddruckkalkulation/raw/branch/main/proxmox-setup.sh)" ``` Nach Abschluss ist die App unter `http://:5001` erreichbar. Container-ID und Name konnen als Argumente ubergeben werden: ```bash bash -c "$(curl -fsSL https://gitea.teamthiele.de/ethiele/3ddruckkalkulation/raw/branch/main/proxmox-setup.sh)" - 105 mein-container ``` **Container-Zugriff:** ```bash pct enter 201 # Shell im Container systemctl status 3ddruck-kalkulation.service journalctl -u 3ddruck-kalkulation.service -f ``` ## Update des Containers `proxmox-update.sh` aktualisiert den Container via Git und startet den Service neu. **Im Container ausfuhren:** ```bash ./proxmox-update.sh ``` **Vom Proxmox-Host aus:** ```bash ./proxmox-update.sh 201 ``` Das Skript holt via `curl` die aktuelle Version aus dem Gitea-Repo, pullt, installiert ggf. neue Dependencies und restartet den systemd-Service. ## Technik | Komponente | Technologie | |-----------|-------------| | Backend | Flask (Python) | | Frontend | Tabler CSS, Bootstrap 5 | | Icons | Tabler Icons | | PDF | fpdf2 (importiert als `fpdf`) | | Config | YAML (Auto-Save, atomar geschrieben) | ## Projektstruktur ``` app.py # Flask-Server mit allen Routen templates/index.html # Hauptseite (Formular + Ergebnisse) templates/invoice.html # Rechnungsseite templates/settings.html # Einstellungen static/style.css # Minimales Custom-CSS static/script.js # Live-Berechnung + Auto-Save proxmox-setup.sh # Ersteinrichtung LXC-Container proxmox-update.sh # Update LXC-Container druckkalkulation_config.yaml # Automatisch erstellte Konfiguration (ignoriert) ``` ## Routen | Methode | Pfad | Beschreibung | |---------|------|-------------| | GET | `/` | Hauptseite mit Formular | | POST | `/calculate` | JSON-Berechnung (AJAX) | | POST | `/save_config` | Speichert Werte in YAML | | GET | `/invoice` | Rechnungsseite | | POST | `/invoice/pdf` | PDF-Download | | POST | `/export` | TXT-Download | | GET | `/settings` | Einstellungsseite | | POST | `/upload_logo` | Logo hochladen | | POST | `/delete_logo` | Logo loschen | ## Hinweise - `fpdf2` wird als `fpdf` importiert (alte API, `from fpdf import FPDF`) - Alle UI-Texte sind Deutsch - Die YAML-Config wird automatisch erstellt und bei jedem Tastendruck gespeichert - `druckkalkulation_config.yaml` und `static/logo.*` sind in `.gitignore` ausgeschlossen