-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding mapping for Amazon purchases.
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Import transactions from Amazon Order History | ||
as exported by Amazon Order History Reporter | ||
(https://chrome.google.com/webstore/detail/amazon-order-history-repo/mgkilgclilajckgnedgjgnfdokkgnibi). | ||
Honors a couple of environment variables: | ||
- ``AMAZON_EXCLUDE_CARDS``: comma-separated last-four digits | ||
of cards or payment methods to exclude in the output. | ||
- ``AMAZON_PURCHASES_ACCOUNT``: The OFX "account id" to use. | ||
Financial tools will use this account ID to associated with an | ||
account. If unspecified, defaults to "100000001". | ||
""" | ||
|
||
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
DATA:OFXSGML | ||
ENCODING:UTF-8 | ||
<OFX> | ||
<SIGNONMSGSRSV1> | ||
<SONRS> | ||
<STATUS> | ||
<CODE>0</CODE> | ||
<SEVERITY>INFO</SEVERITY> | ||
</STATUS> | ||
<DTSERVER>20161031112908</DTSERVER> | ||
<LANGUAGE>ENG</LANGUAGE> | ||
</SONRS> | ||
</SIGNONMSGSRSV1> | ||
<BANKMSGSRSV1> | ||
<STMTTRNRS> | ||
<TRNUID></TRNUID> | ||
<STATUS> | ||
<CODE>0</CODE> | ||
<SEVERITY>INFO</SEVERITY> | ||
</STATUS> | ||
<STMTRS> | ||
<CURDEF>USD</CURDEF> | ||
<BANKACCTFROM> | ||
<BANKID>83f2779c120eb1531fe646f32245de40</BANKID> | ||
<ACCTID>100000001</ACCTID> | ||
<ACCTTYPE>CHECKING</ACCTTYPE> | ||
</BANKACCTFROM> | ||
<BANKTRANLIST> | ||
<DTSTART>19700101</DTSTART> | ||
<DTEND>20230604</DTEND> | ||
<STMTTRN> | ||
<TRNTYPE>DEBIT</TRNTYPE> | ||
<DTPOSTED>20221220000000</DTPOSTED> | ||
<TRNAMT>-4.22</TRNAMT> | ||
<FITID>112-1635210-7125801</FITID> | ||
<NAME>Amazon</NAME> | ||
<MEMO>Goof Off Household Heavy Duty Remover, 4 fl. oz. Spray, For Spots, Stains, Marks, and Messes; </MEMO> | ||
</STMTTRN> | ||
<STMTTRN> | ||
<TRNTYPE>DEBIT</TRNTYPE> | ||
<DTPOSTED>20221220000000</DTPOSTED> | ||
<TRNAMT>-7.42</TRNAMT> | ||
<FITID>111-3273904-8117030</FITID> | ||
<NAME>Amazon</NAME> | ||
<MEMO>Darksteve - Violet Decorative Light Bulb - Edison Light Bulb, Antique Vintage Style Light, G80 Size, E26 Base, Non-Dimmable (3w/110v); </MEMO> | ||
</STMTTRN> | ||
</BANKTRANLIST> | ||
</STMTRS> | ||
</STMTTRNRS> | ||
</BANKMSGSRSV1> | ||
</OFX> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
order id,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments | ||
112-1635210-7125801,"Goof Off Household Heavy Duty Remover, 4 fl. oz. Spray, For Spots, Stains, Marks, and Messes; ",John Doe,2022-12-20,4.22,0,0,0,0.24,0,"Visa ending in 1234: December 24, 2022: $4.22; " | ||
111-3273904-8117030,"Darksteve - Violet Decorative Light Bulb - Edison Light Bulb, Antique Vintage Style Light, G80 Size, E26 Base, Non-Dimmable (3w/110v); ",John Doe,2022-12-20,7.42,0,0,0,0.42,0,"Visa ending in 1234: December 28, 2022: $7.42; " | ||
114-5269613-6941034,"TOPGREENER Smart Wi-Fi In-Wall Tamper Resistant Dual USB Charger Outlet, Energy Monitoring, Compatible with Amazon Alexa and Google Assistant, Outlet; ",John Doe,2022-10-11,34.12,0,0,0,1.93,0,"Visa ending in 9876: October 12, 2022: $34.12; " | ||
order id,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters