diff --git a/taxes_az/taxes_az/report/sport_and_lottery_report/sport_and_lottery_report.py b/taxes_az/taxes_az/report/sport_and_lottery_report/sport_and_lottery_report.py index 8755908..23d7ad8 100644 --- a/taxes_az/taxes_az/report/sport_and_lottery_report/sport_and_lottery_report.py +++ b/taxes_az/taxes_az/report/sport_and_lottery_report/sport_and_lottery_report.py @@ -76,6 +76,7 @@ def get_data(filters): si.posting_date, si.grand_total, si.currency, + si.won, sii.amount ) .where( @@ -102,12 +103,14 @@ def get_data(filters): "amount_up_to_500": 0, "amount_over_500": 0, } - - # Distribute the item amount into the correct bucket - if item.amount <= 500: - processed_data[doc_name]["amount_up_to_500"] += item.amount - else: - processed_data[doc_name]["amount_over_500"] += item.amount + + # 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: + processed_data[doc_name]["amount_over_500"] += item.amount # Return the processed data as a list of dictionaries return list(processed_data.values())