diff --git a/app.py b/app.py index a59b588..f586255 100644 --- a/app.py +++ b/app.py @@ -124,19 +124,32 @@ def index(): return render_template('index.html', config=config, calc=calc) +@app.route('/settings') +def settings(): + """Einstellungsseite fuer Druckerabschreibung, Arbeitskosten und Marge.""" + config = load_config() + return render_template('settings.html', config=config) + + @app.route('/calculate', methods=['POST']) def calc_json(): - """AJAX-Endpunkt: Nimmt Formular-JSON entgegen, gibt Berechnung zurueck.""" + """AJAX-Endpunkt: Nimmt Formular-JSON entgegen, gibt Berechnung zurueck. + Fehlende Werte werden aus der gespeicherten Config ergaenzt.""" data = request.get_json() - calc = calculate(data) + config = load_config() + merged = {**config, **data} + calc = calculate(merged) return jsonify(calc) @app.route('/save_config', methods=['POST']) def save_config_route(): - """AJAX-Endpunkt: Speichert aktuelle Formularwerte in YAML.""" + """AJAX-Endpunkt: Speichert aktuelle Formularwerte in YAML. + Vorhandene Werte (z.B. aus Einstellungen) werden nicht ueberschrieben.""" data = request.get_json() - save_config(data) + existing = load_config() + existing.update(data) + save_config(existing) return jsonify({'status': 'ok'}) @@ -210,7 +223,9 @@ def invoice_pdf(): def export(): """Exportiert die Kalkulation als TXT-Datei.""" data = request.get_json() - calc = calculate(data) + config = load_config() + merged = {**config, **data} + calc = calculate(merged) lines = [ "3D-DRUCK KOSTENKALKULATION", @@ -239,4 +254,4 @@ def export(): if __name__ == '__main__': - app.run(host='0.0.0.0', debug=True) + app.run(host='0.0.0.0', port=5001, debug=True) diff --git a/templates/index.html b/templates/index.html index 531b3a7..0e024f5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -22,6 +22,11 @@ 3D Druck Kostenkalkulator -
-
Drucker Abschreibung
-
-
- - -
-
- - -
-
- - -
-
-
- -
-
Arbeitskosten
-
-
- - -
-
- - -
-
-
- -
-
Gewinnmarge
-
-
- - -
-
-
- diff --git a/templates/invoice.html b/templates/invoice.html index 70cead7..8ad5e72 100644 --- a/templates/invoice.html +++ b/templates/invoice.html @@ -22,6 +22,11 @@ Rechnung erstellen