Fix Sport and Lottery Report: filter won/lost amounts correctly

Issue: Amount columns were showing both won and lost transactions
Fix: Only won=1 transactions now appear in amount columns

Changes:
- Added si.won field to SELECT query
- Amount up to 500: only counts won=1 items
- Amount over 500: only counts won=1 items
- Grand total: still shows all amounts (won + lost)

This ensures gambling report accuracy after won/lost bug fix.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Ali 2026-02-16 17:41:39 +04:00
parent bc08937278
commit bc37685f40
1 changed files with 9 additions and 6 deletions

View File

@ -76,6 +76,7 @@ def get_data(filters):
si.posting_date,
si.grand_total,
si.currency,
si.won,
sii.amount
)
.where(
@ -103,7 +104,9 @@ def get_data(filters):
"amount_over_500": 0,
}
# Distribute the item amount into the correct bucket
# Distribute the item amount into the correct bucket ONLY if won = 1
# Grand total already contains all amounts (won + lost)
if item.won == 1:
if item.amount <= 500:
processed_data[doc_name]["amount_up_to_500"] += item.amount
else: