{% comment %} Per-row resolution control for one StockTakeItem. Expects in context: item — a StockTakeItem (status "missing" or "unexpected") next_url — URL to return to after the POST (this page) Branches: * resolved → "Resolved" badge; Undo (unexpected) or txn link (missing) * acknowledged → "Acknowledged" badge + note; Undo (unacknowledge) * missing → reason + Lost/Damaged/Expired + Apply * unexpected, binnable → "Add to bin" * unexpected, not binnable (not in system or terminal e.g. dispensed) → Acknowledge with a required note {% endcomment %} {% url 'edc_pharmacy:resolve_stock_take_item_url' stock_take_item=item.pk as action_url %} {% if item.resolved %} {# The code itself links to the ledger, so no extra link is shown here. #} Resolved {% if item.status == "unexpected" %}
{% csrf_token %}
{% endif %} {% elif item.acknowledged %} Acknowledged {{ item.acknowledged_note|truncatechars:40 }}
{% csrf_token %}
{% elif item.status == "missing" and item.conflict %} {# accounted for in another bin — cannot be lost. The reason is shown under #} {# the stock code via the conflict hint; clear the row with acknowledge. #}
{% csrf_token %}
{% elif item.status == "missing" %} {# not accounted for anywhere — the only count outcome is "lost" #}
{% csrf_token %}
{% elif item.stock and not item.stock.is_terminal %} {# unexpected and physically present — register it to this bin #}
{% csrf_token %}
{% else %} {# unexpected but cannot be added to a bin: not in system, or terminal. #} {# The reason is shown under the stock code via _cannot_add_hint.html. #}
{% csrf_token %}
{% endif %}