diff --git a/shiftflow/templates/shiftflow/writeoffs.html b/shiftflow/templates/shiftflow/writeoffs.html
index 546f790..1bca9d4 100644
--- a/shiftflow/templates/shiftflow/writeoffs.html
+++ b/shiftflow/templates/shiftflow/writeoffs.html
@@ -83,6 +83,7 @@
{{ c.stock_item.material.full_name|default:c.stock_item.material.name }}
({% if c.stock_item.current_length and c.stock_item.current_width %}{{ c.stock_item.current_length|floatformat:"-g" }}×{{ c.stock_item.current_width|floatformat:"-g" }}{% elif c.stock_item.current_length %}{{ c.stock_item.current_length|floatformat:"-g" }}{% else %}—{% endif %})
+ {% if c.stock_item.deal_id %}(сделка № {{ c.stock_item.deal.number }}){% endif %}
{{ c.quantity|floatformat:"-g" }} шт
{% elif c.stock_item_id and c.stock_item.entity_id %}
diff --git a/shiftflow/views.py b/shiftflow/views.py
index bfdf865..70c502b 100644
--- a/shiftflow/views.py
+++ b/shiftflow/views.py
@@ -5180,8 +5180,10 @@ class LegacyWriteOffsView(LoginRequiredMixin, TemplateView):
'tasks__task__material',
'consumptions__material',
'consumptions__stock_item__material',
+ 'consumptions__stock_item__deal',
'results__stock_item__material',
'results__stock_item__entity',
+ 'results__stock_item__deal',
'remnants__material',
)
)
@@ -5206,6 +5208,8 @@ class LegacyWriteOffsView(LoginRequiredMixin, TemplateView):
si = res.stock_item
if res.kind == 'finished':
label = str(getattr(si, 'entity', None) or '—')
+ if getattr(si, 'deal_id', None) and getattr(getattr(si, 'deal', None), 'number', None):
+ label = f"{label} (сделка № {si.deal.number})"
produced[label] = produced.get(label, 0.0) + float(si.quantity)
elif res.kind == 'remnant':
label = str(getattr(si, 'material', None) or '—')
@@ -6186,8 +6190,10 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
'tasks__task__material',
'consumptions__material',
'consumptions__stock_item__material',
+ 'consumptions__stock_item__deal',
'results__stock_item__material',
'results__stock_item__entity',
+ 'results__stock_item__deal',
'remnants__material',
)
)
@@ -6212,6 +6218,8 @@ class WriteOffsView(LoginRequiredMixin, TemplateView):
si = res.stock_item
if res.kind == 'finished':
label = str(getattr(si, 'entity', None) or '—')
+ if getattr(si, 'deal_id', None) and getattr(getattr(si, 'deal', None), 'number', None):
+ label = f"{label} (сделка № {si.deal.number})"
produced[label] = produced.get(label, 0.0) + float(si.quantity)
elif res.kind == 'remnant':
label = str(getattr(si, 'material', None) or '—')