{% extends "pos/base.html" %} {% block content %}

Stock Adjustment Script

Important: Ye script old sale, purchase, aur old stock history rows ko update/delete nahi karegi. Apply par ProductStock rows ka stock reset hoga, product_details stock update hoga, aur agar history closing product stock se match nahi karti to stock_history mein new adjustment row insert hogi.
{% if messages %} {% for message in messages %}
{{ message }}
{% endfor %} {% endif %}
One Product flow mein product code/prod id/db id required hai.

Flow: {{ scope }} | Total checked: {{ total_checked }} | Total planned: {{ total_planned }} | Need adjustment: {{ total_affected }} | History adjustments: {{ total_history_adjustments }} | Variant adjustments: {{ total_variant_adjustments }} | Default stock will move: {{ total_default_stock_will_move }} | Preview limit: {{ preview_limit }}

{% if move_default_to_other %}
"Move default layer stock to other variants" is ON — default variant ka stock last non-default variant mein move hoga (agar koi non-default variant exist nahi karta to naya bana diya jayega).
{% endif %} {% if scope == "one" and not product_code %}
One Product flow ke liye pehle product code / prod id / db id enter karo.
{% elif total_planned > 0 %}
{% csrf_token %}
{% else %}
No product found for this flow.
{% endif %}
{% for row in preview_rows %} {% empty %} {% endfor %}
DB ID Prod ID Code Name Product Stock Target Stock Current Variant Stock Variant Rows Default → Other Move History Calculation History Adjustment Status / Issue
{{ row.id }} {{ row.prod_id }} {{ row.product_code }} {{ row.name }} Present: {{ row.old_present_stock }}
Bonus: {{ row.old_bonus_stock }}
{{ row.target_stock }}
Bonus: {{ row.target_bonus }}
On Hand: {{ row.variant_on_hand_total }}
Bonus: {{ row.variant_bonus_total }}
Total: {{ row.variant_total }} {% if row.variant_total_mismatch %}
Variant total mismatch {% endif %}
{{ row.variant_rows_count }} {% if row.consolidate_variants %} {% if not row.variant_distribution_ok %}
Distribution will be reset {% else %}
Distribution OK {% endif %} {% else %} {% if row.variant_total_mismatch %}
Total mismatch — last row will adjust by {{ row.variant_adjustment_delta }} {% else %}
Total OK — distribution untouched {% endif %} {% endif %}
{% if row.will_move_default_stock %} Default stock: {{ row.default_stock_before }}
→ moving to: {{ row.target_variant_sku }}
{% else %} — {% endif %}
Opening: {{ row.history_opening }}
Net Change: {{ row.history_net_change }}
Closing: {{ row.history_closing }}
Rows: {{ row.history_rows_count }} {% if row.first_history_id %}
First ID: {{ row.first_history_id }} {% endif %} {% if row.last_history_id %}
Last ID: {{ row.last_history_id }} {% endif %}
{% if row.history_adjustment < 0 %} {{ row.history_adjustment }} {% elif row.history_adjustment > 0 %} +{{ row.history_adjustment }} {% else %} 0 {% endif %} {% if row.history_needs_adjustment %}
New history adjustment row will be inserted. {% else %}
History already matched. {% endif %}
{% if row.issue %} {{ row.issue }} {% else %} {% if row.needs_change %} Adjustment needed {% else %} Already OK {% endif %}
{% if row.product_needs_update %} Product details stock will be updated.
{% else %} Product details stock already OK.
{% endif %} {% if row.consolidate_variants %} {% if row.variant_total_mismatch or not row.variant_distribution_ok %} ProductStock rows will be reset.
Last variant row will receive target stock.
{% else %} ProductStock already OK.
{% endif %} {% else %} {% if row.variant_total_mismatch %} Only last variant row will be nudged by {{ row.variant_adjustment_delta }} — other variants untouched.
{% else %} ProductStock already OK — distribution untouched.
{% endif %} {% endif %} {% if row.history_needs_adjustment %} Stock history adjustment row will be inserted. {% else %} Stock history already matched. {% endif %} {% endif %}
No products found for this flow.
{% endblock %}