fix - some improves on new excel transactions

This commit is contained in:
2026-01-04 16:35:16 +03:30
parent 3062a0167d
commit 78adbfd3ce

View File

@@ -636,19 +636,16 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
t_items = transaction_shares_map.get(t['id'], []) t_items = transaction_shares_map.get(t['id'], [])
products_str = '، '.join([i['name'] for i in t_items]) if t_items else '-' products_str = '، '.join([i['name'] for i in t_items]) if t_items else '-'
# جمع share totals هر تراکنش
share_values = [] share_values = []
for share_name in share_names: for share_name in share_names:
# print(t_items, '\n', share_name)
for i in t_items: for i in t_items:
share_total = sum( share_total = sum(
share['price'] for share in i['item_share'] if share['name'] == share_name) share['price'] for share in i['item_share'] if share['name'] == share_name)
share_values.append(share_total) share_values.append(share_total)
share_column_totals[share_name] += share_total share_column_totals[share_name] += share_total
# جمع کل
total_price += t['price_paid'] or 0 total_price += t['price_paid'] or 0
total_weight += sum(i['unit_price'] or 0 for i in t_items) # یا وزن واقعی اگر موجود باشه total_weight += sum(i['unit_price'] or 0 for i in t_items)
all_weight += total_weight all_weight += total_weight
list1 = [ list1 = [
@@ -661,9 +658,9 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
str(shamsi_date(t['transaction_date'], in_value=True)) if t.get('transaction_date') else '', str(shamsi_date(t['transaction_date'], in_value=True)) if t.get('transaction_date') else '',
products_str, products_str,
t.get('transaction_id', '-'), t.get('transaction_id', '-'),
'-', # شماره کارت اگر موجود باشه '-', # card
t.get('price_paid', 0), t.get('price_paid', 0),
f'{total_weight}کیلوگرم', # ماهیت وزن f'{total_weight}کیلوگرم',
TRANSACTION_STATUS_MAP.get(t.get('transaction_status'), '-'), TRANSACTION_STATUS_MAP.get(t.get('transaction_status'), '-'),
] ]
list1.extend(share_values) list1.extend(share_values)