Skip to content
This repository was archived by the owner on Feb 25, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/dumper/n26.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ def fetch_transactions

def accept?(transaction)
return true unless @skip_pending_transactions
already_processed?(transaction)

# Card authorizations (if a company reserves some small amount)
# to check if your card is valid are the same type
# as processing transactions. So if we ignore those, we need to ignore
# the type for transactions where you get that authorization-money back.
already_processed?(transaction) &&
!returned_authorization?(transaction)
end

private
Expand Down Expand Up @@ -102,5 +108,11 @@ def import_id(transaction)
def already_processed?(transaction)
transaction['type'] != 'AA'
end

# This can be true if a company reserved some small money
# that they will give you back.
def returned_authorization?(transaction)
transaction['type'] == 'AV'
end
end
end
13 changes: 13 additions & 0 deletions spec/dumper/n26_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@
expect(accept?).to be_truthy
end
end

context 'when the transaction is processed ' \
'but a returned authorization' do
let(:transaction) do
t = transaction_processed
t['type'] = 'AV'
t
end

it 'returns true' do
expect(accept?).to be_falsy
end
end
end
end
end