{% 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' %}
Back to Listing {# All free-text conversation happens in the Messages module, never here. This button simply opens the existing chat thread for this listing. #} Open Conversation
{% set cover = listing.images[0] if listing.images else None %} {% if cover %} {{ listing.title }} {% else %}
{% endif %}

{{ listing.title }}

{{ listing.status.value|title }}
Original Price
{{ currency_symbol|default('₹') }}{{ "{:,.2f}".format(listing.price) }}
Seller
{{ other.profile.full_name if other.profile else other.email }}
Listed on
{{ listing.created_at.strftime('%d %b %Y') if listing.created_at else 'Recently listed' }}
Original Price
{{ currency_symbol|default('₹') }}{{ "{:,.2f}".format(listing.price) }}
Current Offer
{% if offer_amount is not none %}{{ currency_symbol|default('₹') }}{{ "{:,.2f}".format(offer_amount) }}{% else %}—{% endif %}
Difference
{% if difference_text is not none %}{{ difference_text }}%{% else %}—{% endif %}
Offers Exchanged
{{ offer_count }}
Started
{{ conversation.created_at.strftime('%d %b %Y') if conversation and conversation.created_at else 'Today' }}
{% if latest_offer %}
{{ currency_symbol|default('₹') }}{{ "{:,.2f}".format(latest_offer.amount) }}
Latest Offer
Offered by {{ offer_origin_label }}
{% if latest_offer.status.value == 'accepted' %}Offer accepted{% elif latest_offer.status.value == 'rejected' %}Offer rejected{% elif latest_offer.status.value == 'countered' %}Counter offer sent{% else %}Waiting for response{% endif %}
{{ latest_offer.created_at.strftime('%d %b %Y • %H:%M') if latest_offer.created_at else 'Just now' }}
{% else %}
No offers yet
{% if current_user.id == conversation.buyer_id %}
Start negotiating by sending your first offer.
{% if offer_form is defined %}{{ offer_form.hidden_tag() }}{% endif %}
{% else %}
Waiting for the buyer to send the first offer.
{% endif %} {% endif %}
{% if listing.status.value != 'available' %} {# Sold / reserved listings cannot take new offers. #}
This listing is {{ listing.status.value }}. Negotiation is closed and no further offers can be made.
{% elif latest_offer and latest_offer.status.value == 'pending' %} {% if current_user.id == latest_offer.seller_id %} {# The current pending offer is addressed to me: I can respond. #}
{% else %} {# I sent the current offer: it is the other party's turn. #}
Waiting for the other party to respond to your offer.
{% endif %} {% elif latest_offer and latest_offer.status.value == 'accepted' %}
This offer has been accepted. The negotiation is complete.
{% elif latest_offer and latest_offer.status.value in ['rejected', 'withdrawn', 'expired'] %} {# Negotiation may continue: the buyer can send a fresh offer. #} {% if current_user.id == conversation.buyer_id %}
{% if offer_form is defined %}{{ offer_form.hidden_tag() }}{% endif %}
{% else %}
The previous offer was rejected. Waiting for a new offer from the buyer.
{% endif %} {% else %} {# No offers yet: only the buyer can open the negotiation. #} {% if current_user.id == conversation.buyer_id %}
{% if offer_form is defined %}{{ offer_form.hidden_tag() }}{% endif %}
{% else %}
Waiting for the buyer to make an offer.
{% endif %} {% endif %}
{{ listing.status.value|title }}
This listing is currently available for negotiation.
  • Be polite
  • Keep offers realistic
  • Respond quickly
  • Respect the seller
{% if latest_offer and latest_offer.status.value == 'pending' and current_user.id == latest_offer.seller_id %}
{% if offer_form is defined %}{{ offer_form.hidden_tag() }}{% endif %}
{% endif %}
{% for offer in conversation.offers|sort(attribute='created_at', reverse=true) %} {% set maker = offer.buyer %} {% set maker_name = (maker.profile.full_name if maker.profile and maker.profile.full_name else maker.email) if maker else 'Someone' %} {% set maker_role = 'Buyer' if offer.buyer_id == conversation.buyer_id else 'Seller' %}
{{ maker_name }} ({{ maker_role }}) offered {{ currency_symbol|default('₹') }}{{ "{:,.2f}".format(offer.amount) }}
{{ offer.created_at.strftime('%d %b %Y • %H:%M') if offer.created_at else 'Just now' }}
{{ offer.status.value|title }}
{% endfor %}
Negotiation started
{{ conversation.created_at.strftime('%d %b %Y • %H:%M') if conversation and conversation.created_at else 'Started' }}
Started
{% endblock %}