Show bracket gross total price on bracket filter view
Sums gross_price estimates for all bracket jobs with known STL volume and displays it as a badge next to the bracket name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,21 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str
|
||||
)
|
||||
jobs = query.order_by(status_order, PrintJob.priority.desc(), PrintJob.created_at.asc()).all()
|
||||
|
||||
stl_files = list_stl_files()
|
||||
stl_cache = get_cache_map(stl_files, db)
|
||||
|
||||
bracket_gross_total = None
|
||||
if active_bracket:
|
||||
total = 0.0
|
||||
has_any = False
|
||||
for j in active_bracket.jobs:
|
||||
cached = stl_cache.get(j.file_name)
|
||||
if cached and cached.volume_ccm:
|
||||
total += estimate(cached.volume_ccm, j.job_material)["gross_price"]
|
||||
has_any = True
|
||||
if has_any:
|
||||
bracket_gross_total = round(total, 2)
|
||||
|
||||
return templates.TemplateResponse("jobs.html", {
|
||||
"request": request,
|
||||
"active": "jobs",
|
||||
@@ -172,10 +187,11 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str
|
||||
"show_all": bool(show_all),
|
||||
"hidden_count": hidden_count,
|
||||
"active_bracket": active_bracket,
|
||||
"bracket_gross_total": bracket_gross_total,
|
||||
"printers": db.query(Printer).order_by(Printer.name).all(),
|
||||
"brackets": db.query(JobBracket).order_by(JobBracket.name).all(),
|
||||
"stl_files": (stl_files := list_stl_files()),
|
||||
"stl_cache": get_cache_map(stl_files, db),
|
||||
"stl_files": stl_files,
|
||||
"stl_cache": stl_cache,
|
||||
"materials": available_materials() or MATERIALS,
|
||||
"colors": available_colors() or COLORS,
|
||||
"spool_map": spool_counts(),
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
<span class="badge bg-secondary fs-6 fw-normal px-3 py-2">
|
||||
<i class="bi bi-collection me-1"></i>{{ active_bracket.name }}
|
||||
</span>
|
||||
{% if bracket_gross_total is not none %}
|
||||
<span class="badge bg-dark border border-secondary fs-6 fw-normal px-3 py-2 text-white">
|
||||
<i class="bi bi-currency-euro me-1 text-secondary"></i>{{ "%.2f"|format(bracket_gross_total) }} <span class="text-secondary fw-normal" style="font-size:.75em">gross total</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
<a href="/jobs{% if q %}?q={{ q }}{% endif %}" class="text-secondary text-decoration-none small">× clear filter</a>
|
||||
</div>
|
||||
{% elif q %}
|
||||
|
||||
Reference in New Issue
Block a user