{% extends "base.html" %} {% import 'components/macros.html' as ui %} {% block title %}Receipt - {{ brand_name }}{% endblock %} {% block head_extra %} {% endblock %} {% block content %}

{{ brand_name }}

Official Receipt

{% if sale %}

Date: {{ sale[3] }}

{% endif %}

Shop Location: {{ shop_location or 'Not set' }}


{% if sale %}

Receipt Code: {{ receipt_code or 'RCP-' ~ '%06d'|format(sale[0]) }}


{% if sale_items %} {% for item in sale_items %} {% endfor %}
{{ item[0] }} {{ item[1] }} x {{ "%.2f"|format(item[2]) }} {{ "%.2f"|format(item[3]) }}

{% endif %}

Total: {{ currency_symbol }} {{ "%.2f"|format(sale[1]|float) }}

{% if sale[6] == 'cash' %} {% set cash_received = sale[9]|float if sale[9] is not none else sale[1]|float %} {% set change_due = sale[10]|float if sale[10] is not none else cash_received - (sale[1]|float) %}

Cash Received: {{ currency_symbol }} {{ "%.2f"|format(cash_received) }}

Balance / Change Given: {{ currency_symbol }} {{ "%.2f"|format(change_due if change_due > 0 else 0) }}

{% endif %} {% if sale[11] %}

Customer: {{ sale[11] }}

{% endif %} {% set returned = sale[4]|float if sale[4] is not none else 0 %} {% if returned > 0 %}

Returned: {{ currency_symbol }} {{ "%.2f"|format(returned) }}

Net: {{ currency_symbol }} {{ "%.2f"|format(sale[1]|float - returned) }}

{% endif %}

Cashier ID: {{ sale[2] }}

{% endif %}

Status: PAID

{% if sale and sale[5] %}
Payment Method: {{ sale[6]|title if sale[6] else 'Unknown' }}
Payment Status: {% if sale[5] == 'completed' %} ✅ VERIFIED — Money received in admin account {% elif sale[5] == 'pending' %} ⏳ PENDING — Awaiting confirmation {% elif sale[5] == 'under_review' %} 🔍 UNDER REVIEW — Verifying payment {% elif sale[5] == 'failed' %} ❌ FAILED — Payment not received {% else %} {{ sale[5]|title }} {% endif %}
{% endif %}

Thank you for shopping with us.

Send Receipt to Customer

Email {{ 'ready' if delivery_status.email else 'not configured' }} SMS {{ 'ready' if delivery_status.sms else 'not configured' }} WhatsApp {{ 'ready' if delivery_status.whatsapp else 'not configured' }}
{# sale tuple layout is controlled by modules/sales/routes.py receipt() query. #} {# It selects: ..., customer_contact, amount_tendered, change_due, customer_name, customer_phone, customer_email #} {# In that layout: sale[8]=customer_contact, sale[11]=customer_name, sale[12]=customer_phone, sale[13]=customer_email. #} {# Defensive tuple indexing: sales tuple layout is controlled by modules/sales/routes.py. During some migrations/DB states, tuple indexes for phone/email may shift. This must never throw; 500 would bounce user back to /admin. #} {% set sale_phone = (sale[12] if sale and sale|length > 12 else '') %} {% set sale_email = (sale[13] if sale and sale|length > 13 else '') %} {% set contact_raw = (sale[8] if sale and sale|length > 8 else '') %} {% set contact_phone_fallback = (contact_raw if contact_raw and '@' not in contact_raw else '') %} {% set contact_email_fallback = (contact_raw if contact_raw and '@' in contact_raw else '') %}
{% if session.get('role') == 'admin' %} Configure Delivery APIs {% endif %} {% if delivery_result %}
{{ delivery_result.message }}
{% endif %}
Back to Sales Return Items
{% endblock %}