{% extends "pos/base.html" %} {% block title %}Duplicate Purchase Cleanup{% endblock %} {% block content %}

Duplicate Purchase Invoice Cleanup

Back to Purchases
{% if executed %}
Cleanup executed. Any remaining issues below are ones the run could not fully fix automatically.
{% endif %} {% if warnings %}
Warnings ({{ warnings|length }}):
{% endif %}
Affected invoices
{{ totals.invoices }}
Extra payment rows
{{ totals.pay_extras }}
Extra line rows
{{ totals.line_extras }}
Extra stock_history rows
{{ totals.sh_extras }}
Serials removable
{{ totals.serial_safe }}
Serials blocked
{{ totals.serial_block }}
Extra builty rows
{{ totals.builty_extras }}
{% if not plans %}
No duplicate purchase invoices detected. Nothing to do.
{% else %}
Plan — one block per (invoice #, bill type)

Rows marked KEEP stay. Rows marked DEL would be removed when Execute is pressed.

{% for plan in plans %}
Invoice #{{ plan.invoice_no }}  |  {{ plan.category_label }}  |  Party: {{ plan.party_label }} {{ plan.pay_extras_count }} extra payments, {{ plan.line_extras }} extra lines, {{ plan.sh_extras }} extra stock rows
{# ─── PAYMENTS ─── #}
Payments
{% if plan.pay_keeper %} {% endif %} {% for p in plan.pay_extras %} {% endfor %}
Action payment_id total_amount amount_transaction (paid) date challan
KEEP {{ plan.pay_keeper.payment_id }} {{ plan.pay_keeper.total_amount }} {{ plan.pay_keeper.amount_transaction }} {{ plan.pay_keeper.transaction_date }} {{ plan.pay_keeper.builty_no|default:"" }}
DEL {{ p.payment_id }} {{ p.total_amount }} {{ p.amount_transaction }} {{ p.transaction_date }} {{ p.builty_no|default:"" }}
{# ─── LINES ─── #}
Purchase lines  ·  {{ plan.line_total }} total ⇒ {{ plan.line_keepers }} keeper(s), {{ plan.line_extras }} extra
{# ─── STOCK HISTORY ─── #}
stock_history  ·  {{ plan.sh_total }} rows ⇒ {{ plan.sh_keepers }} keeper(s), {{ plan.sh_extras }} extra
{# ─── SERIALS ─── #} {% if plan.serials_to_remove or plan.serials_blocked %}
Serials
{% for s in plan.serials_to_remove %} {% endfor %} {% for s in plan.serials_blocked %} {% endfor %}
Action serial_no status
DEL {{ s.serial_no }} {{ s.status }}
SKIP {{ s.serial_no }} {{ s.status }} (already moved)
{% endif %} {# ─── FIFO ─── #} {% if plan.fifo_plan %}
FIFO layers (sub_products_list)
{% for fp in plan.fifo_plan %} {% endfor %}
Product Price Layer qty (now) Want to reduce by Will reduce by
{{ fp.prod_name }} ({{ fp.product_code }}) {{ fp.price }} {{ fp.layer_qty }} {{ fp.want_reduce }} {{ fp.will_reduce }} {% if fp.floored %}partial — reconcile after{% endif %}
{% endif %} {# ─── BUILTY EXTRAS ─── #} {% if plan.builty_extras_count %}
Builty expense extras: {{ plan.builty_extras_count }} (will also remove matching expense payment row + create_today_expense row)
{% endif %}
Party running balance released after this cleanup: {{ plan.party_balance_delta|floatformat:2 }} (rebuilt from scratch on Execute)
{% endfor %} {# ── Execute button ── #} {% if not executed %}
{% csrf_token %}
Re-run Dry Run
{% endif %} {% endif %}
{% endblock %}