Fix: Calculate total_payout from actual win amounts instead of redistributed amounts

- Fix _calculate_summary() to sum win_amount from bet details where result is 'won'
- Previously used total_redistributed which is amount redistributed to players, not payout to winners
- This fixes total_payout showing as 0 when there are winning bets
- Net profit calculation now works correctly
parent 501e171f
...@@ -1715,6 +1715,7 @@ class ReportsSyncResponseHandler(ResponseHandler): ...@@ -1715,6 +1715,7 @@ class ReportsSyncResponseHandler(ResponseHandler):
def _calculate_summary(self, bets: List, stats: List) -> Dict[str, Any]: def _calculate_summary(self, bets: List, stats: List) -> Dict[str, Any]:
"""Calculate summary statistics""" """Calculate summary statistics"""
total_payin = 0.0 total_payin = 0.0
total_payout = 0.0
total_bets = 0 total_bets = 0
for bet in bets: for bet in bets:
...@@ -1722,8 +1723,8 @@ class ReportsSyncResponseHandler(ResponseHandler): ...@@ -1722,8 +1723,8 @@ class ReportsSyncResponseHandler(ResponseHandler):
if bet_details: if bet_details:
total_payin += sum(d.amount for d in bet_details) total_payin += sum(d.amount for d in bet_details)
total_bets += len(bet_details) total_bets += len(bet_details)
# Add win amounts for winning bets
total_payout = sum(stat.total_redistributed for stat in stats) total_payout += sum(d.win_amount for d in bet_details if d.result == 'won')
return { return {
'total_payin': float(total_payin), 'total_payin': float(total_payin),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment