view BOMpricing range

Closes #1889
This commit is contained in:
Matthias 2021-08-13 17:50:41 +02:00
parent a2ffd06abf
commit f0325fe30f
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
3 changed files with 53 additions and 10 deletions

View File

@ -60,6 +60,21 @@
<td>Max: {% include "price.html" with price=max_total_bom_price %}</td>
</tr>
{% endif %}
{% if min_total_bom_purchase_price %}
<tr>
<td><b>{% trans 'Unit Purchase Price' %}</b></td>
<td>Min: {% include "price.html" with price=min_unit_bom_purchase_price %}</td>
<td>Max: {% include "price.html" with price=max_unit_bom_purchase_price %}</td>
</tr>
{% if quantity > 1 %}
<tr>
<td><b>{% trans 'Total Purchase Price' %}</b></td>
<td>Min: {% include "price.html" with price=min_total_bom_purchase_price %}</td>
<td>Max: {% include "price.html" with price=max_total_bom_purchase_price %}</td>
</tr>
{% endif %}
{% endif %}
{% if part.has_complete_bom_pricing == False %}
<tr>
<td colspan='3'>

View File

@ -61,6 +61,25 @@
<td>Max: {% include "price.html" with price=max_total_bom_price %}</td>
</tr>
{% endif %}
{% if min_total_bom_purchase_price %}
<tr>
<td></td>
<td>{% trans 'Unit Purchase Price' %}</td>
<td>Min: {% include "price.html" with price=min_unit_bom_purchase_price %}</td>
<td>Max: {% include "price.html" with price=max_unit_bom_purchase_price %}</td>
</tr>
{% if quantity > 1 %}
<tr>
<td></td>
<td>{% trans 'Total Purchase Price' %}</td>
<td>Min: {% include "price.html" with price=min_total_bom_purchase_price %}</td>
<td>Max: {% include "price.html" with price=max_total_bom_purchase_price %}</td>
</tr>
{% endif %}
{% endif %}
{% if part.has_complete_bom_pricing == False %}
<tr>
<td colspan='4'>

View File

@ -1351,6 +1351,7 @@ class PartPricing(AjaxView):
use_internal = InvenTreeSetting.get_setting('PART_BOM_USE_INTERNAL_PRICE', False)
bom_price = part.get_bom_price_range(quantity, internal=use_internal)
purchase_price = part.get_bom_price_range(quantity, purchase=True)
if bom_price is not None:
min_bom_price, max_bom_price = bom_price
@ -1358,19 +1359,27 @@ class PartPricing(AjaxView):
min_bom_price /= scaler
max_bom_price /= scaler
min_unit_bom_price = round(min_bom_price / quantity, 3)
max_unit_bom_price = round(max_bom_price / quantity, 3)
min_bom_price = round(min_bom_price, 3)
max_bom_price = round(max_bom_price, 3)
if min_bom_price:
ctx['min_total_bom_price'] = min_bom_price
ctx['min_unit_bom_price'] = min_unit_bom_price
ctx['min_total_bom_price'] = round(min_bom_price, 3)
ctx['min_unit_bom_price'] = round(min_bom_price / quantity, 3)
if max_bom_price:
ctx['max_total_bom_price'] = max_bom_price
ctx['max_unit_bom_price'] = max_unit_bom_price
ctx['max_total_bom_price'] = round(max_bom_price, 3)
ctx['max_unit_bom_price'] = round(max_bom_price / quantity, 3)
if purchase_price is not None:
min_bom_purchase_price, max_bom_purchase_price = purchase_price
min_bom_purchase_price /= scaler
max_bom_purchase_price /= scaler
if min_bom_purchase_price:
ctx['min_total_bom_purchase_price'] = round(min_bom_purchase_price, 3)
ctx['min_unit_bom_purchase_price'] = round(min_bom_purchase_price / quantity, 3)
if max_bom_purchase_price:
ctx['max_total_bom_purchase_price'] = round(max_bom_purchase_price, 3)
ctx['max_unit_bom_purchase_price'] = round(max_bom_purchase_price / quantity, 3)
# internal part pricing information
internal_part_price = part.get_internal_price(quantity)