{% extends "layouts/base.twig" %} {% block title %}{{ translations.pricing }}{% endblock %} {% block head %} {% endblock %} {% block page_heading %}

{{ translations.pricing }}

{{ translations.product_pricing_subtitle }}

{% endblock %} {% block content %} {# ─── Nagłówek: sklep + statystyki ─── #}
{{ shop.getRepresentativeName() }}
{% if shop.getName() and shop.getName() != shop.getRepresentativeName() %} ({{ shop.getName() }}) {% endif %}
{% if shop.getCity() %} {{ shop.getZip() }} {{ shop.getCity() }}, {{ shop.getStreet() }} {{ shop.getStreetNum() }} {% endif %} {% if shop.getPhone() %} {{ shop.getPhone() }} {% endif %} {% if shop.getOpeningHours() and shop.getClosingHours() %} {{ shop.getOpeningHours() }} – {{ shop.getClosingHours() }} {% endif %}
{{ translations.products }}
{{ translations.without_max_price }}
{{ translations.avg_margin_on_max_price|default('Śred. marża (cena maks.)') }}
{# ─── Karta główna ─── #}

{{ translations.pricing }}

{{ translations.pricing_subtitle_hint|default('Ustaw maksymalną cenę sprzedaży dla każdego produktu') }}
{% if categories is defined and categories|length > 0 %}
{# ── Wiersz 1: grupy kolumn ── #} {# ── Wiersz 2: nazwy kolumn ── #} {% for category in categories %} {% for product in category.products %} {%- set raw = product.getRecipeCostGross()|default(0) -%} {%- set portionP = product.getPortionPrice()|default(0) -%} {%- set maxP = product.getMaxPortionPrice()|default(0) -%} {%- set expMargin = product.getExpectedMargin()|default(0) -%} {%- set margeOnMax = maxP > 0 ? ((maxP - raw) / maxP * 100)|round(0) : null -%} {%- set margeOnPortion = portionP > 0 ? ((portionP - raw) / portionP * 100)|round(0) : null -%} {%- set targetPrice = expMargin > 0 and raw > 0 ? raw / (1 - expMargin / 100) : null -%} {# ── Nazwa ── #} {# ── Koszt produkcji ── #} {# ── VAT ── #} {# ── Oczekiwana marża ── #} {# ── Obecna cena sprzedaży ── #} {# ── Marża od ceny sprzedaży ── #} {# ── Maks. cena sprzedaży (edytowalna) ── #} {# ── Marża od ceny maks. ── #} {% endfor %} {% endfor %}
{{ translations.product }} {{ translations.cost_section|default('Koszt') }} {{ translations.margin_section|default('Marże') }} {{ translations.max_price_section|default('Cena maks. sklepu') }}
{{ translations.raw_price }} {{ translations.vat|default('VAT') }} {{ translations.expected_margin_short|default('Oczek.') }} {{ translations.current_sale_price_short|default('Cena sp.') }} {{ translations.current_margin_short|default('Marża sp.') }} {{ translations.max_sale_price }} {{ translations.margin_on_max|default('Marża maks.') }}
{{ category.name }} {{ category.products|length }}
{{ product.getName() }} {% if product.getIsVegetarian() %} 🌿 {% endif %} {% if raw > 0 %} {{ raw|number_format(2, ',', ' ') }} {% else %} {% endif %} {{ product.getTaxValPerc() }}% {% if expMargin > 0 %} {{ expMargin|number_format(0, ',', ' ') }}% {% else %} {% endif %} {% if portionP > 0 %} {{ portionP|number_format(2, ',', ' ') }} {% else %} {% endif %} {% if margeOnPortion is not null %} {%- set cls = margeOnPortion >= 50 ? 'marge-good' : (margeOnPortion >= 20 ? 'marge-ok' : 'marge-bad') -%} {{ margeOnPortion }}% {# delta względem oczekiwanej #} {% if expMargin > 0 %} {%- set delta = margeOnPortion - expMargin|round(0) -%}
{{ delta >= 0 ? '+' : '' }}{{ delta }}pp
{% endif %} {% else %} {% endif %}
{# Podpowiedź: cena wyliczona z oczekiwanej marży #} {% if targetPrice is not null %}
{{ translations.for_expected_margin|default('Dla') }} {{ expMargin|number_format(0) }}%: {{ targetPrice|number_format(2, ',', ' ') }}
{% endif %}
{% if margeOnMax is not null %} {%- set cls = margeOnMax >= 50 ? 'marge-good' : (margeOnMax >= 20 ? 'marge-ok' : 'marge-bad') -%} {{ margeOnMax }}% {# delta względem oczekiwanej #} {% if expMargin > 0 %} {%- set delta = margeOnMax - expMargin|round(0) -%}
{{ delta >= 0 ? '+' : '' }}{{ delta }}pp
{% endif %} {% else %} {% endif %}

{{ translations.no_results|default('Brak wyników dla podanych filtrów') }}

{% else %}
{{ translations.no_products }}
{{ translations.back }}
{% endif %}
{# ── Legenda ── #}
{{ translations.legend|default('Legenda:') }} ≥50%{{ translations.legend_good|default('Wysoka marża') }} 20-49%{{ translations.legend_ok|default('Dobra marża') }} <20%{{ translations.legend_bad|default('Niska marża') }} —%{{ translations.legend_target|default('Oczekiwana marża') }} +Xpp / −Xpp {{ translations.legend_delta|default('odchylenie od oczekiwanej marży') }}
{% endblock %} {% block scripts %} {% endblock %}