+def get_donations(agreement_id, year):
+ a = get_agreement(agreement_id)
+ transactions = []
+ for transaction in a.search_transactions(
+ date(year - 1, 12, 31),
+ date(year + 1, 1, 1))['agreement_transaction_list']:
+ if transaction['status'] != 'Completed':
+ continue
+ dt = datetime.strptime(
+ transaction['time_stamp'],
+ '%Y-%m-%dT%H:%M:%S%z'
+ ).astimezone()
+ if dt.year != year:
+ continue
+ assert transaction['amount']['currency'] == 'PLN'
+ transactions.append({
+ 'timestamp': dt,
+ 'amount': Decimal(transaction['amount']['value'])
+ })
+ return transactions