compute plan grouping

This commit is contained in:
Tobias Brunner 2025-05-23 17:09:02 +02:00
parent 3896636f9b
commit 19b36b9a2c
No known key found for this signature in database
7 changed files with 284 additions and 93 deletions

View file

@ -8,84 +8,110 @@
<div class="col-12">
<h1 class="mb-4">Complete Price List - All Service Variants</h1>
{% if pricing_data_by_service_level %}
{% for service_level, pricing_data in pricing_data_by_service_level.items %}
<div class="mb-5">
<h2 class="mb-3">{{ service_level }}</h2>
<div class="table-responsive">
<table class="table table-striped table-bordered table-sm">
<thead class="table-dark">
<tr>
<th>Cloud Provider</th>
<th>Service</th>
<th>Compute Plan</th>
<th>vCPUs</th>
<th>RAM (GB)</th>
<th>CPU/Memory Ratio</th>
<th>Term</th>
<th>Currency</th>
<th>Compute Plan Price</th>
<th>Variable Unit</th>
<th>Units</th>
<th>Replica Enforce</th>
<th>SLA Base</th>
<th>SLA Per Unit</th>
<th>SLA Price</th>
<th>Discount Model</th>
<th>Discount Details</th>
<th class="table-warning">Final Price</th>
</tr>
</thead>
<tbody>
{% for row in pricing_data %}
<tr>
<td>{{ row.cloud_provider }}</td>
<td>{{ row.service }}</td>
<td>{{ row.compute_plan }}</td>
<td>{{ row.vcpus }}</td>
<td>{{ row.ram }}</td>
<td>{{ row.cpu_mem_ratio }}</td>
<td>{{ row.term }}</td>
<td>{{ row.currency }}</td>
<td>{{ row.compute_plan_price|floatformat:2 }}</td>
<td>{{ row.variable_unit }}</td>
<td>{{ row.units }}</td>
<td>{{ row.replica_enforce }}</td>
<td>{{ row.sla_base|floatformat:2 }}</td>
<td>{{ row.sla_per_unit|floatformat:4 }}</td>
<td>{{ row.sla_price|floatformat:2 }}</td>
<td>
{% if row.has_discount %}
{{ row.discount_model }}
{% else %}
None
{% endif %}
</td>
<td>
{% if row.has_discount %}
<small class="text-muted">
<strong>Total Units:</strong> {{ row.total_units }}<br>
<strong>Standard Price:</strong> {{ row.standard_sla_price|floatformat:2 }}<br>
<strong>Discounted Price:</strong> {{ row.discounted_sla_price|floatformat:2 }}<br>
<strong>Savings:</strong> {{ row.discount_savings|floatformat:2 }} ({{ row.discount_percentage|floatformat:1 }}%)<br>
{% if row.discount_breakdown %}
<strong>Breakdown:</strong><br>
{% for tier in row.discount_breakdown %}
{{ tier.tier_range }} units: {{ tier.units }} × {{ tier.rate|floatformat:4 }} = {{ tier.subtotal|floatformat:2 }}<br>
{% endfor %}
{% endif %}
</small>
{% else %}
<small class="text-muted">No discount applied</small>
{% endif %}
</td>
<td class="table-warning fw-bold">{{ row.final_price|floatformat:2 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<p class="text-muted"><strong>{{ pricing_data|length }}</strong> variants for {{ service_level }}</p>
{% if pricing_data_by_group_and_service_level %}
{% for group_name, service_levels in pricing_data_by_group_and_service_level.items %}
<div class="mb-5 border rounded p-3">
<h2 class="mb-3 text-primary">{{ group_name }}</h2>
{# Display group description and node_label from first available plan #}
{% for service_level, pricing_data in service_levels.items %}
{% if pricing_data and forloop.first %}
{% with pricing_data.0 as representative_plan %}
{% if representative_plan.compute_plan_group_description %}
<p class="text-muted mb-2"><strong>Description:</strong> {{ representative_plan.compute_plan_group_description }}</p>
{% endif %}
{% if representative_plan.compute_plan_group_node_label %}
<p class="text-muted mb-3"><strong>Node Label:</strong> <code>{{ representative_plan.compute_plan_group_node_label }}</code></p>
{% endif %}
{% endwith %}
{% endif %}
{% endfor %}
{% for service_level, pricing_data in service_levels.items %}
<div class="mb-4">
<h3 class="mb-3 text-secondary">{{ service_level }}</h3>
{% if pricing_data %}
<div class="table-responsive">
<table class="table table-striped table-bordered table-sm">
<thead class="table-dark">
<tr>
<th>Cloud Provider</th>
<th>Service</th>
<th>Compute Plan</th>
<th>vCPUs</th>
<th>RAM (GB)</th>
<th>CPU/Memory Ratio</th>
<th>Term</th>
<th>Currency</th>
<th>Compute Plan Price</th>
<th>Variable Unit</th>
<th>Units</th>
<th>Replica Enforce</th>
<th>SLA Base</th>
<th>SLA Per Unit</th>
<th>SLA Price</th>
<th>Discount Model</th>
<th>Discount Details</th>
<th class="table-warning">Final Price</th>
</tr>
</thead>
<tbody>
{% for row in pricing_data %}
<tr>
<td>{{ row.cloud_provider }}</td>
<td>{{ row.service }}</td>
<td>{{ row.compute_plan }}</td>
<td>{{ row.vcpus }}</td>
<td>{{ row.ram }}</td>
<td>{{ row.cpu_mem_ratio }}</td>
<td>{{ row.term }}</td>
<td>{{ row.currency }}</td>
<td>{{ row.compute_plan_price|floatformat:2 }}</td>
<td>{{ row.variable_unit }}</td>
<td>{{ row.units }}</td>
<td>{{ row.replica_enforce }}</td>
<td>{{ row.sla_base|floatformat:2 }}</td>
<td>{{ row.sla_per_unit|floatformat:4 }}</td>
<td>{{ row.sla_price|floatformat:2 }}</td>
<td>
{% if row.has_discount %}
{{ row.discount_model }}
{% else %}
None
{% endif %}
</td>
<td>
{% if row.has_discount %}
<small class="text-muted">
<strong>Total Units:</strong> {{ row.total_units }}<br>
<strong>Standard Price:</strong> {{ row.standard_sla_price|floatformat:2 }}<br>
<strong>Discounted Price:</strong> {{ row.discounted_sla_price|floatformat:2 }}<br>
<strong>Savings:</strong> {{ row.discount_savings|floatformat:2 }} ({{ row.discount_percentage|floatformat:1 }}%)<br>
{% if row.discount_breakdown %}
<strong>Breakdown:</strong><br>
{% for tier in row.discount_breakdown %}
{{ tier.tier_range }} units: {{ tier.units }} × {{ tier.rate|floatformat:4 }} = {{ tier.subtotal|floatformat:2 }}<br>
{% endfor %}
{% endif %}
</small>
{% else %}
<small class="text-muted">No discount applied</small>
{% endif %}
</td>
<td class="table-warning fw-bold">{{ row.final_price|floatformat:2 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<p class="text-muted"><strong>{{ pricing_data|length }}</strong> variants for {{ service_level }} in {{ group_name }}</p>
{% else %}
<p class="text-muted">No pricing variants available for {{ service_level }} in {{ group_name }}.</p>
{% endif %}
</div>
{% empty %}
<p class="text-muted">No service levels with pricing data found for group: {{ group_name }}.</p>
{% endfor %}
</div>
{% endfor %}
{% else %}