Skip to content

Commit

Permalink
Adding mapping for Amazon purchases.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 4, 2023
1 parent 445b76e commit 01db396
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions csv2ofx/mappings/amazon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Import transactions from Amazon Order History
as exported by Amazon Order History Reporter
(https://chrome.google.com/webstore/detail/amazon-order-history-repo/mgkilgclilajckgnedgjgnfdokkgnibi).
"""

import os
import functools
from operator import itemgetter


@functools.lru_cache()
def cards():
setting = os.environ.get('AMAZON_EXCLUDE_CARDS', None)
return setting.split(',') if setting else []


def exclude_cards(row):
return not any(card in row['payments'] for card in cards())


mapping = {
'has_header': True,
'delimiter': ',',
'bank': 'Amazon Purchases',
'account_id': os.environ.get('AMAZON_PURCHASES_ACCOUNT', '100000001'),
'date': itemgetter('date'),
'amount': itemgetter('total'),
'payee': 'Amazon',
'desc': itemgetter('items'),
'id': itemgetter('order id'),
'type': 'DEBIT',
'last_row': -1,
'filter': exclude_cards,
}

0 comments on commit 01db396

Please sign in to comment.