Add printer cost (€0.35/h) to price estimation
Adds depreciation/electricity as a separate line item in the production cost breakdown. Included in the markup base so it contributes to margin. Configurable via PRINTER_COST_PER_HOUR env var (default 0.35). Bracket gross total updates automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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
|
||||
</span>
|
||||
</div>
|
||||
@@ -188,6 +189,8 @@
|
||||
<td class="border-0">{{ "%.2f"|format(estimation.filament_cost) }} €</td></tr>
|
||||
<tr><td class="text-secondary">+ 20 % misprint</td>
|
||||
<td>{{ "%.2f"|format(estimation.filament_cost * 1.2) }} €</td></tr>
|
||||
<tr><td class="text-secondary">Printer ({{ estimation.printer_cost_per_hour }} €/h)</td>
|
||||
<td>{{ "%.2f"|format(estimation.printer_cost) }} €</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user