diff --git a/app/estimation.py b/app/estimation.py index 3584ed2..731bc8e 100644 --- a/app/estimation.py +++ b/app/estimation.py @@ -46,11 +46,12 @@ def estimate(volume_ccm: float, material: str | None) -> dict: PRINT_SPEED_G_PER_HOUR (env, default 32): ~32 g/h matches Bambu Lab at normal quality; use ~20 for slower printers. """ - vat_rate = float(os.environ.get("VAT_RATE", 19)) - price_per_kg = float(os.environ.get("FILAMENT_PRICE_PER_KG", 15)) - base_factor = float(os.environ.get("MATERIAL_FACTOR", 0.50)) - print_speed = float(os.environ.get("PRINT_SPEED_G_PER_HOUR", 32)) - density = _DENSITY.get(material or "", _DEFAULT_DENSITY) + vat_rate = float(os.environ.get("VAT_RATE", 19)) + price_per_kg = float(os.environ.get("FILAMENT_PRICE_PER_KG", 15)) + base_factor = float(os.environ.get("MATERIAL_FACTOR", 0.50)) + print_speed = float(os.environ.get("PRINT_SPEED_G_PER_HOUR", 32)) + printer_cost_per_hour = float(os.environ.get("PRINTER_COST_PER_HOUR", 0.35)) + density = _DENSITY.get(material or "", _DEFAULT_DENSITY) eff_factor = _effective_factor(volume_ccm, base_factor) material_ccm = volume_ccm * eff_factor @@ -59,18 +60,21 @@ def estimate(volume_ccm: float, material: str | None) -> dict: filament_cost = weight_g / 1000 * price_per_kg after_misprint = filament_cost * 1.20 - net_price = after_misprint * 1.30 + printer_cost = (print_minutes / 60) * printer_cost_per_hour + net_price = (after_misprint + printer_cost) * 1.30 gross_price = net_price * (1 + vat_rate / 100) return { - "material_ccm": round(material_ccm, 2), - "weight_g": round(weight_g, 1), - "print_minutes": print_minutes, - "filament_cost": round(filament_cost, 2), - "net_price": round(net_price, 2), - "gross_price": round(gross_price, 2), - "vat_rate": vat_rate, - "price_per_kg": price_per_kg, - "material_factor": eff_factor, - "print_speed": print_speed, + "material_ccm": round(material_ccm, 2), + "weight_g": round(weight_g, 1), + "print_minutes": print_minutes, + "filament_cost": round(filament_cost, 2), + "printer_cost": round(printer_cost, 2), + "net_price": round(net_price, 2), + "gross_price": round(gross_price, 2), + "vat_rate": vat_rate, + "price_per_kg": price_per_kg, + "material_factor": eff_factor, + "print_speed": print_speed, + "printer_cost_per_hour": printer_cost_per_hour, } diff --git a/app/templates/job_detail.html b/app/templates/job_detail.html index da3665c..1d029b3 100644 --- a/app/templates/job_detail.html +++ b/app/templates/job_detail.html @@ -155,6 +155,7 @@ {{ (estimation.material_factor * 100) | round | int }}% material factor · {{ estimation.print_speed | int }} g/h · {{ estimation.price_per_kg }} €/kg + · {{ estimation.printer_cost_per_hour }} €/h printer · {{ estimation.vat_rate }}% VAT @@ -188,6 +189,8 @@ {{ "%.2f"|format(estimation.filament_cost) }} € + 20 % misprint {{ "%.2f"|format(estimation.filament_cost * 1.2) }} € + Printer ({{ estimation.printer_cost_per_hour }} €/h) + {{ "%.2f"|format(estimation.printer_cost) }} €