Improve pricing display

This commit is contained in:
Oliver Walters 2019-05-18 23:44:43 +10:00
parent ffda5a1b29
commit a54760b219
2 changed files with 74 additions and 16 deletions

View File

@ -6,37 +6,77 @@
Calculate pricing information for {{ part }}. Calculate pricing information for {{ part }}.
</div> </div>
<h4>Quantity</h4>
<table class='table table-striped table-condensed'> <table class='table table-striped table-condensed'>
<tr> <tr>
<td><b>Part</b></td> <td><b>Part</b></td>
<td>{{ part }}</td> <td colspan='2'>{{ part }}</td>
</tr> </tr>
<tr> <tr>
<td><b>Quantity</b></td> <td><b>Quantity</b></td>
<td>{{ quantity }}</td> <td colspan='2'>{{ quantity }}</td>
</tr> </tr>
{% if buy_price %} </table>
{% if part.supplier_count > 0 %}
<h4>Supplier Pricing</h4>
<table class='table table-striped table-condensed'>
{% if min_total_buy_price %}
<tr> <tr>
<td><b>Buy Cost</b></td> <td><b>Unit Cost</b></td>
<td>{{ buy_price }}</td> <td>Min: {{ min_unit_buy_price }}</td>
<td>Max: {{ max_unit_buy_price }}</td>
</tr>
{% if quantity > 1 %}
<tr>
<td><b>Total Cost</b></td>
<td>Min: {{ min_total_buy_price }}</td>
<td>Max: {{ max_total_buy_price }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% if bom_price %} {% else %}
<tr> <tr>
<td><b>BOM Cost</b></td> <td colspan='3'>
<td>{{ bom_price }}</td> <span class='warning-msg'><i>No supplier pricing available</i></span>
</td>
</tr> </tr>
{% endif %}
</table>
{% endif %}
{% if part.bom_count > 0 %}
<h4>BOM Pricing</h4>
<table class='table table-striped table-condensed'>
{% if min_total_bom_price %}
<tr>
<td><b>Unit Cost</b></td>
<td>Min: {{ min_unit_bom_price }}</td>
<td>Max: {{ max_unit_bom_price }}</td>
</tr>
{% if quantity > 1 %}
<tr>
<td><b>Total Cost</b></td>
<td>Min: {{ min_total_bom_price }}</td>
<td>Max: {{ max_total_bom_price }}</td>
</tr>
{% endif %}
{% if part.has_complete_bom_pricing == False %} {% if part.has_complete_bom_pricing == False %}
<tr> <tr>
<td colspan='2'> <td colspan='3'>
<span class='warning-msg'><i>Note: BOM pricing is incomplete for this part</i></span> <span class='warning-msg'><i>Note: BOM pricing is incomplete for this part</i></span>
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% else %}
<tr>
<td colspan='3'>
<span class='warning-msg'><i>No BOM pricing available</i></span>
</td>
</tr>
{% endif %} {% endif %}
</table> </table>
{% endif %}
{% if buy_price or bom_price %} {% if min_unit_buy_price or min_unit_bom_price %}
{% else %} {% else %}
<div class='alert alert-danger alert-block'> <div class='alert alert-danger alert-block'>
No pricing information is available for this part. No pricing information is available for this part.

View File

@ -577,14 +577,32 @@ class PartPricing(AjaxView):
if part is None: if part is None:
return ctx return ctx
buy_price = part.get_price_info(quantity, bom=False) # Supplier pricing information
bom_price = part.get_price_info(quantity, buy=False) if part.supplier_count > 0:
min_buy_price = part.get_min_supplier_price(quantity)
max_buy_price = part.get_max_supplier_price(quantity)
if buy_price: if min_buy_price:
ctx['buy_price'] = buy_price ctx['min_total_buy_price'] = min_buy_price
ctx['min_unit_buy_price'] = min_buy_price / quantity
if bom_price: if max_buy_price:
ctx['bom_price'] = bom_price ctx['max_total_buy_price'] = max_buy_price
ctx['max_unit_buy_price'] = max_buy_price / quantity
# BOM pricing information
if part.bom_count > 0:
min_bom_price = part.get_min_bom_price(quantity)
max_bom_price = part.get_max_bom_price(quantity)
if min_bom_price:
ctx['min_total_bom_price'] = min_bom_price
ctx['min_unit_bom_price'] = min_bom_price / quantity
if max_bom_price:
ctx['max_total_bom_price'] = max_bom_price
ctx['max_unit_bom_price'] = max_bom_price / quantity
return ctx return ctx