Improve margin report status labels

This commit is contained in:
Victor Fraile Garcia 2026-05-30 19:34:43 +02:00
parent 4e3e3aef1b
commit bff3fef40d

View File

@ -278,7 +278,69 @@
<tr><td>Acción recomendada</td><td>{{ report.recommended_action }}</td></tr>
</table>
<h2>6. Timeline</h2>
<h2>6. Margin Intelligence</h2>
{% if margin %}
<div class="grid">
<div class="card"><div class="label">Ingreso neto</div><div class="value">{{ margin.revenue_net_eur|num(2) }} €</div></div>
<div class="card"><div class="label">Cliente</div><div class="value" style="font-size: 11px;">{{ margin.customer_name or "Sin cliente" }}</div></div>
<div class="card"><div class="label">Pedido venta</div><div class="value">{{ margin.sale_order_ref or "Sin pedido" }}</div></div>
<div class="card"><div class="label">Coste paros</div><div class="value">{{ margin.stop_cost_eur|num(2) }} €</div></div>
<div class="card"><div class="label">Coste material</div><div class="value">{{ margin.material_cost_estimated_eur|num(2) if margin.material_cost_estimated_eur is not none else "Pendiente" }}</div></div>
<div class="card"><div class="label">Coste conocido</div><div class="value">{{ margin.known_or_estimated_cost_eur|num(2) }} €</div></div>
<div class="card"><div class="label">Margen estimado</div><div class="value">{{ margin.estimated_margin_eur|num(2) if margin.estimated_margin_eur is not none else "No calculable" }}</div></div>
<div class="card"><div class="label">Estado margen</div><div class="value" style="font-size: 10px;">{% if margin.margin_status == 'PARTIAL_MARGIN_MISSING_RAW_MATERIAL_COST' %}Pendiente coste de materia prima{% elif margin.margin_status == 'ESTIMATED_MARGIN_AVAILABLE' %}Margen estimado disponible{% elif margin.margin_status == 'NO_MARGIN_WITHOUT_REVENUE' %}Sin ingreso de venta vinculado{% else %}{{ margin.margin_status }}{% endif %}</div></div>
</div>
<table class="kv-table">
<tr><th>Métrica</th><th>Valor</th></tr>
<tr><td>Ingreso neto venta</td><td>{{ margin.revenue_net_eur|num(2) if margin.revenue_net_eur is not none else "" }} €</td></tr>
<tr><td>Ingreso total venta</td><td>{{ margin.revenue_total_eur|num(2) if margin.revenue_total_eur is not none else "" }} €</td></tr>
<tr><td>Pedido venta</td><td>{{ margin.sale_order_ref or "" }}</td></tr>
<tr><td>Cliente</td><td>{{ margin.customer_name or "" }}</td></tr>
<tr><td>Materia prima consumida</td><td>{{ margin.raw_materials_summary or "Sin materia prima detectada" }}</td></tr>
<tr><td>Coste materia prima</td><td>{{ margin.material_cost_estimated_eur|num(2) if margin.material_cost_estimated_eur is not none else "Pendiente de coste" }}</td></tr>
<tr><td>Estado coste materia prima</td><td>{% if margin.material_cost_source_status == 'MISSING_RAW_MATERIAL_COST_PARAMETER' %}Pendiente coste de materia prima{% elif margin.material_cost_source_status == 'FROM_RAW_MATERIAL_COSTS' %}Calculado desde coste de materia prima{% elif margin.material_cost_source_status == 'FROM_ODOO_RAW_MATERIAL_VALUE' %}Calculado desde valoración Odoo{% else %}{{ margin.material_cost_source_status }}{% endif %}</td></tr>
<tr><td>Coste paros</td><td>{{ margin.stop_cost_eur|num(2) }} €</td></tr>
<tr><td>Coste conocido o estimado</td><td>{{ margin.known_or_estimated_cost_eur|num(2) }} €</td></tr>
<tr><td>Margen parcial tras costes conocidos</td><td>{{ margin.partial_margin_after_known_costs_eur|num(2) if margin.partial_margin_after_known_costs_eur is not none else "" }} €</td></tr>
<tr><td>Margen estimado</td><td>{{ margin.estimated_margin_eur|num(2) if margin.estimated_margin_eur is not none else "No calculable todavía" }}</td></tr>
<tr><td>% margen estimado</td><td>{{ margin.estimated_margin_pct|num(2) if margin.estimated_margin_pct is not none else "No calculable todavía" }}</td></tr>
<tr><td>Estado económico</td><td>{% if margin.margin_status == 'PARTIAL_MARGIN_MISSING_RAW_MATERIAL_COST' %}Pendiente coste de materia prima{% elif margin.margin_status == 'ESTIMATED_MARGIN_AVAILABLE' %}Margen estimado disponible{% elif margin.margin_status == 'NO_MARGIN_WITHOUT_REVENUE' %}Sin ingreso de venta vinculado{% else %}{{ margin.margin_status }}{% endif %}</td></tr>
</table>
<h2>7. Materias primas</h2>
<table>
<tr>
<th>Código</th>
<th>Materia prima</th>
<th>Cantidad prevista</th>
<th>Cantidad consumida</th>
<th>UdM</th>
<th>Coste €/kg</th>
<th>Coste estimado</th>
<th>Estado</th>
</tr>
{% for raw in raw_materials %}
<tr>
<td>{{ raw.raw_product_default_code or "" }}</td>
<td>{{ raw.raw_product_name or "" }}</td>
<td>{{ raw.planned_qty|num(3) if raw.planned_qty is not none else "" }}</td>
<td>{{ raw.consumed_qty|num(3) if raw.consumed_qty is not none else "" }}</td>
<td>{{ raw.raw_uom or "" }}</td>
<td>{{ raw.material_cost_eur_per_kg|num(4) if raw.material_cost_eur_per_kg is not none else "" }}</td>
<td>{{ raw.material_cost_estimated_eur_rounded|num(2) if raw.material_cost_estimated_eur_rounded is not none else "" }}</td>
<td>{% if raw.material_cost_status == 'MISSING_RAW_MATERIAL_COST_PARAMETER' %}Pendiente coste materia prima{% elif raw.material_cost_status == 'FROM_RAW_MATERIAL_COST_PARAMETER' %}Coste manual validado{% elif raw.material_cost_status == 'FROM_ODOO_STOCK_MOVE_VALUE' %}Coste desde Odoo{% else %}{{ raw.material_cost_status }}{% endif %}</td>
</tr>
{% else %}
<tr><td colspan="8">Sin materias primas detectadas para la orden.</td></tr>
{% endfor %}
</table>
{% else %}
<p>No hay datos comerciales o económicos vinculados a esta orden.</p>
{% endif %}
<h2>8. Timeline</h2>
<table class="timeline-table">
<tr>
<th>Hora</th>