add - summary total sharings of brokers on dashboard

This commit is contained in:
2025-11-29 14:40:40 +03:30
parent 111a44d1f9
commit 51f7e1b6cd

View File

@@ -130,7 +130,19 @@ class TransactionDashboardService:
key=lambda x: -x["total_price"]
)
# calculate total statistic of every broker
share_totals = defaultdict(lambda: {"total_price": 0, "count": 0})
for product in products_stats:
for item in product["item_share_stats"]:
name = item["name"]
share_totals[name]["total_price"] += item["total_price"]
share_totals[name]["count"] += item["count"]
share_totals = dict(share_totals)
return {
"transaction_summary": transaction_stats,
"product_summary": list(products_stats),
"brokers_sharing_summary": share_totals
}