{% extends "base.html" %} {% block title %}Negotiation · {{ listing.title }}{% endblock %} {% block content %} {% set latest_offer = conversation.offers|sort(attribute='created_at', reverse=true)|first if conversation.offers else none %} {% set offer_count = conversation.offers|length if conversation and conversation.offers else 0 %} {% set original_price = listing.price %} {% set offer_amount = latest_offer.amount if latest_offer else None %} {% set difference_pct = ((offer_amount / original_price * 100) if offer_amount and original_price else None) %} {% set difference_text = None %} {% if offer_amount is not none and original_price %} {% set difference_text = ((original_price - offer_amount) / original_price * 100)|round(0, 'common')|int %} {% endif %} {# The creator of an offer is its ``buyer_id`` (the sender); ``seller_id`` is the recipient. Counter-offers swap these roles, so the maker is always ``latest_offer.buyer``. Show "You" only when the current user is that maker — mirrors the Offer History logic below. #} {% set offer_origin_label = 'You' %} {% if latest_offer %} {% if latest_offer.buyer_id == current_user.id %} {% set offer_origin_label = 'You' %} {% else %} {% set offer_maker = latest_offer.buyer %} {% set offer_origin_label = (offer_maker.profile.full_name if offer_maker.profile and offer_maker.profile.full_name else offer_maker.email) if offer_maker else 'the other party' %} {% endif %} {% endif %} {% set current_user_is_buyer = current_user.id == conversation.buyer_id %} {% set action_blocked = latest_offer and latest_offer.status.value == 'accepted' %}