Fix: Use correct enum value 'win' instead of 'won' for bet result

- Fix _calculate_summary() to check for result == 'win' (correct enum value)
- Previously checked for result == 'won' which doesn't exist in BetResult enum
- Add safety check for bet_details to handle lazy loading
- Fixes total payout showing 0 when there are winning bets
parent 38b8162c
......@@ -1719,12 +1719,16 @@ class ReportsSyncResponseHandler(ResponseHandler):
total_bets = 0
for bet in bets:
bet_details = [d for d in bet.bet_details if d.result != 'cancelled']
# Ensure bet_details are loaded (handle lazy loading)
bet_details = []
if hasattr(bet, 'bet_details') and bet.bet_details:
bet_details = [d for d in bet.bet_details if d.result != 'cancelled']
if bet_details:
total_payin += sum(d.amount for d in bet_details)
total_bets += len(bet_details)
# Add win amounts for winning bets
total_payout += sum(d.win_amount for d in bet_details if d.result == 'won')
# Add win amounts for winning bets (result is 'win', not 'won')
total_payout += sum(d.win_amount for d in bet_details if d.result == 'win')
return {
'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