{#- The stock and price of a restock watch, in its "Restock & Price" cell of the watch list (td.restock-and-price),
part of the row (watch-overview-single-row.html). Needs: watch -#}
{%- if watch.has_restock_info -%}
{%- if watch['restock']['in_stock']-%} {{ _('In stock') }} {%- else-%} {{ _('Not in stock') }} {%- endif -%}
{%- endif -%}
{%- if watch.get('restock') and watch['restock'].get('price') -%}
{%- set restock = watch['restock'] -%}
{%- set price = restock.get('price') -%}
{%- set currency = restock.get('currency') if restock.get('currency','') else '' -%}
{%- if price is not none and (price|string)|regex_search('\d') -%}
{# @todo: make parse_currency/parse_decimal aware of the locale of the actual web page and use that instead changedetectionio/processors/restock_diff/__init__.py #}
{%- if price is number -%}{# A number, so in their language with the currency's decimal places #}
{{ price|format_price(currency) }}
{%- else -%}{# It's totally fine if it arrives as something else, the website might be something weird in this field #}
{{ price }} {{ currency }}
{%- endif -%}
{%- set price_change_pct = restock.get_price_change_percent() -%}
{%- if price_change_pct is not none -%}
{%- set prev_price = restock.get('last_price') -%}
{%- set prev_disp = prev_price|format_price(currency) if prev_price is number else prev_price -%}
{%- if price_change_pct < 0 -%}
▼ {{ '%g'|format(price_change_pct) }}%
{%- else -%}
▲ +{{ '%g'|format(price_change_pct) }}%
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- elif not watch.has_restock_info -%}
{{ _('No information') }}
{%- endif -%}