Respect the currency of the prices when calculating average part price.

This commit is contained in:
Jan Böhmer 2019-09-01 18:52:22 +02:00
parent a479dc81c4
commit af3dfafe22
5 changed files with 148 additions and 101 deletions

View file

@ -34,9 +34,23 @@
<i class="fas fa-microchip fa-fw" ></i>
<span class="text-muted">{{ part.footprint.fullPath ?? "-"}}</span>
</h6>
<h6 title="{% trans %}part.avg_price.label{% endtrans %}">
<h6>
<i class="fas fa-money-bill-alt fa-fw"></i>
<span class="text-muted">{% if part.averagePrice is not null %}{{ part.averagePrice | moneyFormat }}{% else %}-{% endif %}</span>
<span class="text-muted">
{% set min_order_amount = pricedetail_helper.minOrderAmount(part) %}
{% set max_order_amount = pricedetail_helper.maxDiscountAmount(part) %}
{% set max_order_price = pricedetail_helper.calculateAvgPrice(part, max_order_amount) %}
{% if max_order_price is not null %}
<span title="{% trans %}part.avg_price.label{% endtrans %} {{ max_order_amount | amountFormat(part.partUnit) }}">{{ max_order_price | moneyFormat }}</span>
{% if min_order_amount < max_order_amount %}
<span> - </span>
<span title="{% trans %}part.avg_price.label{% endtrans %} {{ min_order_amount | amountFormat(part.partUnit) }}">{{pricedetail_helper.calculateAvgPrice(part, min_order_amount) | moneyFormat }}</span>
{% endif %}
{% endif %}
</span>
</h6>
{#
{% if part.comment != "" %}