--- a/ledger.py +++ b/ledger.py @@ -1,2 +1,12 @@ def total_settled_cents(records): - return sum(row['cents'] for row in records if row['status'] == 'settled') + seen_ids = set() + total = 0 + for row in records: + if row['status'] != 'settled': + continue + tx_id = row['id'] + if tx_id in seen_ids: + continue + seen_ids.add(tx_id) + total += row['cents'] + return total